Prusa MINI Firmware overview
usbh_msc_bot.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file usbh_msc_bot.h
4  * @author MCD Application Team
5  * @version V3.2.2
6  * @date 07-July-2015
7  * @brief Header file for usbh_msc_bot.c
8  ******************************************************************************
9  * @attention
10  *
11  * <h2><center>&copy; COPYRIGHT 2015 STMicroelectronics</center></h2>
12  *
13  * Licensed under MCD-ST Liberty SW License Agreement V2, (the "License");
14  * You may not use this file except in compliance with the License.
15  * You may obtain a copy of the License at:
16  *
17  * http://www.st.com/software_license_agreement_liberty_v2
18  *
19  * Unless required by applicable law or agreed to in writing, software
20  * distributed under the License is distributed on an "AS IS" BASIS,
21  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
22  * See the License for the specific language governing permissions and
23  * limitations under the License.
24  *
25  ******************************************************************************
26  */
27 
28 /* Define to prevent recursive ----------------------------------------------*/
29 #ifndef __USBH_MSC_BOT_H
30 #define __USBH_MSC_BOT_H
31 
32 #ifdef __cplusplus
33  extern "C" {
34 #endif
35 
36 /* Includes ------------------------------------------------------------------*/
37 #include "usbh_core.h"
38 #include "usbh_msc_bot.h"
39 
40 /** @addtogroup USBH_LIB
41  * @{
42  */
43 
44 /** @addtogroup USBH_CLASS
45  * @{
46  */
47 
48 /** @addtogroup USBH_MSC_CLASS
49  * @{
50  */
51 
52 /** @defgroup USBH_MSC_BOT
53  * @brief This file is the Header file for usbh_msc_bot.c
54  * @{
55  */
56 
57 
58 /** @defgroup USBH_MSC_BOT_Exported_Types
59  * @{
60  */
61 
62 typedef enum {
63  BOT_OK = 0,
64  BOT_FAIL = 1,
67 }
69 
70 typedef enum {
74 }
76 
77 /* CSW Status Definitions */
78 typedef enum
79 {
80 
84 }
86 
87 typedef enum {
99 }
101 
102 typedef union
103 {
104  struct __CBW
105  {
106  uint32_t Signature;
107  uint32_t Tag;
112  uint8_t CB[16];
113  }field;
115 }
117 
118 typedef union
119 {
120  struct __CSW
121  {
122  uint32_t Signature;
123  uint32_t Tag;
124  uint32_t DataResidue;
126  }field;
128 }
130 
131 typedef struct
132 {
133  uint32_t data[16];
140  uint8_t Reserved2[3];
142 }
144 
145 /**
146  * @}
147  */
148 
149 
150 
151 /** @defgroup USBH_MSC_BOT_Exported_Defines
152  * @{
153  */
154 #define BOT_CBW_SIGNATURE 0x43425355
155 #define BOT_CBW_TAG 0x20304050
156 #define BOT_CSW_SIGNATURE 0x53425355
157 #define BOT_CBW_LENGTH 31
158 #define BOT_CSW_LENGTH 13
159 
160 
161 
162 #define BOT_SEND_CSW_DISABLE 0
163 #define BOT_SEND_CSW_ENABLE 1
164 
165 #define BOT_DIR_IN 0
166 #define BOT_DIR_OUT 1
167 #define BOT_DIR_BOTH 2
168 
169 #define BOT_PAGE_LENGTH 512
170 
171 
172 #define BOT_CBW_CB_LENGTH 16
173 
174 
175 #define USB_REQ_BOT_RESET 0xFF
176 #define USB_REQ_GET_MAX_LUN 0xFE
177 
178 #define MAX_BULK_STALL_COUNT_LIMIT 0x04 /* If STALL is seen on Bulk
179  Endpoint continuously, this means
180  that device and Host has phase error
181  Hence a Reset is needed */
182 
183 /**
184  * @}
185  */
186 
187 /** @defgroup USBH_MSC_BOT_Exported_Macros
188  * @{
189  */
190 /**
191  * @}
192  */
193 
194 /** @defgroup USBH_MSC_BOT_Exported_Variables
195  * @{
196  */
197 
198 /**
199  * @}
200  */
201 
202 /** @defgroup USBH_MSC_BOT_Exported_FunctionsPrototype
203  * @{
204  */
207 
211 
212 
213 
214 /**
215  * @}
216  */
217 
218 #ifdef __cplusplus
219 }
220 #endif
221 
222 #endif /* __USBH_MSC_BOT_H__ */
223 
224 
225 /**
226  * @}
227  */
228 
229 /**
230  * @}
231  */
232 
233 /**
234  * @}
235  */
236 
237 /**
238  * @}
239  */
240 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
BOT_StateTypeDef
BOT_StateTypeDef
Definition: usbh_msc_bot.h:87
BOT_CSWTypeDef::__CSW::DataResidue
uint32_t DataResidue
Definition: usbh_msc_bot.h:124
BOT_CBWTypeDef::__CBW::LUN
uint8_t LUN
Definition: usbh_msc_bot.h:110
BOT_OK
Definition: usbh_msc_bot.h:63
BOT_StatusTypeDef
BOT_StatusTypeDef
Definition: usbh_msc_bot.h:62
BOT_CBWTypeDef::__CBW::CBLength
uint8_t CBLength
Definition: usbh_msc_bot.h:111
usbh_core.h
Header file for usbh_core.c.
BOT_HandleTypeDef::Reserved1
uint8_t Reserved1
Definition: usbh_msc_bot.h:138
USBH_MSC_BOT_Init
USBH_StatusTypeDef USBH_MSC_BOT_Init(USBH_HandleTypeDef *phost)
USBH_MSC_BOT_Init The function Initializes the BOT protocol.
Definition: usbh_msc_bot.c:151
USBH_MSC_BOT_Process
USBH_StatusTypeDef USBH_MSC_BOT_Process(USBH_HandleTypeDef *phost, uint8_t lun)
USBH_MSC_BOT_Process The function handle the BOT protocol.
Definition: usbh_msc_bot.c:173
BOT_ERROR_IN
Definition: usbh_msc_bot.h:96
BOT_CBWTypeDef::__CBW::Tag
uint32_t Tag
Definition: usbh_msc_bot.h:107
BOT_DATA_IN_WAIT
Definition: usbh_msc_bot.h:91
BOT_RECEIVE_CSW_WAIT
Definition: usbh_msc_bot.h:95
data
uint8_t data[8]
Definition: masstorage.h:49
BOT_HandleTypeDef::cbw
BOT_CBWTypeDef cbw
Definition: usbh_msc_bot.h:137
BOT_CBWTypeDef
Definition: usbh_msc_bot.h:102
BOT_CSWTypeDef::__CSW
Definition: usbh_msc_bot.h:120
BOT_HandleTypeDef::cmd_state
BOT_CMDStateTypeDef cmd_state
Definition: usbh_msc_bot.h:136
USBH_MSC_BOT_Error
USBH_StatusTypeDef USBH_MSC_BOT_Error(USBH_HandleTypeDef *phost, uint8_t lun)
BOT_CBWTypeDef::__CBW
Definition: usbh_msc_bot.h:104
_USBH_HandleTypeDef
Definition: usbh_def.h:450
BOT_CSWTypeDef
Definition: usbh_msc_bot.h:118
BOT_RECEIVE_CSW
Definition: usbh_msc_bot.h:94
BOT_CSWTypeDef::__CSW::Signature
uint32_t Signature
Definition: usbh_msc_bot.h:122
BOT_FAIL
Definition: usbh_msc_bot.h:64
BOT_DATA_OUT
Definition: usbh_msc_bot.h:92
BOT_HandleTypeDef::prev_state
BOT_StateTypeDef prev_state
Definition: usbh_msc_bot.h:135
BOT_CSW_CMD_PASSED
Definition: usbh_msc_bot.h:81
BOT_CSW_PHASE_ERROR
Definition: usbh_msc_bot.h:83
BOT_CMD_SEND
Definition: usbh_msc_bot.h:72
BOT_CSWTypeDef::__CSW::Status
uint8_t Status
Definition: usbh_msc_bot.h:125
BOT_CBWTypeDef::__CBW::Flags
uint8_t Flags
Definition: usbh_msc_bot.h:109
BOT_CBWTypeDef::__CBW::Signature
uint32_t Signature
Definition: usbh_msc_bot.h:106
USBH_MSC_BOT_REQ_Reset
USBH_StatusTypeDef USBH_MSC_BOT_REQ_Reset(USBH_HandleTypeDef *phost)
USBH_MSC_BOT_REQ_Reset The function the MSC BOT Reset request.
Definition: usbh_msc_bot.c:109
BOT_HandleTypeDef::csw
BOT_CSWTypeDef csw
Definition: usbh_msc_bot.h:139
BOT_CMD_IDLE
Definition: usbh_msc_bot.h:71
BOT_CSWStatusTypeDef
BOT_CSWStatusTypeDef
Definition: usbh_msc_bot.h:78
uint8_t
const uint8_t[]
Definition: 404_html.c:3
BOT_ERROR_OUT
Definition: usbh_msc_bot.h:97
USBH_StatusTypeDef
USBH_StatusTypeDef
Definition: usbh_def.h:302
BOT_DATA_IN
Definition: usbh_msc_bot.h:90
usbh_msc_bot.h
Header file for usbh_msc_bot.c.
BOT_HandleTypeDef::state
BOT_StateTypeDef state
Definition: usbh_msc_bot.h:134
BOT_HandleTypeDef::pbuf
uint8_t * pbuf
Definition: usbh_msc_bot.h:141
BOT_HandleTypeDef
Definition: usbh_msc_bot.h:131
BOT_BUSY
Definition: usbh_msc_bot.h:66
BOT_UNRECOVERED_ERROR
Definition: usbh_msc_bot.h:98
USBH_MSC_BOT_REQ_GetMaxLUN
USBH_StatusTypeDef USBH_MSC_BOT_REQ_GetMaxLUN(USBH_HandleTypeDef *phost, uint8_t *Maxlun)
USBH_MSC_BOT_REQ_GetMaxLUN The function the MSC BOT GetMaxLUN request.
Definition: usbh_msc_bot.c:130
BOT_CMDStateTypeDef
BOT_CMDStateTypeDef
Definition: usbh_msc_bot.h:70
BOT_CSW_CMD_FAILED
Definition: usbh_msc_bot.h:82
BOT_SEND_CBW_WAIT
Definition: usbh_msc_bot.h:89
BOT_CBWTypeDef::__CBW::DataTransferLength
uint32_t DataTransferLength
Definition: usbh_msc_bot.h:108
BOT_SEND_CBW
Definition: usbh_msc_bot.h:88
BOT_CSWTypeDef::__CSW::Tag
uint32_t Tag
Definition: usbh_msc_bot.h:123
BOT_PHASE_ERROR
Definition: usbh_msc_bot.h:65
BOT_CMD_WAIT
Definition: usbh_msc_bot.h:73
BOT_DATA_OUT_WAIT
Definition: usbh_msc_bot.h:93