aboutsummaryrefslogtreecommitdiffstats
path: root/Demos/Device/ClassDriver/MassStorage/Lib
diff options
context:
space:
mode:
authorDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
committerDean Camera <dean@fourwalledcubicle.com>2009-06-18 10:31:55 +0000
commitf896c00c48f04fb9273555ab8d9b1af99f865d25 (patch)
treeb76827a0467c77ddeb30e11748c02a4f53779a14 /Demos/Device/ClassDriver/MassStorage/Lib
parente338cb6f329d6bf948abad88637f81436ee90daf (diff)
downloadlufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.gz
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.tar.bz2
lufa-f896c00c48f04fb9273555ab8d9b1af99f865d25.zip
Break device mode class driver interfaces into seperate config and state structs which are then combined, for clarity. Move device mode class driver interfaces back into the device mode class driver headers from the common class headers to make room for host class interfaces.
Diffstat (limited to 'Demos/Device/ClassDriver/MassStorage/Lib')
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c8
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h4
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c52
-rw-r--r--Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h12
4 files changed, 38 insertions, 38 deletions
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
index 4ec52c345..5b5a2bd90 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.c
@@ -47,7 +47,7 @@
* \param BlockAddress Data block starting address for the write sequence
* \param TotalBlocks Number of blocks of data to write
*/
-void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
+void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
{
uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
@@ -143,7 +143,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uin
BytesInBlockDiv16++;
/* Check if the current command is being aborted by the host */
- if (MSInterfaceInfo->IsMassStoreReset)
+ if (MSInterfaceInfo->State.IsMassStoreReset)
return;
}
@@ -173,7 +173,7 @@ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uin
* \param BlockAddress Data block starting address for the read sequence
* \param TotalBlocks Number of blocks of data to read
*/
-void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
+void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress, uint16_t TotalBlocks)
{
uint16_t CurrDFPage = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) / DATAFLASH_PAGE_SIZE);
uint16_t CurrDFPageByte = ((BlockAddress * VIRTUAL_MEMORY_BLOCK_SIZE) % DATAFLASH_PAGE_SIZE);
@@ -252,7 +252,7 @@ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint
BytesInBlockDiv16++;
/* Check if the current command is being aborted by the host */
- if (MSInterfaceInfo->IsMassStoreReset)
+ if (MSInterfaceInfo->State.IsMassStoreReset)
return;
}
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
index 8cf190727..ace6231db 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/DataflashManager.h
@@ -64,9 +64,9 @@
#define VIRTUAL_MEMORY_BLOCKS (VIRTUAL_MEMORY_BYTES / VIRTUAL_MEMORY_BLOCK_SIZE)
/* Function Prototypes: */
- void DataflashManager_WriteBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress,
+ void DataflashManager_WriteBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress,
uint16_t TotalBlocks);
- void DataflashManager_ReadBlocks(USB_ClassInfo_MS_t* MSInterfaceInfo, const uint32_t BlockAddress,
+ void DataflashManager_ReadBlocks(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const uint32_t BlockAddress,
uint16_t TotalBlocks);
void DataflashManager_WriteBlocks_RAM(const uint32_t BlockAddress, uint16_t TotalBlocks,
uint8_t* BufferPtr) ATTR_NON_NULL_PTR_ARG(3);
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
index d56e343a7..4e6c05013 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.c
@@ -86,12 +86,12 @@ SCSI_Request_Sense_Response_t SenseData =
*
* \param MSInterfaceInfo Pointer to the Mass Storage class interface structure that the command is associated with
*/
-bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
+bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
bool CommandSuccess = false;
/* Run the appropriate SCSI command hander function based on the passed command */
- switch (MSInterfaceInfo->CommandBlock.SCSICommandData[0])
+ switch (MSInterfaceInfo->State.CommandBlock.SCSICommandData[0])
{
case SCSI_CMD_INQUIRY:
CommandSuccess = SCSI_Command_Inquiry(MSInterfaceInfo);
@@ -116,7 +116,7 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
case SCSI_CMD_VERIFY_10:
/* These commands should just succeed, no handling required */
CommandSuccess = true;
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
break;
default:
/* Update the SENSE key to reflect the invalid command */
@@ -146,16 +146,16 @@ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
- uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->CommandBlock.SCSICommandData[3] << 8) |
- MSInterfaceInfo->CommandBlock.SCSICommandData[4]);
+ uint16_t AllocationLength = (((uint16_t)MSInterfaceInfo->State.CommandBlock.SCSICommandData[3] << 8) |
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[4]);
uint16_t BytesTransferred = (AllocationLength < sizeof(InquiryData))? AllocationLength :
sizeof(InquiryData);
/* Only the standard INQUIRY data is supported, check if any optional INQUIRY bits set */
- if ((MSInterfaceInfo->CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||
- MSInterfaceInfo->CommandBlock.SCSICommandData[2])
+ if ((MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & ((1 << 0) | (1 << 1))) ||
+ MSInterfaceInfo->State.CommandBlock.SCSICommandData[2])
{
/* Optional but unsupported bits set - update the SENSE key and fail the request */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
@@ -176,7 +176,7 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
return true;
}
@@ -188,9 +188,9 @@ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
- uint8_t AllocationLength = MSInterfaceInfo->CommandBlock.SCSICommandData[4];
+ uint8_t AllocationLength = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
uint8_t BytesTransferred = (AllocationLength < sizeof(SenseData))? AllocationLength : sizeof(SenseData);
uint8_t PadBytes[AllocationLength - BytesTransferred];
@@ -200,7 +200,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= BytesTransferred;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= BytesTransferred;
return true;
}
@@ -212,7 +212,7 @@ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
uint32_t TotalLUNs = (LUN_MEDIA_BLOCKS - 1);
uint32_t MediaBlockSize = VIRTUAL_MEMORY_BLOCK_SIZE;
@@ -222,7 +222,7 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
Endpoint_ClearIN();
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= 8;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= 8;
return true;
}
@@ -235,12 +235,12 @@ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
+static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo)
{
uint8_t ReturnByte;
/* Check to see if the SELF TEST bit is not set */
- if (!(MSInterfaceInfo->CommandBlock.SCSICommandData[1] & (1 << 2)))
+ if (!(MSInterfaceInfo->State.CommandBlock.SCSICommandData[1] & (1 << 2)))
{
/* Only self-test supported - update SENSE key and fail the command */
SCSI_SET_SENSE(SCSI_SENSE_KEY_ILLEGAL_REQUEST,
@@ -287,7 +287,7 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
#endif
/* Succeed the command and update the bytes transferred counter */
- MSInterfaceInfo->CommandBlock.DataTransferLength = 0;
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength = 0;
return true;
}
@@ -301,20 +301,20 @@ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo)
*
* \return Boolean true if the command completed successfully, false otherwise.
*/
-static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const bool IsDataRead)
+static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const bool IsDataRead)
{
uint32_t BlockAddress;
uint16_t TotalBlocks;
/* Load in the 32-bit block address (SCSI uses big-endian, so have to do it byte-by-byte) */
- ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->CommandBlock.SCSICommandData[2];
- ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->CommandBlock.SCSICommandData[3];
- ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[4];
- ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[5];
+ ((uint8_t*)&BlockAddress)[3] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[2];
+ ((uint8_t*)&BlockAddress)[2] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[3];
+ ((uint8_t*)&BlockAddress)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[4];
+ ((uint8_t*)&BlockAddress)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[5];
/* Load in the 16-bit total blocks (SCSI uses big-endian, so have to do it byte-by-byte) */
- ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->CommandBlock.SCSICommandData[7];
- ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->CommandBlock.SCSICommandData[8];
+ ((uint8_t*)&TotalBlocks)[1] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[7];
+ ((uint8_t*)&TotalBlocks)[0] = MSInterfaceInfo->State.CommandBlock.SCSICommandData[8];
/* Check if the block address is outside the maximum allowable value for the LUN */
if (BlockAddress >= LUN_MEDIA_BLOCKS)
@@ -329,7 +329,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const
#if (TOTAL_LUNS > 1)
/* Adjust the given block address to the real media address based on the selected LUN */
- BlockAddress += ((uint32_t)MSInterfaceInfo->CommandBlock.LUN * LUN_MEDIA_BLOCKS);
+ BlockAddress += ((uint32_t)MSInterfaceInfo->State.CommandBlock.LUN * LUN_MEDIA_BLOCKS);
#endif
/* Determine if the packet is a READ (10) or WRITE (10) command, call appropriate function */
@@ -339,7 +339,7 @@ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const
DataflashManager_WriteBlocks(MSInterfaceInfo, BlockAddress, TotalBlocks);
/* Update the bytes transferred counter and succeed the command */
- MSInterfaceInfo->CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
+ MSInterfaceInfo->State.CommandBlock.DataTransferLength -= ((uint32_t)TotalBlocks * VIRTUAL_MEMORY_BLOCK_SIZE);
return true;
}
diff --git a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
index 8c3e104d9..bf61d8edc 100644
--- a/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
+++ b/Demos/Device/ClassDriver/MassStorage/Lib/SCSI.h
@@ -135,14 +135,14 @@
} SCSI_Request_Sense_Response_t;
/* Function Prototypes: */
- bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_t* MSInterfaceInfo);
+ bool SCSI_DecodeSCSICommand(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
#if defined(INCLUDE_FROM_SCSI_C)
- static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_t* MSInterfaceInfo);
- static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_t* MSInterfaceInfo, const bool IsDataRead);
+ static bool SCSI_Command_Inquiry(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Request_Sense(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Read_Capacity_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_Send_Diagnostic(USB_ClassInfo_MS_Device_t* MSInterfaceInfo);
+ static bool SCSI_Command_ReadWrite_10(USB_ClassInfo_MS_Device_t* MSInterfaceInfo, const bool IsDataRead);
#endif
#endif