X-Git-Url: http://git.linex4red.de/pub/USBasp.git/blobdiff_plain/d1e52660368d34d693131f6aff3c8fd8584162e5..b61049f7222a6290e2164966bd90f636bcb577f9:/LUFA/Drivers/USB/Class/Device/MassStorage.c diff --git a/LUFA/Drivers/USB/Class/Device/MassStorage.c b/LUFA/Drivers/USB/Class/Device/MassStorage.c index 1c41f6046..1dc6d600c 100644 --- a/LUFA/Drivers/USB/Class/Device/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Device/MassStorage.c @@ -28,12 +28,15 @@ this software. */ -#define INCLUDE_FROM_MS_CLASS_C +#include "../../HighLevel/USBMode.h" +#if defined(USB_CAN_BE_DEVICE) + +#define INCLUDE_FROM_MS_CLASS_DEVICE_C #include "MassStorage.h" static USB_ClassInfo_MS_t* CallbackMSInterfaceInfo; -void USB_MS_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo) +void MS_Device_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo) { if (!(Endpoint_IsSETUPReceived())) return; @@ -72,7 +75,7 @@ void USB_MS_ProcessControlPacket(USB_ClassInfo_MS_t* MSInterfaceInfo) } } -bool USB_MS_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo) +bool MS_Device_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo) { if (!(Endpoint_ConfigureEndpoint(MSInterfaceInfo->DataINEndpointNumber, EP_TYPE_BULK, ENDPOINT_DIR_IN, MSInterfaceInfo->DataINEndpointSize, @@ -91,7 +94,7 @@ bool USB_MS_ConfigureEndpoints(USB_ClassInfo_MS_t* MSInterfaceInfo) return true; } -void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo) +void MS_Device_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo) { if (!(USB_IsConnected)) return; @@ -100,21 +103,21 @@ void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo) if (Endpoint_IsReadWriteAllowed()) { - if (USB_MS_ReadInCommandBlock(MSInterfaceInfo)) + if (MS_Device_ReadInCommandBlock(MSInterfaceInfo)) { - if (MSInterfaceInfo->CommandBlock.Flags & COMMAND_DIRECTION_DATA_IN) + if (MSInterfaceInfo->CommandBlock.Flags & MS_COMMAND_DIR_DATA_IN) Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber); - MSInterfaceInfo->CommandStatus.Status = CALLBACK_USB_MS_SCSICommandReceived(MSInterfaceInfo) ? - Command_Pass : Command_Fail; - MSInterfaceInfo->CommandStatus.Signature = CSW_SIGNATURE; + MSInterfaceInfo->CommandStatus.Status = CALLBACK_MS_Device_SCSICommandReceived(MSInterfaceInfo) ? + SCSI_Command_Pass : SCSI_Command_Fail; + MSInterfaceInfo->CommandStatus.Signature = MS_CSW_SIGNATURE; MSInterfaceInfo->CommandStatus.Tag = MSInterfaceInfo->CommandBlock.Tag; MSInterfaceInfo->CommandStatus.DataTransferResidue = MSInterfaceInfo->CommandBlock.DataTransferLength; - if ((MSInterfaceInfo->CommandStatus.Status == Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue)) + if ((MSInterfaceInfo->CommandStatus.Status == SCSI_Command_Fail) && (MSInterfaceInfo->CommandStatus.DataTransferResidue)) Endpoint_StallTransaction(); - USB_MS_ReturnCommandStatus(MSInterfaceInfo); + MS_Device_ReturnCommandStatus(MSInterfaceInfo); if (MSInterfaceInfo->IsMassStoreReset) { @@ -132,18 +135,18 @@ void USB_MS_USBTask(USB_ClassInfo_MS_t* MSInterfaceInfo) } } -static bool USB_MS_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo) +static bool MS_Device_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo) { Endpoint_SelectEndpoint(MSInterfaceInfo->DataOUTEndpointNumber); CallbackMSInterfaceInfo = MSInterfaceInfo; Endpoint_Read_Stream_LE(&MSInterfaceInfo->CommandBlock, - (sizeof(CommandBlockWrapper_t) - MAX_SCSI_COMMAND_LENGTH), - StreamCallback_AbortOnMassStoreReset); + (sizeof(CommandBlockWrapper_t) - 16), + StreamCallback_MS_Device_AbortOnMassStoreReset); - if ((MSInterfaceInfo->CommandBlock.Signature != CBW_SIGNATURE) || + if ((MSInterfaceInfo->CommandBlock.Signature != MS_CBW_SIGNATURE) || (MSInterfaceInfo->CommandBlock.LUN >= MSInterfaceInfo->TotalLUNs) || - (MSInterfaceInfo->CommandBlock.SCSICommandLength > MAX_SCSI_COMMAND_LENGTH)) + (MSInterfaceInfo->CommandBlock.SCSICommandLength > 16)) { Endpoint_StallTransaction(); Endpoint_SelectEndpoint(MSInterfaceInfo->DataINEndpointNumber); @@ -155,7 +158,7 @@ static bool USB_MS_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo) CallbackMSInterfaceInfo = MSInterfaceInfo; Endpoint_Read_Stream_LE(&MSInterfaceInfo->CommandBlock.SCSICommandData, MSInterfaceInfo->CommandBlock.SCSICommandLength, - StreamCallback_AbortOnMassStoreReset); + StreamCallback_MS_Device_AbortOnMassStoreReset); Endpoint_ClearOUT(); @@ -165,7 +168,7 @@ static bool USB_MS_ReadInCommandBlock(USB_ClassInfo_MS_t* MSInterfaceInfo) return true; } -static void USB_MS_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo) +static void MS_Device_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo) { Endpoint_SelectEndpoint(MSInterfaceInfo->DataOUTEndpointNumber); @@ -189,7 +192,7 @@ static void USB_MS_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo) CallbackMSInterfaceInfo = MSInterfaceInfo; Endpoint_Write_Stream_LE(&MSInterfaceInfo->CommandStatus, sizeof(CommandStatusWrapper_t), - StreamCallback_AbortOnMassStoreReset); + StreamCallback_MS_Device_AbortOnMassStoreReset); Endpoint_ClearIN(); @@ -197,12 +200,14 @@ static void USB_MS_ReturnCommandStatus(USB_ClassInfo_MS_t* MSInterfaceInfo) return; } -static uint8_t StreamCallback_AbortOnMassStoreReset(void) +static uint8_t StreamCallback_MS_Device_AbortOnMassStoreReset(void) { - USB_MS_USBTask(CallbackMSInterfaceInfo); + MS_Device_USBTask(CallbackMSInterfaceInfo); if (CallbackMSInterfaceInfo->IsMassStoreReset) return STREAMCALLBACK_Abort; else return STREAMCALLBACK_Continue; } + +#endif