From c326fe96050cf80992ded7726e9222ac5305a908 Mon Sep 17 00:00:00 2001 From: Dean Camera Date: Fri, 9 Jul 2010 07:24:34 +0000 Subject: Rewrote the implementation of the SwapEndian_16() and SwapEndian_32() functions so that they compile down in most instances to minimal loads and stores rather than complicated shifts. Fixed SCSI.c implementations of all the demos/projects casting the block count to a 32-bit temporary before calling SwapEndian_16(). --- Projects/TemperatureDataLogger/Lib/SCSI.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'Projects/TemperatureDataLogger') diff --git a/Projects/TemperatureDataLogger/Lib/SCSI.c b/Projects/TemperatureDataLogger/Lib/SCSI.c index 55312e87b..d499d9ac3 100644 --- a/Projects/TemperatureDataLogger/Lib/SCSI.c +++ b/Projects/TemperatureDataLogger/Lib/SCSI.c @@ -160,7 +160,7 @@ static void SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* const MSInterfaceInf uint8_t PadBytes[AllocationLength - BytesTransferred]; /* Pad out remaining bytes with 0x00 */ - Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK); /* Finalize the stream transfer to send the last packet */ Endpoint_ClearIN(); @@ -182,7 +182,7 @@ static void SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* const MSInterf uint8_t PadBytes[AllocationLength - BytesTransferred]; Endpoint_Write_Stream_LE(&SenseData, BytesTransferred, NO_STREAM_CALLBACK); - Endpoint_Write_Stream_LE(&PadBytes, (AllocationLength - BytesTransferred), NO_STREAM_CALLBACK); + Endpoint_Write_Stream_LE(&PadBytes, sizeof(PadBytes), NO_STREAM_CALLBACK); Endpoint_ClearIN(); /* Succeed the command and update the bytes transferred counter */ @@ -257,7 +257,7 @@ static void SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* const MSInterfa BlockAddress = SwapEndian_32(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[2]); /* Load in the 16-bit total blocks (SCSI uses big-endian, so have to reverse the byte order) */ - TotalBlocks = SwapEndian_16(*(uint32_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]); + TotalBlocks = SwapEndian_16(*(uint16_t*)&MSInterfaceInfo->State.CommandBlock.SCSICommandData[7]); /* Check if the block address is outside the maximum allowable value for the LUN */ if (BlockAddress >= VIRTUAL_MEMORY_BLOCKS) -- cgit v1.2.3