discoverpixy
usbh_msc_bot.h
Go to the documentation of this file.
1 
22 /* Define to prevent recursive ----------------------------------------------*/
23 #ifndef __USBH_MSC_BOT_H__
24 #define __USBH_MSC_BOT_H__
25 
26 /* Includes ------------------------------------------------------------------*/
27 #include "usbh_stdreq.h"
28 
29 
52 typedef union _USBH_CBW_Block
53 {
54  struct __CBW
55  {
56  uint32_t CBWSignature;
57  uint32_t CBWTag;
58  uint32_t CBWTransferLength;
59  uint8_t CBWFlags;
60  uint8_t CBWLUN;
61  uint8_t CBWLength;
62  uint8_t CBWCB[16];
63 }field;
64  uint8_t CBWArray[31];
66 
67 typedef enum
68 {
69  USBH_MSC_BOT_INIT_STATE = 0,
70  USBH_MSC_BOT_RESET,
71  USBH_MSC_GET_MAX_LUN,
72  USBH_MSC_TEST_UNIT_READY,
73  USBH_MSC_READ_CAPACITY10,
74  USBH_MSC_MODE_SENSE6,
75  USBH_MSC_REQUEST_SENSE,
76  USBH_MSC_BOT_USB_TRANSFERS,
77  USBH_MSC_DEFAULT_APPLI_STATE,
78  USBH_MSC_CTRL_ERROR_STATE,
79  USBH_MSC_UNRECOVERED_STATE
80 }
81 MSCState;
82 
83 
84 typedef struct _BOTXfer
85 {
86 uint8_t MSCState;
87 uint8_t MSCStateBkp;
88 uint8_t MSCStateCurrent;
89 uint8_t CmdStateMachine;
90 uint8_t BOTState;
91 uint8_t BOTStateBkp;
92 uint8_t* pRxTxBuff;
93 uint16_t DataLength;
94 uint8_t BOTXferErrorCount;
95 uint8_t BOTXferStatus;
97 
98 
99 typedef union _USBH_CSW_Block
100 {
101  struct __CSW
102  {
103  uint32_t CSWSignature;
104  uint32_t CSWTag;
105  uint32_t CSWDataResidue;
106  uint8_t CSWStatus;
107  }field;
108  uint8_t CSWArray[13];
110 
120 #define USBH_MSC_SEND_CBW 1
121 #define USBH_MSC_SENT_CBW 2
122 #define USBH_MSC_BOT_DATAIN_STATE 3
123 #define USBH_MSC_BOT_DATAOUT_STATE 4
124 #define USBH_MSC_RECEIVE_CSW_STATE 5
125 #define USBH_MSC_DECODE_CSW 6
126 #define USBH_MSC_BOT_ERROR_IN 7
127 #define USBH_MSC_BOT_ERROR_OUT 8
128 
129 
130 #define USBH_MSC_BOT_CBW_SIGNATURE 0x43425355
131 #define USBH_MSC_BOT_CBW_TAG 0x20304050
132 #define USBH_MSC_BOT_CSW_SIGNATURE 0x53425355
133 #define USBH_MSC_CSW_DATA_LENGTH 0x000D
134 #define USBH_MSC_BOT_CBW_PACKET_LENGTH 31
135 #define USBH_MSC_CSW_LENGTH 13
136 #define USBH_MSC_CSW_MAX_LENGTH 63
137 
138 /* CSW Status Definitions */
139 #define USBH_MSC_CSW_CMD_PASSED 0x00
140 #define USBH_MSC_CSW_CMD_FAILED 0x01
141 #define USBH_MSC_CSW_PHASE_ERROR 0x02
142 
143 #define USBH_MSC_SEND_CSW_DISABLE 0
144 #define USBH_MSC_SEND_CSW_ENABLE 1
145 
146 #define USBH_MSC_DIR_IN 0
147 #define USBH_MSC_DIR_OUT 1
148 #define USBH_MSC_BOTH_DIR 2
149 
150 //#define USBH_MSC_PAGE_LENGTH 0x40
151 #define USBH_MSC_PAGE_LENGTH 512
152 
153 
154 #define CBW_CB_LENGTH 16
155 #define CBW_LENGTH 10
156 #define CBW_LENGTH_TEST_UNIT_READY 6
157 
158 #define USB_REQ_BOT_RESET 0xFF
159 #define USB_REQ_GET_MAX_LUN 0xFE
160 
161 #define MAX_BULK_STALL_COUNT_LIMIT 0x04 /* If STALL is seen on Bulk
162  Endpoint continously, this means
163  that device and Host has phase error
164  Hence a Reset is needed */
165 
180 extern USBH_BOTXfer_TypeDef USBH_MSC_BOTXferParam;
181 extern HostCBWPkt_TypeDef USBH_MSC_CBWData;
182 extern HostCSWPkt_TypeDef USBH_MSC_CSWData;
191  USBH_HOST *phost);
193  USBH_HOST *phost);
195 USBH_Status USBH_MSC_BOT_Abort(USB_OTG_CORE_HANDLE *pdev,
196  USBH_HOST *phost,
197  uint8_t direction);
202 #endif //__USBH_MSC_BOT_H__
203 
204 
220 /******************* (C) COPYRIGHT 2011 STMicroelectronics *****END OF FILE****/
221 
Definition: usbh_msc_bot.h:84
Header file for usbh_stdreq.c.
Definition: usbh_msc_bot.h:101
Definition: usbh_msc_bot.h:99
Definition: usbh_msc_bot.h:54
Definition: usb_core.h:287
uint8_t USBH_MSC_DecodeCSW(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
USBH_MSC_DecodeCSW This function decodes the CSW received by the device and updates the same to upper...
Definition: usbh_msc_bot.c:487
void USBH_MSC_Init(USB_OTG_CORE_HANDLE *pdev)
USBH_MSC_Init Initializes the mass storage parameters.
Definition: usbh_msc_bot.c:125
USBH_Status USBH_MSC_BOT_Abort(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost, uint8_t direction)
USBH_MSC_BOT_Abort This function manages the different Error handling for STALL.
Definition: usbh_msc_bot.c:432
void USBH_MSC_HandleBOTXfer(USB_OTG_CORE_HANDLE *pdev, USBH_HOST *phost)
USBH_MSC_HandleBOTXfer This function manages the different states of BOT transfer and updates the sta...
Definition: usbh_msc_bot.c:147
Definition: usbh_msc_bot.h:52
Definition: usbh_core.h:215