1 #ifndef __USBH_MSC_CORE_H__ 2 #define __USBH_MSC_CORE_H__ 3 4 #include <stdint.h> 5 #include "usbh_core.h" 6 7 8 typedef enum { 9 USBH_MSC_GET_MAXLUN = 0, 10 USBH_MSC_TEST_UNIT_READY, 11 USBH_MSC_READ_CAPACITY10, 12 USBH_MSC_MODE_SENSE6, 13 USBH_MSC_REQUEST_SENSE, 14 USBH_MSC_BOT_TRANSFER, 15 USBH_MSC_DEFAULT_APP, 16 USBH_MSC_CLEAR_STALL, 17 USBH_MSC_UNRECOVERED_STATE 18 } USBH_MSC_State; 19 20 21 typedef struct { 22 uint8_t InEp; 23 uint8_t OutEp; 24 uint16_t InEpSize; 25 uint16_t OutEpSize; 26 uint8_t InEpDATAX; 27 uint8_t OutEpDATAX; 28 29 uint8_t Ready; 30 uint8_t MaxLUN; // Max Logic Unit Number 31 uint32_t Capacity; 32 uint16_t PageSize; 33 uint8_t WProtect; // Write Protect 34 uint32_t SenseKey; 35 } USBH_MSC_Info_t; 36 37 38 typedef struct { 39 uint8_t MSCState; 40 uint8_t MSCStateBkp; 41 uint8_t BOTState; 42 uint8_t BOTStateBkp; 43 uint8_t bCSWStatus; // CSW.bCSWStatus 44 uint8_t *pDataBuffer; 45 uint8_t UDiskReady; 46 } USBH_BOTXfer_t; 47 48 49 extern volatile USBH_MSC_Info_t USBH_MSC_Info; 50 extern volatile USBH_BOTXfer_t USBH_BOTXfer; 51 52 53 extern USBH_Class_cb_t USBH_MSC_cb; 54 55 56 USBH_Status USBH_MSC_Init(USBH_Info_t *phost); 57 void USBH_MSC_DeInit(USBH_Info_t *phost); 58 USBH_Status USBH_MSC_Request(USBH_Info_t *phost); 59 USBH_Status USBH_MSC_Process(USBH_Info_t *phost); 60 61 USBH_Status USBH_MSC_getMaxLUN(USBH_Info_t *phost); 62 void USBH_MSC_ErrorHandle(uint8_t status); 63 64 65 #endif // __USBH_MSC_CORE_H__ 66 67