diff options
author | Dean Camera <[email protected]> | 2009-08-26 07:34:31 +0000 |
---|---|---|
committer | Dean Camera <[email protected]> | 2009-08-26 07:34:31 +0000 |
commit | 31d8ebebc0796873f7c70db80a04acdcbb307ed8 (patch) | |
tree | 175e917bd85a7e5a449dfd80e8e8dfff55f1b334 /LUFA | |
parent | ee744abb7efd5fef49782991d58895e10696809a (diff) | |
download | qmk_firmware-31d8ebebc0796873f7c70db80a04acdcbb307ed8.tar.gz qmk_firmware-31d8ebebc0796873f7c70db80a04acdcbb307ed8.zip |
Oops: Really disable building of Projects/Host/ClassDriver directory in the Projects/Host/ makefile.
Add more skeleton functions and definitions to the Mass Storage Host mode Class driver.
Made Endpoint_Write_DWord_* functions echo the structure of the matching Endpoint routines for clarity.
Diffstat (limited to 'LUFA')
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.c | 24 | ||||
-rw-r--r-- | LUFA/Drivers/USB/Class/Host/MassStorage.h | 35 | ||||
-rw-r--r-- | LUFA/Drivers/USB/LowLevel/Pipe.h | 12 | ||||
-rw-r--r-- | LUFA/ManPages/ChangeLog.txt | 1 |
4 files changed, 56 insertions, 16 deletions
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.c b/LUFA/Drivers/USB/Class/Host/MassStorage.c index ea7ed3d8a3..a0b34610cd 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.c +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.c @@ -131,7 +131,7 @@ void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) }
-static uint8_t MassStore_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_CommandBlockWrapper_t* SCSICommandBlock)
+static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, MS_CommandBlockWrapper_t* SCSICommandBlock)
{
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
@@ -152,7 +152,7 @@ static uint8_t MassStore_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, M return PIPE_RWSTREAM_NoError;
}
-static uint8_t MassStore_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
+static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo)
{
uint16_t TimeoutMSRem = COMMAND_DATA_TIMEOUT_MS;
@@ -205,7 +205,7 @@ static uint8_t MassStore_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfac return PIPE_RWSTREAM_NoError;
}
-static uint8_t MassStore_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
+static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr)
{
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
@@ -243,12 +243,12 @@ static uint8_t MassStore_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInf return PIPE_RWSTREAM_NoError;
}
-static uint8_t MassStore_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
+static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
MS_CommandStatusWrapper_t* SCSICommandStatus)
{
uint8_t ErrorCode = PIPE_RWSTREAM_NoError;
- if ((ErrorCode = MassStore_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)
+ if ((ErrorCode = MS_Host_WaitForDataReceived(MSInterfaceInfo)) != PIPE_RWSTREAM_NoError)
return ErrorCode;
Pipe_SelectPipe(MSInterfaceInfo->Config.DataINPipeNumber);
@@ -312,11 +312,25 @@ uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* Max uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, SCSI_Inquiry_Response_t* InquiryData)
{
+ if ((USB_HostState != HOST_STATE_Configured) || !(MSInterfaceInfo->State.Active))
+ return HOST_SENDCONTROL_DeviceDisconnect;
}
uint8_t MS_Host_TestUnitReady(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool* DeviceReady);
+
uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
SCSI_Capacity_t* DeviceCapacity);
+uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
+ SCSI_Request_Sense_Response_t* SenseData);
+
+uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, bool PreventRemoval);
+
+uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddr,
+ uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer);
+
+uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddr,
+ uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer);
+
#endif
diff --git a/LUFA/Drivers/USB/Class/Host/MassStorage.h b/LUFA/Drivers/USB/Class/Host/MassStorage.h index a8a957bab4..7ee3b88046 100644 --- a/LUFA/Drivers/USB/Class/Host/MassStorage.h +++ b/LUFA/Drivers/USB/Class/Host/MassStorage.h @@ -199,6 +199,15 @@ */
uint8_t MS_Host_ResetMSInterface(USB_ClassInfo_MS_Host_t* MSInterfaceInfo) ATTR_NON_NULL_PTR_ARG(1);
+ /** Sends a GET MAX LUN control request to the attached device, retrieving the index of the highest LUN (Logical
+ * UNit, a logical drive) in the device. This value can then be used in the other functions of the Mass Storage
+ * Host mode Class driver to address a specific LUN within the device.
+ *
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state
+ * \param[out] MaxLUNIndex Pointer to a location where the highest LUN index value should be stored
+ *
+ * \return A value from the \ref USB_Host_SendControlErrorCodes_t enum
+ */
uint8_t MS_Host_GetMaxLUN(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t* MaxLUNIndex) ATTR_NON_NULL_PTR_ARG(1, 2);
uint8_t MS_Host_GetInquiryData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
@@ -210,6 +219,18 @@ uint8_t MS_Host_ReadDeviceCapacity(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
SCSI_Capacity_t* DeviceCapacity) ATTR_NON_NULL_PTR_ARG(1, 3);
+ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
+ SCSI_Request_Sense_Response_t* SenseData) ATTR_NON_NULL_PTR_ARG(1, 3);
+
+ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex,
+ bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1);
+
+ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddr,
+ uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6);
+
+ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* MSInterfaceInfo, uint8_t LUNIndex, uint32_t BlockAddr,
+ uint8_t Blocks, uint16_t BlockSize, void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1, 6);
+
/* Private Interface - For use in library only: */
#if !defined(__DOXYGEN__)
/* Macros: */
@@ -236,13 +257,13 @@ static uint8_t DComp_NextMassStorageInterface(void* CurrentDescriptor);
static uint8_t DComp_NextInterfaceBulkDataEndpoint(void* CurrentDescriptor);
- static uint8_t MassStore_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
- MS_CommandBlockWrapper_t* SCSICommandBlock);
- static uint8_t MassStore_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo);
- static uint8_t MassStore_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
- MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr);
- static uint8_t MassStore_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
- MS_CommandStatusWrapper_t* SCSICommandStatus);
+ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
+ MS_CommandBlockWrapper_t* SCSICommandBlock);
+ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* MSInterfaceInfo);
+ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
+ MS_CommandBlockWrapper_t* SCSICommandBlock, void* BufferPtr);
+ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* MSInterfaceInfo,
+ MS_CommandStatusWrapper_t* SCSICommandStatus);
#endif
#endif
diff --git a/LUFA/Drivers/USB/LowLevel/Pipe.h b/LUFA/Drivers/USB/LowLevel/Pipe.h index beee2eb85a..1057ec8bc3 100644 --- a/LUFA/Drivers/USB/LowLevel/Pipe.h +++ b/LUFA/Drivers/USB/LowLevel/Pipe.h @@ -699,8 +699,10 @@ static inline void Pipe_Write_DWord_LE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_LE(const uint32_t DWord)
{
- Pipe_Write_Word_LE(DWord);
- Pipe_Write_Word_LE(DWord >> 16);
+ UPDATX = (DWord & 0xFF);
+ UPDATX = (DWord >> 8);
+ UPDATX = (DWord >> 16);
+ UPDATX = (DWord >> 24);
}
/** Writes four bytes to the currently selected pipe's bank in big endian format, for IN
@@ -713,8 +715,10 @@ static inline void Pipe_Write_DWord_BE(const uint32_t DWord) ATTR_ALWAYS_INLINE;
static inline void Pipe_Write_DWord_BE(const uint32_t DWord)
{
- Pipe_Write_Word_BE(DWord >> 16);
- Pipe_Write_Word_BE(DWord);
+ UPDATX = (DWord >> 24);
+ UPDATX = (DWord >> 16);
+ UPDATX = (DWord >> 8);
+ UPDATX = (DWord & 0xFF);
}
/** Discards four bytes from the currently selected pipe's bank, for OUT direction pipes.
diff --git a/LUFA/ManPages/ChangeLog.txt b/LUFA/ManPages/ChangeLog.txt index 981ff1ded1..61485a0dd4 100644 --- a/LUFA/ManPages/ChangeLog.txt +++ b/LUFA/ManPages/ChangeLog.txt @@ -25,6 +25,7 @@ * - Added return values to the CDC and MIDI class driver transmit functions
* - Added extra masks to the SPI driver, changed SPI_Init() so that the clock polarity and sample modes can be set
* - Optimized Endpoint_Read_Word_* and Pipe_Read_Word_* macros to reduce compiled size
+ * - Added non-null function parameter pointer restrictions to USB Class drivers to improve user code reliability
*
* <b>Fixed:</b>
* - Fixed possible lockup in the CDC device class driver, when the host sends data that is a multiple of the
|