+ /** Retrieves the device sense data, indicating the current device state and error codes for the previously\r
+ * issued command.\r
+ *\r
+ * \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to\r
+ * \param[out] SenseData Pointer to the location where the sense information should be stored\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready\r
+ */\r
+ uint8_t MS_Host_RequestSense(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex,\r
+ SCSI_Request_Sense_Response_t* const SenseData) ATTR_NON_NULL_PTR_ARG(1)\r
+ ATTR_NON_NULL_PTR_ARG(3);\r
+ \r
+ /** Issues a PREVENT MEDIUM REMOVAL command, to logically (or, depending on the type of device, physically) lock\r
+ * the device from removal so that blocks of data on the medium can be read or altered.\r
+ *\r
+ * \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to\r
+ * \param[in] PreventRemoval Boolean true if the device should be locked from removal, false otherwise\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready\r
+ */\r
+ uint8_t MS_Host_PreventAllowMediumRemoval(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex,\r
+ const bool PreventRemoval) ATTR_NON_NULL_PTR_ARG(1);\r
+ \r
+ /** Reads blocks of data from the attached Mass Storage device's medium.\r
+ *\r
+ * \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to\r
+ * \param[in] BlockAddress Starting block address within the device to read from\r
+ * \param[in] Blocks Total number of blocks to read\r
+ * \param[in] BlockSize Size in bytes of each block within the device\r
+ * \param[out] BlockBuffer Pointer to where the read data from the device should be stored\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready\r
+ */\r
+ uint8_t MS_Host_ReadDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize,\r
+ void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);\r
+ \r
+ /** Writes blocks of data to the attached Mass Storage device's medium.\r
+ *\r
+ * \note This function must only be called when the Host state machine is in the HOST_STATE_Configured state or the\r
+ * call will fail.\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing a MS Class host configuration and state\r
+ * \param[in] LUNIndex LUN index within the device the command is being issued to\r
+ * \param[in] BlockAddress Starting block address within the device to write to\r
+ * \param[in] Blocks Total number of blocks to read\r
+ * \param[in] BlockSize Size in bytes of each block within the device\r
+ * \param[in] BlockBuffer Pointer to where the data to write should be sourced from\r
+ *\r
+ * \return A value from the \ref Pipe_Stream_RW_ErrorCodes_t enum or MS_ERROR_LOGICAL_CMD_FAILED if not ready\r
+ */\r
+ uint8_t MS_Host_WriteDeviceBlocks(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, const uint8_t LUNIndex,\r
+ const uint32_t BlockAddress, const uint8_t Blocks, const uint16_t BlockSize,\r
+ void* BlockBuffer) ATTR_NON_NULL_PTR_ARG(1) ATTR_NON_NULL_PTR_ARG(6);\r
+\r
+ /* Inline Functions: */\r
+ /** General management task for a given Mass Storage host class interface, required for the correct operation of\r
+ * the interface. This should be called frequently in the main program loop, before the master USB management task\r
+ * \ref USB_USBTask().\r
+ *\r
+ * \param[in,out] MSInterfaceInfo Pointer to a structure containing an MS Class host configuration and state\r
+ */\r
+ static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo);\r
+ static inline void MS_Host_USBTask(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo)\r
+ {\r
+ (void)MSInterfaceInfo;\r
+ }\r
+\r
+ /* Private Interface - For use in library only: */\r
+ #if !defined(__DOXYGEN__)\r
+ /* Macros: */\r
+ #define MASS_STORE_CLASS 0x08\r
+ #define MASS_STORE_SUBCLASS 0x06\r
+ #define MASS_STORE_PROTOCOL 0x50\r
+\r
+ #define REQ_MassStorageReset 0xFF\r
+ #define REQ_GetMaxLUN 0xFE\r
+\r
+ #define CBW_SIGNATURE 0x43425355UL\r
+ #define CSW_SIGNATURE 0x53425355UL\r
+ \r
+ #define COMMAND_DIRECTION_DATA_OUT (0 << 7)\r
+ #define COMMAND_DIRECTION_DATA_IN (1 << 7)\r
+ \r
+ #define COMMAND_DATA_TIMEOUT_MS 10000\r
+\r
+ #define MS_FOUND_DATAPIPE_IN (1 << 0)\r
+ #define MS_FOUND_DATAPIPE_OUT (1 << 1)\r
+ \r
+ /* Function Prototypes: */\r
+ #if defined(INCLUDE_FROM_MS_CLASS_HOST_C) \r
+ static uint8_t DComp_NextMSInterface(void* const CurrentDescriptor);\r
+ static uint8_t DComp_NextMSInterfaceEndpoint(void* const CurrentDescriptor);\r
+ \r
+ static uint8_t MS_Host_SendCommand(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock,\r
+ void* BufferPtr);\r
+ static uint8_t MS_Host_WaitForDataReceived(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo);\r
+ static uint8_t MS_Host_SendReceiveData(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo, \r
+ MS_CommandBlockWrapper_t* const SCSICommandBlock, void* BufferPtr);\r
+ static uint8_t MS_Host_GetReturnedStatus(USB_ClassInfo_MS_Host_t* const MSInterfaceInfo,\r
+ MS_CommandStatusWrapper_t* const SCSICommandStatus);\r
+ #endif\r
+ #endif\r
+ \r