gr55xx_hal_usb.h
Go to the documentation of this file.
1 /**
2  ****************************************************************************************
3  *
4  * @file gr55xx_hal_usb.h
5  * @author BLE Driver Team
6  * @brief Header file containing functions prototypes of USB HAL library.
7  *
8  ****************************************************************************************
9  * @attention
10  #####Copyright (c) 2019 GOODIX
11  All rights reserved.
12 
13  Redistribution and use in source and binary forms, with or without
14  modification, are permitted provided that the following conditions are met:
15  * Redistributions of source code must retain the above copyright
16  notice, this list of conditions and the following disclaimer.
17  * Redistributions in binary form must reproduce the above copyright
18  notice, this list of conditions and the following disclaimer in the
19  documentation and/or other materials provided with the distribution.
20  * Neither the name of GOODIX nor the names of its contributors may be used
21  to endorse or promote products derived from this software without
22  specific prior written permission.
23 
24  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25  AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26  IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
27  ARE DISCLAIMED. IN NO EVENT SHALL COPYRIGHT HOLDERS AND CONTRIBUTORS BE
28  LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
29  CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
30  SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
31  INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
32  CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
33  ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
34  POSSIBILITY OF SUCH DAMAGE.
35  ****************************************************************************************
36  */
37 
38 /** @addtogroup PERIPHERAL Peripheral Driver
39  * @{
40  */
41 
42 /** @addtogroup HAL_DRIVER HAL Driver
43  * @{
44  */
45 
46 /** @defgroup HAL_USB USB
47  * @brief USB HAL module driver.
48  * @{
49  */
50 
51 /* Define to prevent recursive inclusion -------------------------------------*/
52 #ifndef __GR55xx_HAL_USB_H__
53 #define __GR55xx_HAL_USB_H__
54 
55 #ifdef __cplusplus
56 extern "C" {
57 #endif
58 
59 /* Includes ------------------------------------------------------------------*/
60 #include "gr55xx_ll_usb.h"
61 #include "gr55xx_hal_def.h"
62 
63 /* Exported types ------------------------------------------------------------*/
64 /** @addtogroup HAL_USB_ENUMERATIONS Enumerations
65  * @{
66  */
67 
68 /**
69  * @brief HAL USB State Enumerations definition
70  */
71 typedef enum
72 {
73  HAL_USB_STATE_RESET = 0x00, /**< Peripheral not initialized */
74  HAL_USB_STATE_READY = 0x01, /**< Peripheral initialized and ready for use */
75  HAL_USB_STATE_BUSY = 0x02, /**< An internal process is ongoing */
76  HAL_USB_STATE_BUSY_HOST_REST = 0x12, /**< USB in host rest state during enumeration */
77  HAL_USB_STATE_BUSY_ADDR = 0x22, /**< USB in adress state during enumeration */
78  HAL_USB_STATE_BUSY_CFG = 0x32, /**< USB in configure state during enumeration */
79  HAL_USB_STATE_ERROR = 0x04, /**< Peripheral in error */
80  HAL_USB_STATE_ERROR_CRC16 = 0x14, /**< USB receive CRC error data */
81  HAL_USB_STATE_ERROR_UPID = 0x24, /**< USB receive unsupported PID error */
82  HAL_USB_STATE_ERROR_TIMEOUT = 0x34, /**< USB rx/tx timeout error */
83  HAL_USB_STATE_ERROR_SEQ = 0x44, /**< USB DATA0/DATA1 PID sequence error */
84  HAL_USB_STATE_ERROR_PID_CKS = 0x54, /**< USB PID checksum error */
85  HAL_USB_STATE_ERROR_PID_CRC = 0x64, /**< USB PID CRC error */
86  HAL_USB_STATE_ERROR_DMA_RX = 0x74, /**< USB ep3 or ep4 AHB master receive ERROR response */
87  HAL_USB_STATE_ERROR_NSE = 0x84, /**< USB no such endpoint error */
88  HAL_USB_STATE_ERROR_SYNC = 0x94, /**< USB SYNC error */
89  HAL_USB_STATE_ERROR_BIT_STUFF = 0xA4, /**< USB bit stuff error */
90  HAL_USB_STATE_ERROR_BYTE = 0xB4, /**< USB byte error */
91  HAL_USB_STATE_ERROR_EP5_TIMER = 0xC4, /**< USB ep5 timer out error */
92  HAL_USB_STATE_ABORT = 0x08, /**< Peripheral with abort request ongoing */
93  HAL_USB_STATE_SUSPEND = 0x10 /**< USB transceiver suspend */
95 
96 /**
97  * @brief HAL USB EP
98  */
99 typedef enum
100 {
101  HAL_USB_EP0 = 0x00, /**< USB EP0. */
102  HAL_USB_EP1 = 0x01, /**< USB EP1. */
103  HAL_USB_EP2 = 0x02, /**< USB EP2. */
104  HAL_USB_EP3 = 0x03, /**< USB EP3. */
105  HAL_USB_EP4 = 0x04, /**< USB EP4. */
106  HAL_USB_EP5 = 0x05 /**< USB EP4. */
108 
109 /** @} */
110 
111 /** @addtogroup HAL_USB_STRUCTURES Structures
112  * @{
113  */
114 
115 /** @defgroup USB_Configuration USB Configuration
116  * @{
117  */
118 
119 /**
120  * @brief USB hardware enumeration Structure definition
121  */
122 typedef struct hw_enum_parm
123 {
124  uint8_t cfg_desc_start; /**< Specifies the USB config descriptor start address
125  This parameter can be a value of 8 bit data of offset of config descriptor.(offset refer to sram_addr(device descriptor))*/
126 
127  uint8_t cfg_desc_size; /**< Specifies the USB config descriptor size
128  This parameter can be a value of 8 bit data size of config descriptor.*/
129 
130  uint8_t str_desc0_start; /**< Specifies the USB Language ID descriptor start address
131  This parameter can be a value of 8 bit data of offset of Language ID descriptor.(offset refer to cfg_desc_start(device descriptor))*/
132 
133  uint8_t str_desc0_size; /**< Specifies the USB Language ID descriptor size
134  This parameter can be a value of 8 bit data size of Language ID descriptor.*/
135 
136  uint8_t str_desc1_start; /**< Specifies the USB string descriptor(Manufacturer string) start address
137  This parameter can be a value of 8 bit data of offset of string descriptor.(offset refer to str_desc0_start(device descriptor)*/
138 
139  uint8_t str_desc1_size; /**< Specifies the USB string descriptor(Manufacturer string) size
140  This parameter can be a value of 8 bit data size of string descriptor.*/
141 
142  uint8_t str_desc2_start; /**< Specifies the USB string descriptor(Product string) start address
143  This parameter can be a value of 8 bit data of offset of string descriptor.(device descriptor)*/
144 
145  uint8_t str_desc2_size; /**< Specifies the USB string descriptor(Product string) size
146  This parameter can be a value of 8 bit data size of string descriptor.*/
147 
148  uint8_t str_desc3_start; /**< Specifies the USB string descriptor(Serial Number string) start address
149  This parameter can be a value of 8 bit data of offset of string descriptor.(device descriptor)*/
150 
151  uint8_t str_desc3_size; /**< Specifies the USB string descriptor(Serial Number string) size
152  This parameter can be a value of 8 bit data size of string descriptor.*/
153 
154  uint16_t sram_size; /**< Specifies the USB hardware enumeration SRAM address size
155  This parameter can be a value of 0~256byte descriptor size.(the whole size of hardware enumeration is 256byte)*/
156 
157  uint32_t *p_sram_addr; /**< Specifies the USB hardware enumeration SRAM address
158  This parameter can be a value of 32 bit descriptor SRAM address.(the whole size of hardware enumeration is 256byte)*/
159 
161 
162 /**
163  * @brief USB init Structure definition
164  */
165 typedef struct _usb_init
166 {
167  uint32_t speed; /**< Specifies the USB Transceiver speed.
168  This parameter can be a value of @ref USB_Speed_Mode. */
169 
170  uint32_t enum_type; /**< Specifies the USB enumeration type( hardware enumeration and MCU enumeration).
171  This parameter can be a value of @ref USB_Enum_Type. */
172 
173  hw_enum_parm_t hw_enum; /**< Specifies the USB hardware enumeration parameter(MCU enumeration:NULL;hardware enumeration: valid).
174  This parameter can be a value of @ref hw_enum_parm_t. */
176 /** @} */
177 
178 /** @defgroup USB_handle USB handle
179  * @{
180  */
181 
182 /**
183  * @brief USB handle Structure definition
184  */
185 typedef struct _usb_handle
186 {
187  usb_regs_t *p_instance; /**< USB registers base address */
188 
189  usb_init_t init; /**< USB communication parameters */
190 
191  __IO hal_lock_t lock; /**< Locking object */
192 
193  __IO hal_usb_state_t state; /**< USB communication state */
194 
195  __IO uint32_t error_code; /**< USB Error code */
196 
197  uint32_t timeout; /**< Timeout for the USB memory access */
198 
199  uint32_t retention[12]; /**< USB important register information. */
201 /** @} */
202 
203 /** @} */
204 
205 /** @addtogroup HAL_USB_CALLBACK_STRUCTURES Callback Structures
206  * @{
207  */
208 
209 /** @defgroup HAL_USB_Callback Callback
210  * @{
211  */
212 
213 /**
214  * @brief HAL_USB Callback function definition
215  */
216 
217 typedef struct _usb_callback
218 {
219  void (*usb_msp_init)(usb_handle_t *p_usb); /**< USB init MSP callback */
220  void (*usb_msp_deinit)(usb_handle_t *p_usb); /**< USB de-init MSP callback */
221  void (*usb_suspend_callback)(usb_handle_t *p_usb); /**< USB suspend status interrupt callback */
222  void (*usb_ep0_out_ready_callback)(usb_handle_t *p_usb); /**< USB ep0 data out ready callback */
223  void (*usb_ep1_out_ready_callback)(usb_handle_t *p_usb); /**< USB ep1 data out ready callback */
224  void (*usb_crc16_err_callback)(usb_handle_t *p_usb); /**< USB receive CRC error data callback */
225  void (*usb_upid_err_callback)(usb_handle_t *p_usb); /**< USB receive unsupported PID callbac */
226  void (*usb_time_out_callback)(usb_handle_t *p_usb); /**< USB rx/tx timeout error callback */
227  void (*usb_seq_err_callback)(usb_handle_t *p_usb); /**< USB DATA0/DATA1 PID sequence error callback */
228  void (*usb_pid_cks_err_callback)(usb_handle_t *p_usb); /**< USB PID checksum error callback */
229  void (*usb_pid_crc_err_callback)(usb_handle_t *p_usb); /**< USB PID CRC error callback */
230  void (*usb_host_reset_callback)(usb_handle_t *p_usb); /**< USB host reset callback */
231  void (*usb_ahb_xfer_err_callback)(usb_handle_t *p_usb); /**< USB ep3 and ep4 AHB master receive error response callback */
232  void (*usb_nse_err_callback)(usb_handle_t *p_usb); /**< USB no such endpoint error callback */
233  void (*usb_ep3_ahb_xfer_done_callback)(usb_handle_t *p_usb); /**< USB ep3 AHB master transfer done callback */
234  void (*usb_sync_err_callback)(usb_handle_t *p_usb); /**< USB SYNC error callback */
235  void (*usb_bit_stuff_err_callback)(usb_handle_t *p_usb); /**< USB bit stuff error callback */
236  void (*usb_byte_err_callback)(usb_handle_t *p_usb); /**< USB byte error callback */
237  void (*usb_sof_callback)(usb_handle_t *p_usb); /**< USB SOF callback */
238  void (*usb_ep0_tx_done_callback)(usb_handle_t *p_usb); /**< USB ep0 TX done callback */
239  void (*usb_ep2_tx_done_callback)(usb_handle_t *p_usb); /**< USB ep2 TX done callback */
240  void (*usb_ep3_tx_done_callback)(usb_handle_t *p_usb); /**< USB ep3 TX done callback */
241  void (*usb_into_config_callback)(usb_handle_t *p_usb); /**< USB into configcallback */
242  void (*usb_ep4_ahb_xfer_done_callback)(usb_handle_t *p_usb); /**< USB ep4 AHB master transfer done callback */
243  void (*usb_ep4_tx_done_callback)(usb_handle_t *p_usb); /**< USB ep4 TX done callback */
244  void (*usb_ep5_out_ready_callback)(usb_handle_t *p_usb); /**< USB ep5 RX done callback */
245  void (*usb_ep5_ahb_xfer_done_callback)(usb_handle_t *p_usb); /**< USB ep5 AHB master transfer done callback */
246  void (*usb_ep5_timer_out_err_callback)(usb_handle_t *p_usb); /**< USB ep5 timer out error callback */
247  void (*usb_attach_callback)(usb_handle_t *p_usb); /**< USB attatch callback */
248  void (*usb_detach_callback)(usb_handle_t *p_usb); /**< USB detatch callback */
250 /** @} */
251 
252 /** @} */
253 
254 /**
255  * @defgroup HAL_USB_MACRO Defines
256  * @{
257  */
258 
259 /* Exported constants --------------------------------------------------------*/
260 /** @defgroup USB_Exported_Constants USB Exported Constants
261  * @{
262  */
263 
264 
265 /** @defgroup USB_Error_Code USB Error Code
266  * @{
267  */
268 #define HAL_USB_ERROR_NONE ((uint32_t)0x00000000) /**< No error */
269 #define HAL_USB_ERROR_TIMEOUT ((uint32_t)0x00000001) /**< Timeout error */
270 #define HAL_USB_ERROR_TRANSFER ((uint32_t)0x00000002) /**< Transfer error */
271 #define HAL_USB_ERROR_DMA ((uint32_t)0x00000004) /**< DMA transfer error */
272 #define HAL_USB_ERROR_INVALID_PARAM ((uint32_t)0x00000008) /**< Invalid parameters error */
273 /** @} */
274 
275 /** @defgroup USB_EP_FIFO_Address USB EF FIFO address
276  * @{
277  */
278 #define HAL_USB_FIFO_EP0 (USB_BASE + 0x40) /**< USB EP0 FIFO address. */
279 #define HAL_USB_FIFO_EP1 (USB_BASE + 0x44) /**< USB EP1 FIFO address. */
280 #define HAL_USB_FIFO_EP2 (USB_BASE + 0x48) /**< USB EP2 FIFO address. */
281 #define HAL_USB_FIFO_EP3 (USB_BASE + 0x4C) /**< USB EP3 FIFO address. */
282 /** @} */
283 
284 /** @defgroup USB_Pwr_Mode USB Power Mode
285  * @{
286  */
287 #define USB_PWR_MODE_LP LL_USB_PWR_MODE_LP /**< usb working in low power mode. */
288 #define USB_PWR_MODE_NORMAL LL_USB_PWR_MODE_NORMAL /**< usb working in normal mode. */
289 /** @} */
290 
291 /** @defgroup USB_Speed_Mode USB speed Mode
292  * @{
293  */
294 #define USB_HAL_SPEED_LOW LL_USB_XCRV_CTRL_SPEED_LOW /**< USB Transceiver speed select: low speed */
295 #define USB_HAL_SPEED_FULL LL_USB_XCRV_CTRL_SPEED_FULL /**< USB Transceiver speed select: full speed */
296 /** @} */
297 
298 
299 /** @defgroup USB_Enum_Type USB enumeration type
300  * @{
301  */
302 #define USB_ENUM_TYPE_HW LL_USB_ENUM_TYPE_HW /**< USB hardware enumeration type */
303 #define USB_ENUM_TYPE_MCU LL_USB_ENUM_TYPE_MCU /**< USB MCU enumeration type */
304 /** @} */
305 
306 /** @defgroup USB_EP_ATTR USB Endpoint attribute setting
307  * @{
308  */
309 #define USB_EP_ATTR_INT ((uint32_t)0x00000000UL) /**< Endpoint attribute setting: interrupt */
310 #define USB_EP_ATTR_ISO ((uint32_t)0x00000001UL) /**< Endpoint attribute setting: Isochronous */
311 #define USB_EP_ATTR_BULK ((uint32_t)0x00000002UL) /**< Endpoint attribute setting: bulk */
312 /** @} */
313 
314 /** @defgroup USB_EP4_FIFO_WEN USB ep4 write fifo effective byte
315  * @{
316  */
317 #define USB_EP4_FIFO_WEN_DEFAULT LL_USB_EP4_FIFO_WEN_DEFAULT /**< USB ep4 write fifo enable default value */
318 #define USB_EP4_FIFO_WEN_1BYTE LL_USB_EP4_FIFO_WEN_1BYTE /**< USB ep4 write fifo 1 byte effective */
319 #define USB_EP4_FIFO_WEN_2BYTE LL_USB_EP4_FIFO_WEN_2BYTE /**< USB ep4 write fifo 2 byte effective */
320 #define USB_EP4_FIFO_WEN_3BYTE LL_USB_EP4_FIFO_WEN_3BYTE /**< USB ep4 write fifo 3 byte effective */
321 #define USB_EP4_FIFO_WEN_4BYTE LL_USB_EP4_FIFO_WEN_4BYTE /**< USB ep4 write fifo 4 byte effective */
322 /** @} */
323 
324 /** @defgroup USB_Timeout_definition USB Timeout_definition
325  * @{
326  */
327 #define HAL_USB_TIMEOUT_DEFAULT_VALUE ((uint32_t)5000) /**< 5s */
328 /** @} */
329 
330 /** @defgroup USB_Flags_definition USB Flags Definition
331  * @{
332  */
333 #define USB_FLAG_SUSPEND LL_USB_INT_STAT_SUSPEND /**< USB suspend status flag */
334 #define USB_FLAG_EP0_OUT_READY LL_USB_INT_STAT_EP0_OUT_READY /**< USB ep0 data out ready flag */
335 #define USB_FLAG_EP1_OUT_READY LL_USB_INT_STAT_EP1_OUT_READY /**< USB ep1 data out ready flag */
336 #define USB_FLAG_CRC16_ERR LL_USB_INT_STAT_CRC16_ERR /**< USB receive CRC error data flag */
337 #define USB_FLAG_UPID_ERR LL_USB_INT_STAT_UPID_ERR /**< USB receive unsupported PID flag */
338 #define USB_FLAG_TIMEOUT_ERR LL_USB_INT_STAT_TIMEOUT_ERR /**< USB rx/tx timeout error flag */
339 #define USB_FLAG_SEQ_ERR LL_USB_INT_STAT_SEQ_ERR /**< USB DATA0/DATA1 PID sequence error flag */
340 #define USB_FLAG_PID_CKS_ERR LL_USB_INT_STAT_PID_CKS_ERR /**< USB PID checksum error flag */
341 #define USB_FLAG_PID_CRC_ERR LL_USB_INT_STAT_PID_CRC_ERR /**< USB PID CRC error flag */
342 #define USB_FLAG_HOST_RESET LL_USB_INT_STAT_HOST_RESET /**< USB host reset flag */
343 #define USB_FLAG_AHB_XFER_ERR LL_USB_INT_STAT_AHB_XFER_ERR /**< USB ep3 and ep4 AHB master receive error flag */
344 #define USB_FLAG_NSE_ERR LL_USB_INT_STAT_NSE_ERR /**< USB no such endpoint error flag */
345 #define USB_FLAG_EP3_AHB_XFER_DONE LL_USB_INT_STAT_EP3_AHB_XFER_DONE /**< USB ep3 AHB master transfer done flag */
346 #define USB_FLAG_SYNC_ERR LL_USB_INT_STAT_SYNC_ERR /**< USB SYNC error flag */
347 #define USB_FLAG_BIT_STUFF_ERR LL_USB_INT_STAT_BIT_STUFF_ERR /**< USB bit stuff error flag */
348 #define USB_FLAG_BYTE_ERR LL_USB_INT_STAT_BYTE_ERR /**< USB byte error flag */
349 #define USB_FLAG_SOF LL_USB_INT_STAT_SOF /**< USB SOF flag */
350 #define USB_FLAG_EP0_TX_DONE LL_USB_INT_STAT_EP0_TX_DONE /**< USB ep0 TX done flag */
351 #define USB_FLAG_EP2_TX_DONE LL_USB_INT_STAT_EP2_TX_DONE /**< USB ep2 TX done flag */
352 #define USB_FLAG_EP3_TX_DONE LL_USB_INT_STAT_EP3_TX_DONE /**< USB ep3 TX done flag */
353 #define USB_FLAG_INTO_CONFIG LL_USB_INT_STAT_INTO_CONFIG /**< USB into cofig status flag */
354 #define USB_FLAG_EP5_OUT_READY LL_USB_INT_STAT_EP5_OUT_READY /**< USB ep5 data out ready flag */
355 #define USB_FLAG_EP4_AHB_XFER_DONE LL_USB_INT_STAT_EP4_AHB_XFER_DONE /**< USB ep4 AHB master transfer done flag */
356 #define USB_FLAG_EP4_TX_DONE LL_USB_INT_STAT_EP4_TX_DONE /**< USB ep4 TX done flag */
357 #define USB_FLAG_EP5_AHB_XFER_DONE LL_USB_INT_STAT_EP5_AHB_XFER_DONE /**< USB ep5 AHB master transfer done flag */
358 #define USB_FLAG_EP5_TIMER_OUT_ERR LL_USB_INT_STAT_EP5_TIMER_OUT_ERR /**< USB ep5 timer out error flag */
359 /** @} */
360 
361 /** @defgroup USB_Interrupt_definition USB Interrupt Definition
362  * @{
363  */
364 #define USB_IT_ALL LL_USB_INT_EN_ALL /**< USB all interrupt */
365 #define USB_IT_RESET_VAL LL_USB_INT_RESET_VAL /**< USB interrupt control reset value */
366 #define USB_IT_SUSPEND LL_USB_INT_EN_SUSPEND /**< USB suspend status interrupt */
367 #define USB_IT_EP0_OUT_READY LL_USB_INT_EN_EP0_OUT_READY /**< USB ep0 data out ready interrupt */
368 #define USB_IT_EP1_OUT_READY LL_USB_INT_EN_EP1_OUT_READY /**< USB ep1 data out ready interrupt */
369 #define USB_IT_CRC16_ERR LL_USB_INT_EN_CRC16_ERR /**< USB receive CRC error data interrupt */
370 #define USB_IT_UPID_ERR LL_USB_INT_EN_UPID_ERR /**< USB receive unsupported PID interrupt */
371 #define USB_IT_TIMEOUT_ERR LL_USB_INT_EN_TIMEOUT_ERR /**< USB rx/tx timeout error interrupt */
372 #define USB_IT_SEQ_ERR LL_USB_INT_EN_SEQ_ERR /**< USB DATA0/DATA1 PID sequence error interrupt */
373 #define USB_IT_PID_CKS_ERR LL_USB_INT_EN_PID_CKS_ERR /**< USB PID checksum error interrupt */
374 #define USB_IT_PID_CRC_ERR LL_USB_INT_EN_PID_CRC_ERR /**< USB PID CRC error interrupt */
375 #define USB_IT_HOST_RESET LL_USB_INT_EN_HOST_RESET /**< USB host reset interrupt */
376 #define USB_IT_AHB_XFER_ERR LL_USB_INT_EN_AHB_XFER_ERR /**< USB ep3 and ep4 AHB master receive error interrupt */
377 #define USB_IT_NSE_ERR LL_USB_INT_EN_NSE_ERR /**< USB no such endpoint error interrupt */
378 #define USB_IT_EP3_AHB_XFER_DONE LL_USB_INT_EN_EP3_AHB_XFER_DONE /**< USB ep3 AHB master transfer done interrupt */
379 #define USB_IT_SYNC_ERR LL_USB_INT_EN_SYNC_ERR /**< USB SYNC error interrupt */
380 #define USB_IT_BIT_STUFF_ERR LL_USB_INT_EN_BIT_STUFF_ERR /**< USB bit stuff error interrupt */
381 #define USB_IT_BYTE_ERR LL_USB_INT_EN_BYTE_ERR /**< USB byte error interrupt */
382 #define USB_IT_SOF LL_USB_INT_EN_SOF /**< USB SOF interrupt */
383 #define USB_IT_EP0_TX_DONE LL_USB_INT_EN_EP0_TX_DONE /**< USB ep0 TX done interrupt */
384 #define USB_IT_EP2_TX_DONE LL_USB_INT_EN_EP2_TX_DONE /**< USB ep2 TX done interrupt */
385 #define USB_IT_EP3_TX_DONE LL_USB_INT_EN_EP3_TX_DONE /**< USB ep3 TX done interrupt */
386 #define USB_IT_INTO_CONFIG LL_USB_INT_EN_INTO_CONFIG /**< USB into cofig status interrupt */
387 #define USB_IT_EP5_OUT_READY LL_USB_INT_EN_EP5_OUT_READY /**< USB ep5 data out ready interrupt */
388 #define USB_IT_EP4_AHB_XFER_DONE LL_USB_INT_EN_EP4_AHB_XFER_DONE /**< USB ep4 AHB master transfer done interrupt */
389 #define USB_IT_EP4_TX_DONE LL_USB_INT_EN_EP4_TX_DONE /**< USB ep4 TX done interrupt */
390 #define USB_IT_EP5_AHB_XFER_DONE LL_USB_INT_EN_EP5_AHB_XFER_DONE /**< USB ep5 AHB master transfer done interrupt */
391 #define USB_IT_EP5_TIMER_OUT_ERR LL_USB_INT_EN_EP5_TIMER_OUT_ERR /**< USB ep5 timer out error interrupt */
392 /** @} */
393 
394 /** @defgroup USB_IT_CLR USB interrupt clear
395  * @{
396  */
397 #define USB_IT_CLR_ALL LL_USB_INT_CLR_ALL /**< USB all interrupt clear */
398 #define USB_IT_CLR_SUSPEND LL_USB_INT_CLR_SUSPEND /**< USB suspend status interrupt clear */
399 #define USB_IT_CLR_EP0_OUT_READY LL_USB_INT_CLR_EP0_OUT_READY /**< USB ep0 data out ready interrupt clear */
400 #define USB_IT_CLR_EP1_OUT_READY LL_USB_INT_CLR_EP1_OUT_READY /**< USB ep1 data out ready interrupt clear */
401 #define USB_IT_CLR_CRC16_ERR LL_USB_INT_CLR_CRC16_ERR /**< USB receive CRC error data interrupt clear */
402 #define USB_IT_CLR_UPID_ERR LL_USB_INT_CLR_UPID_ERR /**< USB receive unsupported PID interrupt clear */
403 #define USB_IT_CLR_TIMEOUT_ERR LL_USB_INT_CLR_TIMEOUT_ERR /**< USB rx/tx timeout error interrupt clear */
404 #define USB_IT_CLR_SEQ_ERR LL_USB_INT_CLR_SEQ_ERR /**< USB DATA0/DATA1 PID sequence error interrupt clear */
405 #define USB_IT_CLR_PID_CKS_ERR LL_USB_INT_CLR_PID_CKS_ERR /**< USB PID checksum error interrupt clear */
406 #define USB_IT_CLR_PID_CRC_ERR LL_USB_INT_CLR_PID_CRC_ERR /**< USB PID CRC error interrupt clear */
407 #define USB_IT_CLR_HOST_RESET LL_USB_INT_CLR_HOST_RESET /**< USB host reset interrupt clear */
408 #define USB_IT_CLR_AHB_XFER_ERR LL_USB_INT_CLR_AHB_XFER_ERR /**< USB ep3 and ep4 AHB master receive error interrupt clear */
409 #define USB_IT_CLR_NSE_ERR LL_USB_INT_CLR_NSE_ERR /**< USB no such endpoint error interrupt clear */
410 #define USB_IT_CLR_EP3_AHB_XFER_DONE LL_USB_INT_CLR_EP3_AHB_XFER_DONE /**< USB ep3 AHB master transfer done interrupt clear */
411 #define USB_IT_CLR_SYNC_ERR LL_USB_INT_CLR_SYNC_ERR /**< USB SYNC error interrupt clear */
412 #define USB_IT_CLR_BIT_STUFF_ERR LL_USB_INT_CLR_BIT_STUFF_ERR /**< USB bit stuff error interrupt clear */
413 #define USB_IT_CLR_BYTE_ERR LL_USB_INT_CLR_BYTE_ERR /**< USB byte error interrupt clear */
414 #define USB_IT_CLR_SOF LL_USB_INT_CLR_SOF /**< USB SOF interrupt clear */
415 #define USB_IT_CLR_EP0_TX_DONE LL_USB_INT_CLR_EP0_TX_DONE /**< USB ep0 TX done interrupt clear */
416 #define USB_IT_CLR_EP2_TX_DONE LL_USB_INT_CLR_EP2_TX_DONE /**< USB ep2 TX done interrupt clear */
417 #define USB_IT_CLR_EP3_TX_DONE LL_USB_INT_CLR_EP3_TX_DONE /**< USB ep3 TX done interrupt clear */
418 #define USB_IT_CLR_INTO_CONFIG LL_USB_INT_CLR_INTO_CONFIG /**< USB into cofig status interrupt clear */
419 #define USB_IT_CLR_EP5_OUT_READY LL_USB_INT_CLR_EP5_OUT_READY /**< USB ep5 data out ready interrupt clear */
420 #define USB_IT_CLR_EP4_AHB_XFER_DONE LL_USB_INT_CLR_EP4_AHB_XFER_DONE /**< USB ep4 AHB master transfer done interrupt clear */
421 #define USB_IT_CLR_EP4_TX_DONE LL_USB_INT_CLR_EP4_TX_DONE /**< USB ep4 TX done interrupt clear */
422 #define USB_IT_CLR_EP5_AHB_XFER_DONE LL_USB_INT_CLR_EP5_AHB_XFER_DONE /**< USB ep5 AHB master transfer done interrupt clear */
423 #define USB_IT_CLR_EP5_TIMER_OUT_ERR LL_USB_INT_CLR_EP5_TIMER_OUT_ERR /**< USB ep5 timer out error interrupt clear */
424 /** @} */
425 
426 /** @} */
427 
428 /* Private macros ------------------------------------------------------------*/
429 /** @defgroup USB_Private_Macro USB Private Macros
430  * @{
431  */
432 
433 /** @brief Check if USB PWR Mode is valid.
434  * @param __MODE__ USB power Mode.
435  * @retval SET (__MODE__ is low power) or RESET (__MODE__ is normal)
436  */
437 #define IS_USB_PWR_MODE(__MODE__) (((__MODE__) == LL_USB_PWR_MODE_LP) || \
438  ((__MODE__) == USB_PWR_MODE_NORMAL))
439 
440 /** @brief Check if USB speed Mode is valid.
441  * @param __MODE__ USB speed Mode.
442  * @retval SET (__MODE__ is low speed) or RESET (__MODE__ is full speed)
443  */
444 #define IS_USB_SPEED(__MODE__) (((__MODE__) == USB_HAL_SPEED_LOW) || \
445  ((__MODE__) == USB_HAL_SPEED_FULL))
446 
447 /** @brief Check if USB enumeration type is valid.
448  * @param __TYPE__ USB enumeration type.
449  * @retval SET (__TYPE__ is HW enumeration) or RESET (__TYPE__ is MCU enumeration)
450  */
451 #define IS_USB_ENUM_TYPE(__TYPE__) (((__TYPE__) == USB_ENUM_TYPE_HW) || \
452  ((__TYPE__) == USB_ENUM_TYPE_MCU))
453 
454 /** @} */
455 
456 /* Exported macro ------------------------------------------------------------*/
457 /** @defgroup USB_Exported_Macros USB Exported Macros
458  * @{
459  */
460 
461 /** @brief Reset USB handle states.
462  * @param __HANDLE__ USB handle.
463  * @retval None
464  */
465 #define __HAL_USB_RESET_HANDLE_STATE(__HANDLE__) ((__HANDLE__)->state = HAL_USB_STATE_RESET)
466 
467 /** @brief Enable the specified USB peripheral.
468  * @retval None
469  */
470 #define __HAL_USB_ENABLE() ll_usb_enable()
471 
472 /** @brief Disable the specified USB peripheral.
473  * @retval None
474  */
475 #define __HAL_USB_DISABLE() ll_usb_disable()
476 
477 /** @brief Enable the specified USB peripheral software reset.
478  * @retval None
479  */
480 #define __HAL_USB_ENABLE_SW_RST() SET_BITS(MCU_SUB->USB_SW_RST, MCU_SUB_USB_SW_RST_EN)
481 
482 /** @brief Disable the specified USB peripheral software reset.
483  * @retval None
484  */
485 #define __HAL_USB_DISABLE_SW_RST() CLEAR_BITS(MCU_SUB->USB_SW_RST, MCU_SUB_USB_SW_RST_EN)
486 
487 /** @brief Enable the specified USB interrupts.
488  * @param __HANDLE__ Specifies the USB Handle.
489  * @param __INTERRUPT__ Specifies the interrupt source to enable.
490  * This parameter can be one of the following values:
491  * @arg @ref USB_IT_ALL USB all interrupt
492  * @arg @ref USB_IT_RESET_VAL interrupt control register rest value
493  * @arg @ref USB_IT_SUSPEND USB suspend status interrupt
494  * @arg @ref USB_IT_EP0_OUT_READY USB ep0 data out ready interrupt
495  * @arg @ref USB_IT_EP1_OUT_READY USB ep1 data out ready interrupt
496  * @arg @ref USB_IT_CRC16_ERR USB receive CRC error data interrupt
497  * @arg @ref USB_IT_UPID_ERR USB receive unsupported PID interrupt
498  * @arg @ref USB_IT_TIMEOUT_ERR USB rx/tx timeout error interrupt
499  * @arg @ref USB_IT_SEQ_ERR USB DATA0/DATA1 PID sequence error interrupt
500  * @arg @ref USB_IT_PID_CKS_ERR USB PID checksum error interrupt
501  * @arg @ref USB_IT_PID_CRC_ERR USB PID CRC error interrupt
502  * @arg @ref USB_IT_HOST_RESET USB host reset interrupt
503  * @arg @ref USB_IT_AHB_XFER_ERR USB ep3 and ep4 AHB master receive ERROR response interrupt
504  * @arg @ref USB_IT_NSE_ERR USB no such endpoint error interrupt
505  * @arg @ref USB_IT_EP3_AHB_XFER_DONE USB ep3 AHB master transfer done interrupt
506  * @arg @ref USB_IT_SYNC_ERR USB SYNC error interrupt
507  * @arg @ref USB_IT_BIT_STUFF_ERR USB bit stuff error interrupt
508  * @arg @ref USB_IT_BYTE_ERR USB byte error interrupt
509  * @arg @ref USB_IT_SOF USB SOF interrupt
510  * @arg @ref USB_IT_EP0_TX_DONE USB ep0 TX done interrupt
511  * @arg @ref USB_IT_EP2_TX_DONE USB ep2 TX done interrupt
512  * @arg @ref USB_IT_EP3_TX_DONE USB ep3 TX done interrupt
513  * @arg @ref USB_IT_INTO_CONFIG USB into cofig status interrupt
514  * @arg @ref USB_IT_EP5_OUT_READY USB ep5 data out ready interrupt
515  * @arg @ref USB_IT_CLR_EP4_AHB_XFER_DONE USB ep4 AHB master transfer done interrupt
516  * @arg @ref USB_IT_EP4_TX_DONE USB ep4 TX done interrupt
517  * @arg @ref USB_IT_EP5_AHB_XFER_DONE USB ep5 AHB master transfer done interrupt
518  * @arg @ref USB_IT_EP5_TIMER_OUT_ERR USB ep5 timer out error interrupt
519  * @retval None
520  */
521 #define __HAL_USB_ENABLE_IT(__HANDLE__, __INTERRUPT__) SET_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
522 
523 /** @brief Disable the specified USB interrupts.
524  * @param __HANDLE__ Specifies the USB handle.
525  * @param __INTERRUPT__ Specifies the interrupt source to disable.
526  * This parameter can be one of the following values:
527  * @arg @ref USB_IT_ALL USB all interrupt
528  * @arg @ref USB_IT_RESET_VAL interrupt control register rest value
529  * @arg @ref USB_IT_SUSPEND USB suspend status interrupt
530  * @arg @ref USB_IT_EP0_OUT_READY USB ep0 data out ready interrupt
531  * @arg @ref USB_IT_EP1_OUT_READY USB ep1 data out ready interrupt
532  * @arg @ref USB_IT_CRC16_ERR USB receive CRC error data interrupt
533  * @arg @ref USB_IT_UPID_ERR USB receive unsupported PID interrupt
534  * @arg @ref USB_IT_TIMEOUT_ERR USB rx/tx timeout error interrupt
535  * @arg @ref USB_IT_SEQ_ERR USB DATA0/DATA1 PID sequence error interrupt
536  * @arg @ref USB_IT_PID_CKS_ERR USB PID checksum error interrupt
537  * @arg @ref USB_IT_PID_CRC_ERR USB PID CRC error interrupt
538  * @arg @ref USB_IT_HOST_RESET USB host reset interrupt
539  * @arg @ref USB_IT_AHB_XFER_ERR USB ep3 and ep4 AHB master receive ERROR response interrupt
540  * @arg @ref USB_IT_NSE_ERR USB no such endpoint error interrupt
541  * @arg @ref USB_IT_EP3_AHB_XFER_DONE USB ep3 AHB master transfer done interrupt
542  * @arg @ref USB_IT_SYNC_ERR USB SYNC error interrupt
543  * @arg @ref USB_IT_BIT_STUFF_ERR USB bit stuff error interrupt
544  * @arg @ref USB_IT_BYTE_ERR USB byte error interrupt
545  * @arg @ref USB_IT_SOF USB SOF interrupt
546  * @arg @ref USB_IT_EP0_TX_DONE USB ep0 TX done interrupt
547  * @arg @ref USB_IT_EP2_TX_DONE USB ep2 TX done interrupt
548  * @arg @ref USB_IT_EP3_TX_DONE USB ep3 TX done interrupt
549  * @arg @ref USB_IT_EP3_TX_DONE USB ep3 TX done interrupt
550  * @arg @ref USB_IT_INTO_CONFIG USB into cofig status interrupt
551  * @arg @ref USB_IT_EP5_OUT_READY USB ep5 data out ready interrupt
552  * @arg @ref USB_IT_CLR_EP4_AHB_XFER_DONE USB ep4 AHB master transfer done interrupt
553  * @arg @ref USB_IT_EP4_TX_DONE USB ep4 TX done interrupt
554  * @arg @ref USB_IT_EP5_AHB_XFER_DONE USB ep5 AHB master transfer done interrupt
555  * @arg @ref USB_IT_EP5_TIMER_OUT_ERR USB ep5 timer out error interrupt
556  * @retval None
557  */
558 #define __HAL_USB_DISABLE_IT(__HANDLE__, __INTERRUPT__) CLEAR_BITS((__HANDLE__)->p_instance->INT_EN, (__INTERRUPT__))
559 
560 /** @brief Check whether the specified USB flag is set or not.
561  * @param __HANDLE__ Specifies the USB Handle.
562  * @param __FLAG__ Specifies the flag to check.
563  * This parameter can be one of the following values:
564  * @retval The new state of __FLAG__ (TRUE or FALSE).
565  * @arg @ref USB_Flags_definition USB all flag
566  * @arg @ref USB_FLAG_SUSPEND USB suspend status flag
567  * @arg @ref USB_FLAG_EP0_OUT_READY USB ep0 data out ready flag
568  * @arg @ref USB_FLAG_EP1_OUT_READY USB ep1 data out ready flag
569  * @arg @ref USB_FLAG_CRC16_ERR USB receive CRC error data flag
570  * @arg @ref USB_FLAG_UPID_ERR USB receive unsupported PID flag
571  * @arg @ref USB_FLAG_TIMEOUT_ERR USB rx/tx timeout error flag
572  * @arg @ref USB_FLAG_SEQ_ERR USB DATA0/DATA1 PID sequence error flag
573  * @arg @ref USB_FLAG_PID_CKS_ERR USB PID checksum error flag
574  * @arg @ref USB_FLAG_PID_CRC_ERR USB PID CRC error flag
575  * @arg @ref USB_FLAG_HOST_RESET USB host reset flag
576  * @arg @ref USB_FLAG_AHB_XFER_ERR USB ep3 and ep4 AHB master receive ERROR response flag
577  * @arg @ref USB_FLAG_NSE_ERR USB no such endpoint error flag
578  * @arg @ref USB_FLAG_EP3_AHB_XFER_DONE USB ep3 AHB master transfer done flag
579  * @arg @ref USB_FLAG_SYNC_ERR USB SYNC error flag
580  * @arg @ref USB_FLAG_BIT_STUFF_ERR USB bit stuff error flag
581  * @arg @ref USB_FLAG_BYTE_ERR USB byte error flag
582  * @arg @ref USB_FLAG_SOF USB SOF flag
583  * @arg @ref USB_FLAG_EP0_TX_DONE USB ep0 TX done flag
584  * @arg @ref USB_FLAG_EP2_TX_DONE USB ep2 TX done flag
585  * @arg @ref USB_FLAG_EP3_TX_DONE USB ep3 TX done flag
586  * @arg @ref USB_FLAG_INTO_CONFIG USB into cofig status flag
587  * @arg @ref USB_FLAG_EP5_OUT_READY USB ep5 data out ready flag
588  * @arg @ref USB_FLAG_EP4_AHB_XFER_DONE USB ep4 AHB master transfer done flag
589  * @arg @ref USB_FLAG_EP4_TX_DONE USB ep4 TX done flag
590  * @arg @ref USB_FLAG_EP5_AHB_XFER_DONE USB ep5 AHB master transfer done flag
591  * @arg @ref USB_FLAG_EP5_TIMER_OUT_ERR USB ep5 timer out error flag
592  */
593 #define __HAL_USB_GET_FLAG(__HANDLE__, __FLAG__) ((READ_BITS((__HANDLE__)->p_instance->INT_STAT, (__FLAG__)) != 0) ? SET : RESET)
594 
595 /** @brief Clear the specified USB flag.
596  * @param __HANDLE__ Specifies the USB Handle.
597  * @param __FLAG__ Specifies the flag to check.
598  * This parameter can be one of the following values:
599  * @arg @ref USB_IT_CLR_ALL USB all clear
600  * @arg @ref USB_IT_CLR_SUSPEND USB suspend status clear
601  * @arg @ref USB_IT_CLR_EP0_OUT_READY USB ep0 data out ready clear
602  * @arg @ref USB_IT_CLR_EP1_OUT_READY USB ep1 data out ready clear
603  * @arg @ref USB_IT_CLR_CRC16_ERR USB receive CRC error data clear
604  * @arg @ref USB_IT_CLR_UPID_ERR USB receive unsupported PID clear
605  * @arg @ref USB_IT_CLR_TIMEOUT_ERR USB rx/tx timeout error clear
606  * @arg @ref USB_IT_CLR_SEQ_ERR USB DATA0/DATA1 PID sequence error clear
607  * @arg @ref USB_IT_CLR_PID_CKS_ERR USB PID checksum error clear
608  * @arg @ref USB_IT_CLR_PID_CRC_ERR USB PID CRC error clear
609  * @arg @ref USB_IT_CLR_HOST_RESET USB host reset clear
610  * @arg @ref USB_IT_CLR_AHB_XFER_ERR USB ep3 and ep4 AHB master receive ERROR response clear
611  * @arg @ref USB_IT_CLR_NSE_ERR USB no such endpoint error clear
612  * @arg @ref USB_IT_CLR_EP3_AHB_XFER_DONE USB ep3 AHB master transfer done clear
613  * @arg @ref USB_IT_CLR_SYNC_ERR USB SYNC error flag
614  * @arg @ref USB_IT_CLR_BIT_STUFF_ERR USB bit stuff error clear
615  * @arg @ref USB_IT_CLR_BYTE_ERR USB byte error clear
616  * @arg @ref USB_IT_CLR_SOF USB SOF clear
617  * @arg @ref USB_IT_CLR_EP0_TX_DONE USB ep0 TX done clear
618  * @arg @ref USB_IT_CLR_EP2_TX_DONE USB ep2 TX done clear
619  * @arg @ref USB_IT_CLR_EP3_TX_DONE USB ep3 TX done clear
620  * @arg @ref USB_IT_CLR_INTO_CONFIG USB into cofig status interrupt clear
621  * @arg @ref USB_IT_CLR_EP5_OUT_READY USB ep5 data out ready interrupt clear
622  * @arg @ref USB_IT_CLR_EP4_AHB_XFER_DONE USB ep4 AHB master transfer done interrupt clear
623  * @arg @ref USB_IT_CLR_EP4_TX_DONE USB ep4 TX done interrupt clear
624  * @arg @ref USB_IT_CLR_EP5_AHB_XFER_DONE USB ep5 AHB master transfer done interrupt clear
625  * @arg @ref USB_IT_CLR_EP5_TIMER_OUT_ERR USB ep5 timer out error interrupt clear
626  * @retval None
627  */
628 #define __HAL_USB_CLEAR_FLAG(__HANDLE__, __FLAG__) SET_BITS((__HANDLE__)->p_instance->INT_CLR, (__FLAG__))
629 
630 /** @brief Check whether the specified USB flag is set or not.
631  * @param __HANDLE__ Specifies the USB Handle.
632  * @retval The new state of TRUE or FALSE.
633  */
634 #define __HAL_USB_GET_EP0_OUT_DAT_RDY(__HANDLE__) ((READ_BITS((__HANDLE__)->p_instance->CTRL, USB_CTRL_EP0_OUT_DATA_RDY) != 0) ? SET : RESET)
635 
636 /** @brief Enable the specified USB in addressed status.
637  * @param __HANDLE__ Specifies the USB Handle.
638  * @retval None
639  */
640 #define __HAL_USB_ENABLE_ADDR_STAT(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL,USB_CTRL_ADDR_STAT)
641 
642 /** @brief Enable the specified USB in configured status.
643  * @param __HANDLE__ Specifies the USB Handle.
644  * @retval None
645  */
646 #define __HAL_USB_ENABLE_CFG_STAT(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL,USB_CTRL_CFG_STAT)
647 
648 /** @brief clear the specified USB EP0 IN FIFO.
649  * @param __HANDLE__ Specifies the USB Handle.
650  * @retval None
651  */
652 #define __HAL_USB_CLEAR_EP0_IFIFO(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->EP0_1_CTRL,USB_EP0_CTRL_IFIFO_CLR)
653 
654 /** @brief clear the specified USB EP1 IN FIFO.
655  * @param __HANDLE__ Specifies the USB Handle.
656  * @retval None
657  */
658 #define __HAL_USB_CLEAR_EP1_IFIFO(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->EP0_1_CTRL,USB_EP1_CTRL_IFIFO_CLR)
659 
660 /** @brief Enable the specified USB device remote_wakeup feature.
661  * @param __HANDLE__ Specifies the USB handle.
662  * @retval None
663  */
664 #define __HAL_USB_ENABLE_DEV_REMOTE_WAKEUP(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->CTRL,USB_CTRL_DEV_REMOTE_WAKEUP)
665 
666 /** @brief Disable the specified USB device remote_wakeup feature.
667  * @param __HANDLE__ Specifies the USB handle.
668  * @retval None
669  */
670 #define __HAL_USB_DISABLE_DEV_REMOTE_WAKEUP(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->CTRL,USB_CTRL_DEV_REMOTE_WAKEUP)
671 
672 /** @brief Enable the specified USB EP5 DMA READ.
673  * @param __HANDLE__ Specifies the USB Handle.
674  * @retval None
675  */
676 #define __HAL_USB_ENABLE_EP5_DMA_READ(__HANDLE__) SET_BITS((__HANDLE__)->p_instance->EP5_CTRL,USB_EP5_CTRL_AHBM_EN)
677 
678 /** @brief Disable the specified USB EP5 DMA READ.
679  * @param __HANDLE__ Specifies the USB Handle.
680  * @retval None
681  */
682 #define __HAL_USB_DISABLE_EP5_DMA_READ(__HANDLE__) CLEAR_BITS((__HANDLE__)->p_instance->EP5_CTRL,USB_EP5_CTRL_AHBM_EN)
683 
684 
685 /** @brief Set USB ep5 DMA recieve data time out value.
686  * @param __HANDLE__ Specifies the USB Handle.
687  * @param __VAL__ Specifies 0:never timeout 1~1000ms.
688  * @retval None
689  */
690 #define __HAL_USB_SET_EP5_TIMER_VAL(__HANDLE__, __VAL__) MODIFY_REG((__HANDLE__)->p_instance->EP5_TIMER, USB_EP5_TIMER_VAL, (__VAL__));
691 
692 /** @brief Set USB ep4 DMA burst size value.
693  * @param __HANDLE__ Specifies the USB Handle.
694  * @param __VAL__ Specifies 0:ep4 DMA burst size value(32~1023).
695  * @retval None
696  */
697 #define __HAL_USB_SET_EP4_BURST_SIZE(__HANDLE__, __VAL__) MODIFY_REG((__HANDLE__)->p_instance->EP4_AHBM_CTRL, USB_EP4_AHBM_CTRL_BURST_SIZE,\
698  (__VAL__) << USB_EP4_AHBM_CTRL_BURST_SIZE_Pos);
699 /** @} */
700 
701 /** @} */
702 
703 /* Exported functions --------------------------------------------------------*/
704 /** @addtogroup HAL_USB_DRIVER_FUNCTIONS Functions
705  * @{
706  */
707 
708 /** @defgroup USB_Exported_Functions_Group1 Initialization and de-initialization functions
709  * @brief Initialization and de-initializations functions
710  *
711 @verbatim
712  ===============================================================================
713  ##### Initialization and de-initialization functions #####
714  ===============================================================================
715  [..] This subsection provides a set of functions allowing to initialize and
716  de-initialize the USBx peripheral:
717 
718  (+) User must implement hal_usb_msp_init() function in which he configures
719  all related peripherals resources (GPIO, DMA, IT and NVIC ).
720 
721  (+) Call the function hal_usb_init() to configure the selected device with
722  the selected configuration:
723  (++) Data Size
724  (++) Clock Polarity
725  (++) Audio Frequency
726 
727  (+) Call the function hal_usb_deinit() to restore the default configuration
728  of the selected USBx peripheral.
729 
730 @endverbatim
731  * @{
732  */
733 
734 /**
735  ****************************************************************************************
736  * @brief Initialize the USB according to the specified parameters
737  * in the usb_init_t and initialize the associated handle.
738  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
739  * @retval ::HAL_OK: Operation is OK.
740  * @retval ::HAL_ERROR: Parameter error or operation not supported.
741  * @retval ::HAL_BUSY: Driver is busy.
742  * @retval ::HAL_TIMEOUT: Timeout occurred.
743  ****************************************************************************************
744  */
746 
747 /**
748  ****************************************************************************************
749  * @brief De-initialize the USB peripheral.
750  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
751  * @retval ::HAL_OK: Operation is OK.
752  * @retval ::HAL_ERROR: Parameter error or operation not supported.
753  * @retval ::HAL_BUSY: Driver is busy.
754  * @retval ::HAL_TIMEOUT: Timeout occurred.
755  ****************************************************************************************
756  */
758 
759 /**
760  ****************************************************************************************
761  * @brief Initialize the USB MSP.
762  * @note This function should not be modified. When the callback is needed,
763  the hal_usb_msp_deinit can be implemented in the user file.
764  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
765  ****************************************************************************************
766  */
768 
769 /**
770  ****************************************************************************************
771  * @brief De-initialize the USB MSP.
772  * @note This function should not be modified. When the callback is needed,
773  the hal_usb_msp_deinit can be implemented in the user file.
774  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
775  ****************************************************************************************
776  */
778 
779 /** @} */
780 
781 /** @defgroup USB_Exported_Functions_Group2 USB operation functions
782  * @brief Data transfers functions
783  *
784 @verbatim
785  ==============================================================================
786  ##### USB operation functions #####
787  ===============================================================================
788  [..]
789  This subsection provides a set of functions allowing to manage the USB
790  data transfers.
791 
792  [..] The USB supports master and slave mode:
793 
794  (#) There are two modes of transfer:
795  (++) Blocking mode: The communication is performed in polling mode.
796  The HAL status of all data processing is returned by the same function
797  after finishing transfer.
798  (++) No-Blocking mode: The communication is performed using Interrupts
799  or DMA, These APIs return the HAL status.
800  The end of the data processing will be indicated through the
801  dedicated USB IRQ when using Interrupt mode or the DMA IRQ when
802  using DMA mode.
803  The hal_usb_tx_cplt_callback(), hal_usb_rx_cplt_callback() and hal_usb_tx_rx_cplt_callback() user callbacks
804  will be executed respectively at the end of the transmit or Receive process
805  The hal_usb_error_callback() user callback will be executed when a communication error is detected.
806 
807  (#) APIs provided for these 2 transfer modes (Blocking mode or Non blocking mode using either Interrupt or DMA)
808  exist for 1-Line (simplex) and 2-Line (full duplex) modes.
809 
810 @endverbatim
811  * @{
812  */
813 
814 /**
815  ****************************************************************************************
816  * @brief usb modlue reset the basic configuration during host reset
817  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
818  * @retval ::HAL_OK: Operation is OK.
819  * @retval ::HAL_ERROR: Parameter error or operation not supported.
820  * @retval ::HAL_BUSY: Driver is busy.
821  * @retval ::HAL_TIMEOUT: Timeout occurred.
822  ****************************************************************************************
823  */
825 
826 /**
827  ****************************************************************************************
828  * @brief usb module gets whether the device is connected to the host.
829  * @retval ::0: usb device is disconnected to the host.
830  * @retval ::1: usb device is connected to the host.
831  ****************************************************************************************
832  */
834 
835 /**
836  ****************************************************************************************
837  * @brief usb ep start transmit data.
838  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
839  * @param[in] ep: USB endpoit number(only EP0 EP2 EP3 EP4 supported)
840  * @retval ::HAL_OK: Operation is OK.
841  * @retval ::HAL_ERROR: Parameter error or operation not supported.
842  * @retval ::HAL_BUSY: Driver is busy.
843  * @retval ::HAL_TIMEOUT: Timeout occurred.
844  ****************************************************************************************
845  */
847 
848 /**
849  ****************************************************************************************
850  * @brief usbd inform host transmit data end.
851  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
852  * @param[in] ep: USB endpoit number(only EP0 EP2 EP3 EP4 supported)
853  * @retval ::HAL_OK: Operation is OK.
854  * @retval ::HAL_ERROR: Parameter error or operation not supported.
855  * @retval ::HAL_BUSY: Driver is busy.
856  * @retval ::HAL_TIMEOUT: Timeout occurred.
857  ****************************************************************************************
858  */
860 
861 /**
862  ****************************************************************************************
863  * @brief usb ep start receive data.
864  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
865  * @param[in] ep: USB endpoit number(only EP0 EP1 EP5 supported)
866  * @retval ::HAL_OK: Operation is OK.
867  * @retval ::HAL_ERROR: Parameter error or operation not supported.
868  * @retval ::HAL_BUSY: Driver is busy.
869  * @retval ::HAL_TIMEOUT: Timeout occurred.
870  ****************************************************************************************
871  */
873 
874 /**
875  ****************************************************************************************
876  * @brief usbd inform host receive data end.
877  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
878  * @param[in] ep: USB endpoit number(only EP0 EP1 EP5 supported)
879  * @retval ::HAL_OK: Operation is OK.
880  * @retval ::HAL_ERROR: Parameter error or operation not supported.
881  * @retval ::HAL_BUSY: Driver is busy.
882  * @retval ::HAL_TIMEOUT: Timeout occurred.
883  ****************************************************************************************
884  */
886 
887 /**
888  ****************************************************************************************
889  * @brief Transmit an amount of data to USB endpoint in dma mode.
890  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
891  * @param[in] ep: USB endpoit number( EP3 or EP4 support dma transmit mode)
892  * @param[in] p_data: Pointer to ahbm buffer adderss
893  * @param[in] length: Amount of data transmit during dma mode.
894  * @retval ::HAL_OK: Operation is OK.
895  * @retval ::HAL_ERROR: Parameter error or operation not supported.
896  * @retval ::HAL_BUSY: Driver is busy.
897  * @retval ::HAL_TIMEOUT: Timeout occurred.
898  ****************************************************************************************
899  */
900 hal_status_t hal_usb_ep_transmit_dma(usb_handle_t *p_usb,hal_usb_ep_t ep,uint8_t *p_data, uint32_t length);
901 
902 /**
903  ****************************************************************************************
904  * @brief Receive an amount of data to USB endpoint in dma mode.
905  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
906  * @param[in] ep: USB endpoit number(EP5 support dma receive mode)
907  * @param[in] p_data: Pointer to AHB master buffer adderss
908  * @param[in] length: Amount of data receive during dma mode.
909  * @retval ::HAL_OK: Operation is OK.
910  * @retval ::HAL_ERROR: Parameter error or operation not supported.
911  * @retval ::HAL_BUSY: Driver is busy.
912  * @retval ::HAL_TIMEOUT: Timeout occurred.
913  ****************************************************************************************
914  */
915 hal_status_t hal_usb_ep_receive_dma(usb_handle_t *p_usb,hal_usb_ep_t ep,uint8_t *p_data, uint32_t length);
916 /**
917  ****************************************************************************************
918  * @brief set USB devcice address.
919  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
920  * @param[in] addr: USB device address.
921  * @retval ::HAL_OK: Operation is OK.
922  * @retval ::HAL_ERROR: Parameter error or operation not supported.
923  * @retval ::HAL_BUSY: Driver is busy.
924  * @retval ::HAL_TIMEOUT: Timeout occurred.
925  ****************************************************************************************
926  */
928 
929 /**
930  ****************************************************************************************
931  * @brief get USB devcice address
932  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
933  * @return USB devcice address form host
934  ****************************************************************************************
935  */
937 
938 
939 /**
940  ****************************************************************************************
941  * @brief write 32bit value to USB endpoit FIFO.
942  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
943  * @param[in] ep: USB endpoit number(only EP0 EP2 EP3 EP4 supported)
944  * @param[in] value: USB endpoit FIFO 32bit data
945  * @param[in] ep4_wr_byte: USB ep4 write fifo effective byte
946  USB_EP4_FIFO_WEN_DEFAULT
947  USB_EP4_FIFO_WEN_1BYTE
948  USB_EP4_FIFO_WEN_2BYTE
949  USB_EP4_FIFO_WEN_3BYTE
950  USB_EP4_FIFO_WEN_4BYTE
951  * @retval ::HAL_OK: Operation is OK.
952  * @retval ::HAL_ERROR: Parameter error or operation not supported.
953  * @retval ::HAL_BUSY: Driver is busy.
954  * @retval ::HAL_TIMEOUT: Timeout occurred.
955  ****************************************************************************************
956  */
957 hal_status_t hal_usb_write_ep_fifo(usb_handle_t *p_usb,hal_usb_ep_t ep,uint32_t value,uint32_t ep4_wr_byte);
958 
959 /**
960  ****************************************************************************************
961  * @brief read 32bit value from USB endpoit FIFO.
962  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
963  * @param[in] ep: ep EP0 EP1 EP5
964  * @retval :: value USB endpoit FIFO 32bit data
965  ****************************************************************************************
966  */
968 
969 
970 /**
971  ****************************************************************************************
972  * @brief set USB EP attribute.
973  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
974  * @param[in] ep: ep EP1 EP2 EP3
975  * @param[in] attr: USB attribute setting. This parameter can be one of the following values:
976  * @arg @ref USB_EP_ATTR_INT Endpoint attribute setting: interrupt
977  * @arg @ref USB_EP_ATTR_ISO Endpoint attribute setting: Isochronous
978  * @arg @ref USB_EP_ATTR_BULK Endpoint attribute setting: bulk
979  * @retval ::HAL_OK: Operation is OK.
980  * @retval ::HAL_ERROR: Parameter error or operation not supported.
981  * @retval ::HAL_BUSY: Driver is busy.
982  * @retval ::HAL_TIMEOUT: Timeout occurred.
983  ****************************************************************************************
984  */
986 
987 /**
988  ****************************************************************************************
989  * @brief get USB EP attribute setting.
990  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
991  * @param[in] ep: ep EP1 EP2 EP3
992  * @return USB attribute setting This parameter can be one of the following values:
993  * @arg @ref USB_EP_ATTR_INT Endpoint attribute setting: interrupt
994  * @arg @ref USB_EP_ATTR_ISO Endpoint attribute setting: Isochronous
995  * @arg @ref USB_EP_ATTR_BULK Endpoint attribute setting: bulk
996  ****************************************************************************************
997  */
999 
1000 /**
1001  ****************************************************************************************
1002  * @brief USB halt the endpoint.
1003  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1004  * @param[in] ep: ep EP1 EP2 EP3
1005  * @retval ::HAL_OK: Operation is OK.
1006  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1007  * @retval ::HAL_BUSY: Driver is busy.
1008  * @retval ::HAL_TIMEOUT: Timeout occurred.
1009  ****************************************************************************************
1010  */
1012 
1013 /**
1014  ****************************************************************************************
1015  * @brief USB un halt the endpoint.
1016  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1017  * @param[in] ep: ep EP1 EP2 EP3
1018  * @retval ::HAL_OK: Operation is OK.
1019  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1020  * @retval ::HAL_BUSY: Driver is busy.
1021  * @retval ::HAL_TIMEOUT: Timeout occurred.
1022  ****************************************************************************************
1023  */
1025 
1026 /**
1027  ****************************************************************************************
1028  * @brief USB un halt the endpoint and set the endpoint attribute.
1029  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1030  * @param[in] ep: ep EP1 EP2 EP3
1031  * @param[in] attr: USB attribute setting.
1032  * @retval ::HAL_OK: Operation is OK.
1033  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1034  * @retval ::HAL_BUSY: Driver is busy.
1035  * @retval ::HAL_TIMEOUT: Timeout occurred.
1036  ****************************************************************************************
1037  */
1039 
1040 
1041 /**
1042  ****************************************************************************************
1043  * @brief get USB EP0 received data sum.
1044  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1045  * @return USB received data sum in the EP0 IN FIFO
1046  * @arg 0x0 ~ 0xFF.
1047  ****************************************************************************************
1048  */
1050 
1051 /**
1052  ****************************************************************************************
1053  * @brief get USB all interrupt status.
1054  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1055  * @return USB all interrupt flag
1056  ****************************************************************************************
1057  */
1059 /**
1060  ****************************************************************************************
1061  * @brief get USB EP1 received data sum.
1062  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1063  * @return USB received data sum in the EP IN FIFO
1064  * @arg 0x0 ~ 0xFF.
1065  ****************************************************************************************
1066  */
1068 
1069 /**
1070  ****************************************************************************************
1071  * @brief get USB EP5 received data sum.
1072  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1073  * @return USB received data sum in the EP IN FIFO
1074  * @arg 0x0 ~ 0xFF.
1075  ****************************************************************************************
1076  */
1078 
1079 /**
1080  ****************************************************************************************
1081  * @brief send ok command to USB host(EP0).
1082  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1083  * @retval ::HAL_OK: Operation is OK.
1084  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1085  * @retval ::HAL_BUSY: Driver is busy.
1086  * @retval ::HAL_TIMEOUT: Timeout occurred.
1087  ****************************************************************************************
1088  */
1090 
1091 
1092 /**
1093  ****************************************************************************************
1094  * @brief send error command to USB host(EP0).
1095  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1096  * @retval ::HAL_OK: Operation is OK.
1097  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1098  * @retval ::HAL_BUSY: Driver is busy.
1099  * @retval ::HAL_TIMEOUT: Timeout occurred.
1100  ****************************************************************************************
1101  */
1103 
1104 /** @} */
1105 
1106 /** @addtogroup USB_IRQ_Handler_and_Callbacks IRQ Handler and Callbacks
1107  * @brief IRQ Handler and Callbacks functions
1108  * @{
1109  */
1110 
1111 /**
1112  ****************************************************************************************
1113  * @brief Handle USB interrupt request.
1114  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1115  ****************************************************************************************
1116  */
1118 
1119 /**
1120  ****************************************************************************************
1121  * @brief Handle USB attach interrupt request.
1122  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1123  ****************************************************************************************
1124  */
1126 
1127 /**
1128  ****************************************************************************************
1129  * @brief Handle USB detach interrupt request.
1130  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1131  ****************************************************************************************
1132  */
1134 
1135 /**
1136  ****************************************************************************************
1137  * @brief USB attach callback.
1138  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1139  ****************************************************************************************
1140  */
1142 
1143 /**
1144  ****************************************************************************************
1145  * @brief USB detach callback.
1146  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1147  ****************************************************************************************
1148  */
1150 
1151 /**
1152  ****************************************************************************************
1153  * @brief usb suspend callback.
1154  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1155  ****************************************************************************************
1156  */
1158 
1159 /**
1160  ****************************************************************************************
1161  * @brief usb EP0 output ready callback.
1162  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1163  ****************************************************************************************
1164  */
1166 
1167 /**
1168  ****************************************************************************************
1169  * @brief usb EP1 output ready callback.
1170  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1171  ****************************************************************************************
1172  */
1174 
1175 
1176 /**
1177  ****************************************************************************************
1178  * @brief usb receive CRC error data callback.
1179  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1180  ****************************************************************************************
1181  */
1183 
1184 /**
1185  ****************************************************************************************
1186  * @brief usb receive unsupported PID callback.
1187  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1188  ****************************************************************************************
1189  */
1191 
1192 /**
1193  ****************************************************************************************
1194  * @brief usb rx/tx timeout error callback.
1195  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1196  ****************************************************************************************
1197  */
1199 
1200 /**
1201  ****************************************************************************************
1202  * @brief usb DATA0/DATA1 PID sequence error callback.
1203  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1204  ****************************************************************************************
1205  */
1207 
1208 /**
1209  ****************************************************************************************
1210  * @brief usb PID checksum error callback.
1211  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1212  ****************************************************************************************
1213  */
1215 
1216 /**
1217  ****************************************************************************************
1218  * @brief usb PID CRC error callback.
1219  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1220  ****************************************************************************************
1221  */
1223 
1224 /**
1225  ****************************************************************************************
1226  * @brief usb host reset callback.
1227  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1228  ****************************************************************************************
1229  */
1231 
1232 /**
1233  ****************************************************************************************
1234  * @brief usb EP3 and EP4 AHB master receive ERROR response callback.
1235  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1236  ****************************************************************************************
1237  */
1239 
1240 /**
1241  ****************************************************************************************
1242  * @brief usb no such endpoint error callback.
1243  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1244  ****************************************************************************************
1245  */
1247 
1248 /**
1249  ****************************************************************************************
1250  * @brief usb ep3 AHB master transfer done callback.
1251  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1252  ****************************************************************************************
1253  */
1255 
1256 /**
1257  ****************************************************************************************
1258  * @brief usb SYNC error callback.
1259  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1260  ****************************************************************************************
1261  */
1263 
1264 /**
1265  ****************************************************************************************
1266  * @brief usb bit stuff error callback.
1267  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1268  ****************************************************************************************
1269  */
1271 
1272 /**
1273  ****************************************************************************************
1274  * @brief usb byte error callback.
1275  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1276  ****************************************************************************************
1277  */
1279 
1280 /**
1281  ****************************************************************************************
1282  * @brief usb SOF interrupt callback.
1283  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1284  ****************************************************************************************
1285  */
1287 
1288 /**
1289  ****************************************************************************************
1290  * @brief usb EP0 IN FIFO data has sent to host callback.
1291  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1292  ****************************************************************************************
1293  */
1295 
1296 /**
1297  ****************************************************************************************
1298  * @brief usb EP2 IN FIFO data has sent to host callback.
1299  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1300  ****************************************************************************************
1301  */
1303 
1304 /**
1305  ****************************************************************************************
1306  * @brief usb EP3 IN FIFO data has sent to host callback.
1307  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1308  ****************************************************************************************
1309  */
1311 
1312 /**
1313  ****************************************************************************************
1314  * @brief usb hardware enumeration into config status callback.
1315  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1316  ****************************************************************************************
1317  */
1319 
1320 /**
1321  ****************************************************************************************
1322  * @brief usb EP5 output ready callback.
1323  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1324  ****************************************************************************************
1325  */
1327 
1328 /**
1329  ****************************************************************************************
1330  * @brief usb ep4 AHB master transfer done callback.
1331  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1332  ****************************************************************************************
1333  */
1335 
1336 /**
1337  ****************************************************************************************
1338  * @brief usb EP4 IN FIFO data has sent to host callback.
1339  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1340  ****************************************************************************************
1341  */
1343 
1344 /**
1345  ****************************************************************************************
1346  * @brief usb ep5 AHB master transfer done callback.
1347  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1348  ****************************************************************************************
1349  */
1351 
1352 /**
1353  ****************************************************************************************
1354  * @brief usb ep5 timer out error callback.
1355  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1356  ****************************************************************************************
1357  */
1359 
1360 /** @} */
1361 
1362 /** @defgroup USB_Exported_Functions_Group3 Peripheral State and Errors functions
1363  * @brief USB control functions
1364  *
1365 @verbatim
1366  ===============================================================================
1367  ##### Peripheral State and Errors functions #####
1368  ===============================================================================
1369  [..]
1370  This subsection provides a set of functions allowing to control the USB.
1371  (+) hal_usb_get_state() API can be helpful to check in run-time the state of the USB peripheral
1372  (+) hal_usb_get_error() check in run-time Errors occurring during communication
1373  (+) hal_usb_set_timeout() set the timeout during internal process
1374 @endverbatim
1375  * @{
1376  */
1377 
1378 /**
1379  ****************************************************************************************
1380  * @brief Return the USB handle state.
1381  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1382  * @retval ::HAL_USB_STATE_RESET: Peripheral not initialized.
1383  * @retval ::HAL_USB_STATE_READY: Peripheral initialized and ready for use.
1384  * @retval ::HAL_USB_STATE_BUSY: An internal process is ongoing.
1385  * @retval ::HAL_USB_STATE_BUSY_HOST_REST: USB in host rest state during enumeration
1386  * @retval ::HAL_USB_STATE_BUSY_ADDR: USB in adress state during enumeration
1387  * @retval ::HAL_USB_STATE_BUSY_CFG: USB in configure state during enumeration
1388  * @retval ::HAL_USB_STATE_ABORT: Peripheral with abort request ongoing.
1389  * @retval ::HAL_USB_STATE_ERROR: Peripheral in error.
1390  ****************************************************************************************
1391  */
1393 
1394 /**
1395  ****************************************************************************************
1396  * @brief Return the USB error code.
1397  * @param[in] p_usb: Pointer to an USB handle which contains the configuration information for the specified USB module.
1398  * @return USB error code in bitmap format
1399  ****************************************************************************************
1400  */
1402 
1403 
1404 /**
1405  ****************************************************************************************
1406  * @brief Suspend some registers related to USB configuration before sleep.
1407  * @param[in] p_usb: Pointer to a USB handle which contains the configuration
1408  * information for the specified USB module.
1409  * @retval ::HAL_OK: Operation is OK.
1410  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1411  * @retval ::HAL_BUSY: Driver is busy.
1412  * @retval ::HAL_TIMEOUT: Timeout occurred.
1413  ****************************************************************************************
1414  */
1416 
1417 /**
1418  ****************************************************************************************
1419  * @brief Restore some registers related to USB configuration after sleep.
1420  * This function must be used in conjunction with the hal_usb_suspend_reg().
1421  * @param[in] p_usb: Pointer to a USB handle which contains the configuration
1422  * information for the specified USB module.
1423  * @retval ::HAL_OK: Operation is OK.
1424  * @retval ::HAL_ERROR: Parameter error or operation not supported.
1425  * @retval ::HAL_BUSY: Driver is busy.
1426  * @retval ::HAL_TIMEOUT: Timeout occurred.
1427  ****************************************************************************************
1428  */
1430 
1431 
1432 /** @} */
1433 
1434 /** @} */
1435 
1436 #ifdef __cplusplus
1437 }
1438 #endif
1439 
1440 #endif /* __GR55xx_HAL_USB_H__ */
1441 
1442 /** @} */
1443 
1444 /** @} */
1445 
1446 /** @} */
HAL_USB_EP1
@ HAL_USB_EP1
Definition: gr55xx_hal_usb.h:102
hal_usb_pid_crc_err_callback
void hal_usb_pid_crc_err_callback(usb_handle_t *p_usb)
usb PID CRC error callback.
usb_init_t
struct _usb_init usb_init_t
USB init Structure definition.
hal_usb_msp_deinit
void hal_usb_msp_deinit(usb_handle_t *p_usb)
De-initialize the USB MSP.
_usb_callback::usb_ep5_out_ready_callback
void(* usb_ep5_out_ready_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:244
hal_usb_pid_cks_err_callback
void hal_usb_pid_cks_err_callback(usb_handle_t *p_usb)
usb PID checksum error callback.
HAL_USB_STATE_ERROR
@ HAL_USB_STATE_ERROR
Definition: gr55xx_hal_usb.h:79
_usb_callback::usb_ep0_tx_done_callback
void(* usb_ep0_tx_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:238
hal_lock_t
hal_lock_t
HAL Lock structures definition.
Definition: gr55xx_hal_def.h:81
HAL_USB_STATE_ERROR_SYNC
@ HAL_USB_STATE_ERROR_SYNC
Definition: gr55xx_hal_usb.h:88
_usb_callback::usb_ep3_ahb_xfer_done_callback
void(* usb_ep3_ahb_xfer_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:233
_usb_handle
USB handle Structure definition.
Definition: gr55xx_hal_usb.h:186
_usb_handle::lock
__IO hal_lock_t lock
Definition: gr55xx_hal_usb.h:191
_usb_handle::p_instance
usb_regs_t * p_instance
Definition: gr55xx_hal_usb.h:187
hal_usb_ep_receive_dma
hal_status_t hal_usb_ep_receive_dma(usb_handle_t *p_usb, hal_usb_ep_t ep, uint8_t *p_data, uint32_t length)
Receive an amount of data to USB endpoint in dma mode.
_usb_callback::usb_ep4_ahb_xfer_done_callback
void(* usb_ep4_ahb_xfer_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:242
HAL_USB_STATE_ERROR_BYTE
@ HAL_USB_STATE_ERROR_BYTE
Definition: gr55xx_hal_usb.h:90
hal_usb_ep_transmit_dma
hal_status_t hal_usb_ep_transmit_dma(usb_handle_t *p_usb, hal_usb_ep_t ep, uint8_t *p_data, uint32_t length)
Transmit an amount of data to USB endpoint in dma mode.
hal_usb_ep0_tx_done_callback
void hal_usb_ep0_tx_done_callback(usb_handle_t *p_usb)
usb EP0 IN FIFO data has sent to host callback.
hal_usb_ep2_tx_done_callback
void hal_usb_ep2_tx_done_callback(usb_handle_t *p_usb)
usb EP2 IN FIFO data has sent to host callback.
hal_usb_ep5_timer_out_err_callback
void hal_usb_ep5_timer_out_err_callback(usb_handle_t *p_usb)
usb ep5 timer out error callback.
HAL_USB_STATE_BUSY_ADDR
@ HAL_USB_STATE_BUSY_ADDR
Definition: gr55xx_hal_usb.h:77
_usb_init::speed
uint32_t speed
Definition: gr55xx_hal_usb.h:167
hal_usb_irq_handler
void hal_usb_irq_handler(usb_handle_t *p_usb)
Handle USB interrupt request.
_usb_callback::usb_ep2_tx_done_callback
void(* usb_ep2_tx_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:239
hal_usb_sof_callback
void hal_usb_sof_callback(usb_handle_t *p_usb)
usb SOF interrupt callback.
hal_usb_ep4_tx_done_callback
void hal_usb_ep4_tx_done_callback(usb_handle_t *p_usb)
usb EP4 IN FIFO data has sent to host callback.
HAL_USB_STATE_BUSY
@ HAL_USB_STATE_BUSY
Definition: gr55xx_hal_usb.h:75
hal_usb_get_addr
uint32_t hal_usb_get_addr(usb_handle_t *p_usb)
get USB devcice address
HAL_USB_STATE_RESET
@ HAL_USB_STATE_RESET
Definition: gr55xx_hal_usb.h:73
_usb_handle::init
usb_init_t init
Definition: gr55xx_hal_usb.h:189
_usb_callback::usb_suspend_callback
void(* usb_suspend_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:221
_usb_callback::usb_ep5_ahb_xfer_done_callback
void(* usb_ep5_ahb_xfer_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:245
hal_usb_resume_reg
hal_status_t hal_usb_resume_reg(usb_handle_t *p_usb)
Restore some registers related to USB configuration after sleep. This function must be used in conjun...
hal_usb_crc16_err_callback
void hal_usb_crc16_err_callback(usb_handle_t *p_usb)
usb receive CRC error data callback.
_usb_callback::usb_msp_deinit
void(* usb_msp_deinit)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:220
HAL_USB_STATE_ERROR_PID_CRC
@ HAL_USB_STATE_ERROR_PID_CRC
Definition: gr55xx_hal_usb.h:85
_usb_callback::usb_time_out_callback
void(* usb_time_out_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:226
_usb_init
USB init Structure definition.
Definition: gr55xx_hal_usb.h:166
HAL_USB_STATE_ABORT
@ HAL_USB_STATE_ABORT
Definition: gr55xx_hal_usb.h:92
hw_enum_parm::sram_size
uint16_t sram_size
Definition: gr55xx_hal_usb.h:154
hal_usb_ep5_out_ready_callback
void hal_usb_ep5_out_ready_callback(usb_handle_t *p_usb)
usb EP5 output ready callback.
_usb_callback::usb_msp_init
void(* usb_msp_init)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:219
_usb_callback::usb_upid_err_callback
void(* usb_upid_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:225
hw_enum_parm::cfg_desc_size
uint8_t cfg_desc_size
Definition: gr55xx_hal_usb.h:127
hal_usb_upid_err_callback
void hal_usb_upid_err_callback(usb_handle_t *p_usb)
usb receive unsupported PID callback.
hw_enum_parm::str_desc0_start
uint8_t str_desc0_start
Definition: gr55xx_hal_usb.h:130
hal_usb_bit_stuff_err_callback
void hal_usb_bit_stuff_err_callback(usb_handle_t *p_usb)
usb bit stuff error callback.
HAL_USB_STATE_BUSY_CFG
@ HAL_USB_STATE_BUSY_CFG
Definition: gr55xx_hal_usb.h:78
_usb_callback::usb_ahb_xfer_err_callback
void(* usb_ahb_xfer_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:231
hal_usb_init
hal_status_t hal_usb_init(usb_handle_t *p_usb)
Initialize the USB according to the specified parameters in the usb_init_t and initialize the associa...
hal_usb_into_config_callback
void hal_usb_into_config_callback(usb_handle_t *p_usb)
usb hardware enumeration into config status callback.
hal_usb_ep_write_end
hal_status_t hal_usb_ep_write_end(usb_handle_t *p_usb, hal_usb_ep_t ep)
usbd inform host transmit data end.
hal_usb_ep5_ahb_xfer_done_callback
void hal_usb_ep5_ahb_xfer_done_callback(usb_handle_t *p_usb)
usb ep5 AHB master transfer done callback.
HAL_USB_STATE_ERROR_SEQ
@ HAL_USB_STATE_ERROR_SEQ
Definition: gr55xx_hal_usb.h:83
_usb_init::hw_enum
hw_enum_parm_t hw_enum
Definition: gr55xx_hal_usb.h:173
hal_usb_ep1_out_ready_callback
void hal_usb_ep1_out_ready_callback(usb_handle_t *p_usb)
usb EP1 output ready callback.
hal_usb_state_t
hal_usb_state_t
HAL USB State Enumerations definition.
Definition: gr55xx_hal_usb.h:72
hal_usb_get_ep5_rx_data_sum
uint32_t hal_usb_get_ep5_rx_data_sum(usb_handle_t *p_usb)
get USB EP5 received data sum.
_usb_callback::usb_ep5_timer_out_err_callback
void(* usb_ep5_timer_out_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:246
HAL_USB_EP5
@ HAL_USB_EP5
Definition: gr55xx_hal_usb.h:106
hal_usb_get_ep1_rx_data_sum
uint32_t hal_usb_get_ep1_rx_data_sum(usb_handle_t *p_usb)
get USB EP1 received data sum.
hal_usb_read_ep_fifo
uint32_t hal_usb_read_ep_fifo(usb_handle_t *p_usb, hal_usb_ep_t ep)
read 32bit value from USB endpoit FIFO.
hal_usb_ep_read_start
hal_status_t hal_usb_ep_read_start(usb_handle_t *p_usb, hal_usb_ep_t ep)
usb ep start receive data.
_usb_callback::usb_seq_err_callback
void(* usb_seq_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:227
_usb_handle::state
__IO hal_usb_state_t state
Definition: gr55xx_hal_usb.h:193
hw_enum_parm::str_desc1_start
uint8_t str_desc1_start
Definition: gr55xx_hal_usb.h:136
hal_usb_halt_ep
hal_status_t hal_usb_halt_ep(usb_handle_t *p_usb, hal_usb_ep_t ep)
USB halt the endpoint.
HAL_USB_STATE_ERROR_TIMEOUT
@ HAL_USB_STATE_ERROR_TIMEOUT
Definition: gr55xx_hal_usb.h:82
hw_enum_parm::str_desc1_size
uint8_t str_desc1_size
Definition: gr55xx_hal_usb.h:139
hal_usb_ep_write_start
hal_status_t hal_usb_ep_write_start(usb_handle_t *p_usb, hal_usb_ep_t ep)
usb ep start transmit data.
_usb_callback::usb_ep0_out_ready_callback
void(* usb_ep0_out_ready_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:222
_usb_handle::error_code
__IO uint32_t error_code
Definition: gr55xx_hal_usb.h:195
hw_enum_parm_t
struct hw_enum_parm hw_enum_parm_t
USB hardware enumeration Structure definition.
hal_usb_get_ep_attr
uint32_t hal_usb_get_ep_attr(usb_handle_t *p_usb, hal_usb_ep_t ep)
get USB EP attribute setting.
_usb_callback::usb_ep1_out_ready_callback
void(* usb_ep1_out_ready_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:223
usb_handle_t
struct _usb_handle usb_handle_t
USB handle Structure definition.
usb_callback_t
struct _usb_callback usb_callback_t
HAL_USB Callback function definition.
HAL_USB_STATE_ERROR_EP5_TIMER
@ HAL_USB_STATE_ERROR_EP5_TIMER
Definition: gr55xx_hal_usb.h:91
_usb_callback::usb_ep4_tx_done_callback
void(* usb_ep4_tx_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:243
hal_usb_ep0_out_ready_callback
void hal_usb_ep0_out_ready_callback(usb_handle_t *p_usb)
usb EP0 output ready callback.
hal_usb_get_connect_state
uint8_t hal_usb_get_connect_state(void)
usb module gets whether the device is connected to the host.
HAL_USB_EP3
@ HAL_USB_EP3
Definition: gr55xx_hal_usb.h:104
_usb_callback::usb_detach_callback
void(* usb_detach_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:248
_usb_init::enum_type
uint32_t enum_type
Definition: gr55xx_hal_usb.h:170
_usb_handle::timeout
uint32_t timeout
Definition: gr55xx_hal_usb.h:197
_usb_callback::usb_into_config_callback
void(* usb_into_config_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:241
_usb_callback
HAL_USB Callback function definition.
Definition: gr55xx_hal_usb.h:218
hal_usb_set_cmd_err
hal_status_t hal_usb_set_cmd_err(usb_handle_t *p_usb)
send error command to USB host(EP0).
HAL_USB_STATE_BUSY_HOST_REST
@ HAL_USB_STATE_BUSY_HOST_REST
Definition: gr55xx_hal_usb.h:76
HAL_USB_STATE_ERROR_NSE
@ HAL_USB_STATE_ERROR_NSE
Definition: gr55xx_hal_usb.h:87
hal_usb_ep_t
hal_usb_ep_t
HAL USB EP.
Definition: gr55xx_hal_usb.h:100
hal_usb_seq_err_callback
void hal_usb_seq_err_callback(usb_handle_t *p_usb)
usb DATA0/DATA1 PID sequence error callback.
_usb_callback::usb_host_reset_callback
void(* usb_host_reset_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:230
hal_usb_get_state
hal_usb_state_t hal_usb_get_state(usb_handle_t *p_usb)
Return the USB handle state.
_usb_callback::usb_ep3_tx_done_callback
void(* usb_ep3_tx_done_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:240
hw_enum_parm::p_sram_addr
uint32_t * p_sram_addr
Definition: gr55xx_hal_usb.h:157
HAL_USB_EP0
@ HAL_USB_EP0
Definition: gr55xx_hal_usb.h:101
HAL_USB_EP4
@ HAL_USB_EP4
Definition: gr55xx_hal_usb.h:105
hal_usb_suspend_callback
void hal_usb_suspend_callback(usb_handle_t *p_usb)
usb suspend callback.
hw_enum_parm::str_desc0_size
uint8_t str_desc0_size
Definition: gr55xx_hal_usb.h:133
_usb_callback::usb_sync_err_callback
void(* usb_sync_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:234
hal_status_t
hal_status_t
HAL Status structures definition.
Definition: gr55xx_hal_def.h:70
hal_usb_ep4_ahb_xfer_done_callback
void hal_usb_ep4_ahb_xfer_done_callback(usb_handle_t *p_usb)
usb ep4 AHB master transfer done callback.
hw_enum_parm::cfg_desc_start
uint8_t cfg_desc_start
Definition: gr55xx_hal_usb.h:124
hal_usb_suspend_reg
hal_status_t hal_usb_suspend_reg(usb_handle_t *p_usb)
Suspend some registers related to USB configuration before sleep.
HAL_USB_STATE_ERROR_UPID
@ HAL_USB_STATE_ERROR_UPID
Definition: gr55xx_hal_usb.h:81
hal_usb_ep3_ahb_xfer_done_callback
void hal_usb_ep3_ahb_xfer_done_callback(usb_handle_t *p_usb)
usb ep3 AHB master transfer done callback.
_usb_callback::usb_pid_crc_err_callback
void(* usb_pid_crc_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:229
_usb_callback::usb_nse_err_callback
void(* usb_nse_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:232
hal_usb_reset
hal_status_t hal_usb_reset(usb_handle_t *p_usb)
usb modlue reset the basic configuration during host reset
hal_usb_get_it_flag
uint32_t hal_usb_get_it_flag(usb_handle_t *p_usb)
get USB all interrupt status.
_usb_callback::usb_bit_stuff_err_callback
void(* usb_bit_stuff_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:235
hw_enum_parm::str_desc3_size
uint8_t str_desc3_size
Definition: gr55xx_hal_usb.h:151
hal_usb_set_cmd_ok
hal_status_t hal_usb_set_cmd_ok(usb_handle_t *p_usb)
send ok command to USB host(EP0).
_usb_callback::usb_attach_callback
void(* usb_attach_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:247
hw_enum_parm::str_desc2_size
uint8_t str_desc2_size
Definition: gr55xx_hal_usb.h:145
hal_usb_write_ep_fifo
hal_status_t hal_usb_write_ep_fifo(usb_handle_t *p_usb, hal_usb_ep_t ep, uint32_t value, uint32_t ep4_wr_byte)
write 32bit value to USB endpoit FIFO.
hal_usb_byte_err_callback
void hal_usb_byte_err_callback(usb_handle_t *p_usb)
usb byte error callback.
hal_usb_detach_callback
void hal_usb_detach_callback(usb_handle_t *p_usb)
USB detach callback.
HAL_USB_STATE_ERROR_DMA_RX
@ HAL_USB_STATE_ERROR_DMA_RX
Definition: gr55xx_hal_usb.h:86
hal_usb_get_error
uint32_t hal_usb_get_error(usb_handle_t *p_usb)
Return the USB error code.
hal_usb_ep_read_end
hal_status_t hal_usb_ep_read_end(usb_handle_t *p_usb, hal_usb_ep_t ep)
usbd inform host receive data end.
hal_usb_attach_callback
void hal_usb_attach_callback(usb_handle_t *p_usb)
USB attach callback.
_usb_callback::usb_sof_callback
void(* usb_sof_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:237
hal_usb_get_ep0_rx_data_sum
uint32_t hal_usb_get_ep0_rx_data_sum(usb_handle_t *p_usb)
get USB EP0 received data sum.
HAL_USB_STATE_READY
@ HAL_USB_STATE_READY
Definition: gr55xx_hal_usb.h:74
HAL_USB_STATE_ERROR_BIT_STUFF
@ HAL_USB_STATE_ERROR_BIT_STUFF
Definition: gr55xx_hal_usb.h:89
_usb_callback::usb_crc16_err_callback
void(* usb_crc16_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:224
hal_usb_ep3_tx_done_callback
void hal_usb_ep3_tx_done_callback(usb_handle_t *p_usb)
usb EP3 IN FIFO data has sent to host callback.
_usb_callback::usb_pid_cks_err_callback
void(* usb_pid_cks_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:228
hal_usb_time_out_callback
void hal_usb_time_out_callback(usb_handle_t *p_usb)
usb rx/tx timeout error callback.
HAL_USB_STATE_ERROR_CRC16
@ HAL_USB_STATE_ERROR_CRC16
Definition: gr55xx_hal_usb.h:80
hal_usb_ahb_xfer_err_callback
void hal_usb_ahb_xfer_err_callback(usb_handle_t *p_usb)
usb EP3 and EP4 AHB master receive ERROR response callback.
HAL_USB_STATE_ERROR_PID_CKS
@ HAL_USB_STATE_ERROR_PID_CKS
Definition: gr55xx_hal_usb.h:84
hal_usb_attach_irq_handler
void hal_usb_attach_irq_handler(usb_handle_t *p_usb)
Handle USB attach interrupt request.
hal_usb_detach_irq_handler
void hal_usb_detach_irq_handler(usb_handle_t *p_usb)
Handle USB detach interrupt request.
hal_usb_set_ep_attr
hal_status_t hal_usb_set_ep_attr(usb_handle_t *p_usb, hal_usb_ep_t ep, uint32_t attr)
set USB EP attribute.
hal_usb_deinit
hal_status_t hal_usb_deinit(usb_handle_t *p_usb)
De-initialize the USB peripheral.
_usb_callback::usb_byte_err_callback
void(* usb_byte_err_callback)(usb_handle_t *p_usb)
Definition: gr55xx_hal_usb.h:236
hw_enum_parm
USB hardware enumeration Structure definition.
Definition: gr55xx_hal_usb.h:123
hal_usb_un_halt_ep
hal_status_t hal_usb_un_halt_ep(usb_handle_t *p_usb, hal_usb_ep_t ep)
USB un halt the endpoint.
hal_usb_set_addr
hal_status_t hal_usb_set_addr(usb_handle_t *p_usb, uint32_t addr)
set USB devcice address.
HAL_USB_EP2
@ HAL_USB_EP2
Definition: gr55xx_hal_usb.h:103
hal_usb_set_and_unhalt_ep
hal_status_t hal_usb_set_and_unhalt_ep(usb_handle_t *p_usb, hal_usb_ep_t ep, uint32_t attr)
USB un halt the endpoint and set the endpoint attribute.
hal_usb_host_reset_callback
void hal_usb_host_reset_callback(usb_handle_t *p_usb)
usb host reset callback.
gr55xx_hal_def.h
This file contains HAL common definitions, enumeration, macros and structures definitions.
hal_usb_nse_err_callback
void hal_usb_nse_err_callback(usb_handle_t *p_usb)
usb no such endpoint error callback.
hw_enum_parm::str_desc2_start
uint8_t str_desc2_start
Definition: gr55xx_hal_usb.h:142
gr55xx_ll_usb.h
Header file containing functions prototypes of usb LL library.
_usb_handle::retention
uint32_t retention[12]
Definition: gr55xx_hal_usb.h:199
HAL_USB_STATE_SUSPEND
@ HAL_USB_STATE_SUSPEND
Definition: gr55xx_hal_usb.h:93
hw_enum_parm::str_desc3_start
uint8_t str_desc3_start
Definition: gr55xx_hal_usb.h:148
hal_usb_msp_init
void hal_usb_msp_init(usb_handle_t *p_usb)
Initialize the USB MSP.
hal_usb_sync_err_callback
void hal_usb_sync_err_callback(usb_handle_t *p_usb)
usb SYNC error callback.