From 9e34144c9b7454ab69215c17d75a8ba2dcdcb929 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Wed, 28 Apr 2010 14:33:10 +0000 Subject: Use puts_P() and printf_P() instead of the normal variants where possible in the Host mode Class Driver demos. --- LUFA/Common/Common.h | 16 ++++++++-------- LUFA/Drivers/USB/Class/Host/MassStorage.c | 14 ++++---------- LUFA/ManPages/ChangeLog.txt | 1 + 3 files changed, 13 insertions(+), 18 deletions(-) (limited to 'LUFA') diff --git a/LUFA/Common/Common.h b/LUFA/Common/Common.h index 5f1b2eae5..a59a213a8 100644 --- a/LUFA/Common/Common.h +++ b/LUFA/Common/Common.h @@ -164,18 +164,18 @@ * \param[in,out] Data Pointer to a number containing an even number of bytes to be reversed * \param[in] Bytes Length of the data in bytes */ - static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes); - static inline void SwapEndian_n(uint8_t* Data, uint8_t Bytes) + static inline void SwapEndian_n(void* Data, uint8_t Bytes); + static inline void SwapEndian_n(void* Data, uint8_t Bytes) { - uint8_t Temp; - + uint8_t* CurrDataPos = Data; + while (Bytes) { - Temp = *Data; - *Data = *(Data + Bytes - 1); - *(Data + Bytes - 1) = Temp; + uint8_t Temp = *CurrDataPos; + *CurrDataPos = *(CurrDataPos + Bytes - 1); + *(CurrDataPos + Bytes - 1) = Temp; - Data++; + CurrDataPos++; Bytes -= 2; } } diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index 4ec0b244f..f148f4ecc 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -134,7 +134,8 @@ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInf { uint8_t ErrorCode = PIPE_RWSTREAM_NoError; - SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag; + SCSICommandBlock->Signature = CBW_SIGNATURE; + SCSICommandBlock->Tag = ++MSInterfaceInfo->State.TransactionTag; if (MSInterfaceInfo->State.TransactionTag == 0xFFFFFFFF) MSInterfaceInfo->State.TransactionTag = 1; @@ -334,7 +335,6 @@ uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, c MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = sizeof(SCSI_Inquiry_Response_t), .Flags = COMMAND_DIRECTION_DATA_IN, .LUN = LUNIndex, @@ -370,7 +370,6 @@ uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, co MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = 0, .Flags = COMMAND_DIRECTION_DATA_IN, .LUN = LUNIndex, @@ -407,7 +406,6 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = sizeof(SCSI_Capacity_t), .Flags = COMMAND_DIRECTION_DATA_IN, .LUN = LUNIndex, @@ -432,8 +430,8 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* const MSInterfaceInf if ((ErrorCode = MS_Host_SendCommand(MSInterfaceInfo, &SCSICommandBlock, DeviceCapacity)) != PIPE_RWSTREAM_NoError) return ErrorCode; - DeviceCapacity->Blocks = SwapEndian_32(DeviceCapacity->Blocks); - DeviceCapacity->BlockSize = SwapEndian_32(DeviceCapacity->BlockSize); + SwapEndian_n(&DeviceCapacity->Blocks, sizeof(DeviceCapacity->Blocks)); + SwapEndian_n(&DeviceCapacity->BlockSize, sizeof(DeviceCapacity->BlockSize)); if ((ErrorCode = MS_Host_GetReturnedStatus(MSInterfaceInfo, &SCSICommandStatus)) != PIPE_RWSTREAM_NoError) return ErrorCode; @@ -451,7 +449,6 @@ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, con MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = sizeof(SCSI_Request_Sense_Response_t), .Flags = COMMAND_DIRECTION_DATA_IN, .LUN = LUNIndex, @@ -488,7 +485,6 @@ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInter MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = 0, .Flags = COMMAND_DIRECTION_DATA_OUT, .LUN = LUNIndex, @@ -525,7 +521,6 @@ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = ((uint32_t)Blocks * BlockSize), .Flags = COMMAND_DIRECTION_DATA_IN, .LUN = LUNIndex, @@ -566,7 +561,6 @@ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo MS_CommandBlockWrapper_t SCSICommandBlock = (MS_CommandBlockWrapper_t) { - .Signature = CBW_SIGNATURE, .DataTransferLength = ((uint32_t)Blocks * BlockSize), .Flags = COMMAND_DIRECTION_DATA_OUT, .LUN = LUNIndex, diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 2a772b880..04aa9a497 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -29,6 +29,7 @@ * builds of avrdude at the expense of AVRStudio compatibility * - Removed two-step endpoint/pipe bank clear and switch sequence for smaller, faster endpoint/pipe code * - The USB_Init() function no longer calls sei() - the user is now responsible for enabling interrupts when they are ready + * for them to be enabled (thanks to Andrei Krainev) * * Fixed: * - Fixed software PDI/TPI programming mode in the AVRISP project not correctly toggling just the clock pin -- cgit v1.2.3