1 /**
2   ******************************************************************************
3   * @file    stm32f2xx_ll_usb.h
4   * @author  MCD Application Team
5   * @brief   Header file of USB Low Layer HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * Copyright (c) 2016 STMicroelectronics.
10   * All rights reserved.
11   *
12   * This software is licensed under terms that can be found in the LICENSE file
13   * in the root directory of this software component.
14   * If no LICENSE file comes with this software, it is provided AS-IS.
15   *
16   ******************************************************************************
17   */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef STM32F2xx_LL_USB_H
21 #define STM32F2xx_LL_USB_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif /* __cplusplus */
26 
27 /* Includes ------------------------------------------------------------------*/
28 #include "stm32f2xx_hal_def.h"
29 
30 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
31 /** @addtogroup STM32F2xx_HAL_Driver
32   * @{
33   */
34 
35 /** @addtogroup USB_LL
36   * @{
37   */
38 
39 /* Exported types ------------------------------------------------------------*/
40 
41 /**
42   * @brief  USB Mode definition
43   */
44 
45 typedef enum
46 {
47   USB_DEVICE_MODE = 0,
48   USB_HOST_MODE   = 1,
49   USB_DRD_MODE    = 2
50 } USB_ModeTypeDef;
51 
52 /**
53   * @brief  URB States definition
54   */
55 typedef enum
56 {
57   URB_IDLE = 0,
58   URB_DONE,
59   URB_NOTREADY,
60   URB_NYET,
61   URB_ERROR,
62   URB_STALL
63 } USB_URBStateTypeDef;
64 
65 /**
66   * @brief  Host channel States  definition
67   */
68 typedef enum
69 {
70   HC_IDLE = 0,
71   HC_XFRC,
72   HC_HALTED,
73   HC_ACK,
74   HC_NAK,
75   HC_NYET,
76   HC_STALL,
77   HC_XACTERR,
78   HC_BBLERR,
79   HC_DATATGLERR
80 } USB_HCStateTypeDef;
81 
82 
83 /**
84   * @brief  USB Instance Initialization Structure definition
85   */
86 typedef struct
87 {
88   uint32_t dev_endpoints;           /*!< Device Endpoints number.
89                                          This parameter depends on the used USB core.
90                                          This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
91 
92   uint32_t Host_channels;           /*!< Host Channels number.
93                                          This parameter Depends on the used USB core.
94                                          This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
95 
96   uint32_t dma_enable;              /*!< USB DMA state.
97                                          If DMA is not supported this parameter shall be set by default to zero */
98 
99   uint32_t speed;                   /*!< USB Core speed.
100                                          This parameter can be any value of @ref PCD_Speed/HCD_Speed
101                                                                                  (HCD_SPEED_xxx, HCD_SPEED_xxx) */
102 
103   uint32_t ep0_mps;                 /*!< Set the Endpoint 0 Max Packet size.                                    */
104 
105   uint32_t phy_itface;              /*!< Select the used PHY interface.
106                                          This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module  */
107 
108   uint32_t Sof_enable;              /*!< Enable or disable the output of the SOF signal.                        */
109 
110   uint32_t low_power_enable;        /*!< Enable or disable the low Power Mode.                                  */
111 
112   uint32_t lpm_enable;              /*!< Enable or disable Link Power Management.                               */
113 
114   uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                    */
115 
116   uint32_t vbus_sensing_enable;     /*!< Enable or disable the VBUS Sensing feature.                            */
117 
118   uint32_t use_dedicated_ep1;       /*!< Enable or disable the use of the dedicated EP1 interrupt.              */
119 
120   uint32_t use_external_vbus;       /*!< Enable or disable the use of the external VBUS.                        */
121 
122 } USB_CfgTypeDef;
123 
124 typedef struct
125 {
126   uint8_t   num;                  /*!< Endpoint number
127                                        This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
128 
129   uint8_t   is_in;                /*!< Endpoint direction
130                                        This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
131 
132   uint8_t   is_stall;             /*!< Endpoint stall condition
133                                        This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
134 
135   uint8_t   is_iso_incomplete;    /*!< Endpoint isoc condition
136                                        This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
137 
138   uint8_t   type;                 /*!< Endpoint type
139                                        This parameter can be any value of @ref USB_LL_EP_Type                   */
140 
141   uint8_t   data_pid_start;       /*!< Initial data PID
142                                        This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
143 
144   uint32_t  maxpacket;            /*!< Endpoint Max packet size
145                                        This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
146 
147   uint8_t   *xfer_buff;           /*!< Pointer to transfer buffer                                               */
148 
149   uint32_t  xfer_len;             /*!< Current transfer length                                                  */
150 
151   uint32_t  xfer_count;           /*!< Partial transfer length in case of multi packet transfer                 */
152 
153   uint8_t   even_odd_frame;       /*!< IFrame parity
154                                        This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
155 
156   uint16_t  tx_fifo_num;          /*!< Transmission FIFO number
157                                        This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
158 
159   uint32_t  dma_addr;             /*!< 32 bits aligned transfer buffer address                                  */
160 
161   uint32_t  xfer_size;            /*!< requested transfer size                                                  */
162 } USB_EPTypeDef;
163 
164 typedef struct
165 {
166   uint8_t   dev_addr;           /*!< USB device address.
167                                      This parameter must be a number between Min_Data = 1 and Max_Data = 255    */
168 
169   uint8_t   ch_num;             /*!< Host channel number.
170                                      This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
171 
172   uint8_t   ep_num;             /*!< Endpoint number.
173                                      This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
174 
175   uint8_t   ep_is_in;           /*!< Endpoint direction
176                                      This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
177 
178   uint8_t   speed;              /*!< USB Host Channel speed.
179                                      This parameter can be any value of @ref HCD_Device_Speed:
180                                                                              (HCD_DEVICE_SPEED_xxx)             */
181 
182   uint8_t   do_ping;            /*!< Enable or disable the use of the PING protocol for HS mode.                */
183   uint8_t   do_ssplit;          /*!< Enable start split transaction in HS mode.                                 */
184   uint8_t   do_csplit;          /*!< Enable complete split transaction in HS mode.                              */
185   uint8_t   ep_ss_schedule;     /*!< Enable periodic endpoint start split schedule .                            */
186   uint32_t  iso_splt_xactPos;   /*!< iso split transfer transaction position.                                   */
187 
188   uint8_t   hub_port_nbr;       /*!< USB HUB port number                                                        */
189   uint8_t   hub_addr;           /*!< USB HUB address                                                            */
190 
191   uint8_t   ep_type;            /*!< Endpoint Type.
192                                      This parameter can be any value of @ref USB_LL_EP_Type                     */
193 
194   uint16_t  max_packet;         /*!< Endpoint Max packet size.
195                                      This parameter must be a number between Min_Data = 0 and Max_Data = 64KB   */
196 
197   uint8_t   data_pid;           /*!< Initial data PID.
198                                      This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
199 
200   uint8_t   *xfer_buff;         /*!< Pointer to transfer buffer.                                                */
201 
202   uint32_t  XferSize;           /*!< OTG Channel transfer size.                                                 */
203 
204   uint32_t  xfer_len;           /*!< Current transfer length.                                                   */
205 
206   uint32_t  xfer_count;         /*!< Partial transfer length in case of multi packet transfer.                  */
207 
208   uint8_t   toggle_in;          /*!< IN transfer current toggle flag.
209                                      This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
210 
211   uint8_t   toggle_out;         /*!< OUT transfer current toggle flag
212                                      This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
213 
214   uint32_t  dma_addr;           /*!< 32 bits aligned transfer buffer address.                                   */
215 
216   uint32_t  ErrCnt;             /*!< Host channel error count.                                                  */
217   uint32_t  NyetErrCnt;         /*!< Complete Split NYET Host channel error count.                              */
218 
219   USB_URBStateTypeDef urb_state;  /*!< URB state.
220                                        This parameter can be any value of @ref USB_URBStateTypeDef              */
221 
222   USB_HCStateTypeDef state;       /*!< Host Channel state.
223                                        This parameter can be any value of @ref USB_HCStateTypeDef               */
224 } USB_HCTypeDef;
225 
226 typedef USB_ModeTypeDef     USB_OTG_ModeTypeDef;
227 typedef USB_CfgTypeDef      USB_OTG_CfgTypeDef;
228 typedef USB_EPTypeDef       USB_OTG_EPTypeDef;
229 typedef USB_URBStateTypeDef USB_OTG_URBStateTypeDef;
230 typedef USB_HCStateTypeDef  USB_OTG_HCStateTypeDef;
231 typedef USB_HCTypeDef       USB_OTG_HCTypeDef;
232 
233 /* Exported constants --------------------------------------------------------*/
234 
235 /** @defgroup PCD_Exported_Constants PCD Exported Constants
236   * @{
237   */
238 
239 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
240 /** @defgroup USB_OTG_CORE VERSION ID
241   * @{
242   */
243 #define USB_OTG_CORE_ID_300A          0x4F54300AU
244 #define USB_OTG_CORE_ID_310A          0x4F54310AU
245 /**
246   * @}
247   */
248 
249 /** @defgroup USB_Core_Mode_ USB Core Mode
250   * @{
251   */
252 #define USB_OTG_MODE_DEVICE                    0U
253 #define USB_OTG_MODE_HOST                      1U
254 #define USB_OTG_MODE_DRD                       2U
255 /**
256   * @}
257   */
258 
259 /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed
260   * @{
261   */
262 #define USB_OTG_SPEED_HIGH                     0U
263 #define USB_OTG_SPEED_HIGH_IN_FULL             1U
264 #define USB_OTG_SPEED_FULL                     3U
265 /**
266   * @}
267   */
268 
269 /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY
270   * @{
271   */
272 #define USB_OTG_ULPI_PHY                       1U
273 #define USB_OTG_EMBEDDED_PHY                   2U
274 /**
275   * @}
276   */
277 
278 /** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value
279   * @{
280   */
281 #ifndef USBD_HS_TRDT_VALUE
282 #define USBD_HS_TRDT_VALUE                     9U
283 #endif /* USBD_HS_TRDT_VALUE */
284 #ifndef USBD_FS_TRDT_VALUE
285 #define USBD_FS_TRDT_VALUE                     5U
286 #define USBD_DEFAULT_TRDT_VALUE                9U
287 #endif /* USBD_HS_TRDT_VALUE */
288 /**
289   * @}
290   */
291 
292 /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS
293   * @{
294   */
295 #define USB_OTG_HS_MAX_PACKET_SIZE           512U
296 #define USB_OTG_FS_MAX_PACKET_SIZE            64U
297 #define USB_OTG_MAX_EP0_SIZE                  64U
298 /**
299   * @}
300   */
301 
302 /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency
303   * @{
304   */
305 #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ     (0U << 1)
306 #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ     (1U << 1)
307 #define DSTS_ENUMSPD_FS_PHY_48MHZ              (3U << 1)
308 /**
309   * @}
310   */
311 
312 /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval
313   * @{
314   */
315 #define DCFG_FRAME_INTERVAL_80                 0U
316 #define DCFG_FRAME_INTERVAL_85                 1U
317 #define DCFG_FRAME_INTERVAL_90                 2U
318 #define DCFG_FRAME_INTERVAL_95                 3U
319 /**
320   * @}
321   */
322 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
323 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
324   * @{
325   */
326 #define EP_MPS_64                              0U
327 #define EP_MPS_32                              1U
328 #define EP_MPS_16                              2U
329 #define EP_MPS_8                               3U
330 /**
331   * @}
332   */
333 
334 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
335   * @{
336   */
337 #define EP_TYPE_CTRL                           0U
338 #define EP_TYPE_ISOC                           1U
339 #define EP_TYPE_BULK                           2U
340 #define EP_TYPE_INTR                           3U
341 #define EP_TYPE_MSK                            3U
342 /**
343   * @}
344   */
345 
346 /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed
347   * @{
348   */
349 #define EP_SPEED_LOW                           0U
350 #define EP_SPEED_FULL                          1U
351 #define EP_SPEED_HIGH                          2U
352 /**
353   * @}
354   */
355 
356 /** @defgroup USB_LL_CH_PID_Type USB Low Layer Channel PID Type
357   * @{
358   */
359 #define HC_PID_DATA0                           0U
360 #define HC_PID_DATA2                           1U
361 #define HC_PID_DATA1                           2U
362 #define HC_PID_SETUP                           3U
363 /**
364   * @}
365   */
366 
367 /** @defgroup USB_LL Device Speed
368   * @{
369   */
370 #define USBD_HS_SPEED                          0U
371 #define USBD_HSINFS_SPEED                      1U
372 #define USBH_HS_SPEED                          0U
373 #define USBD_FS_SPEED                          2U
374 #define USBH_FSLS_SPEED                        1U
375 /**
376   * @}
377   */
378 
379 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
380 /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines
381   * @{
382   */
383 #define STS_GOUT_NAK                           1U
384 #define STS_DATA_UPDT                          2U
385 #define STS_XFER_COMP                          3U
386 #define STS_SETUP_COMP                         4U
387 #define STS_SETUP_UPDT                         6U
388 /**
389   * @}
390   */
391 
392 /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines
393   * @{
394   */
395 #define HCFG_30_60_MHZ                         0U
396 #define HCFG_48_MHZ                            1U
397 #define HCFG_6_MHZ                             2U
398 /**
399   * @}
400   */
401 
402 /** @defgroup USB_LL_HFIR_Defines USB Low Layer frame interval Defines
403   * @{
404   */
405 #define HFIR_6_MHZ                          6000U
406 #define HFIR_60_MHZ                        60000U
407 #define HFIR_48_MHZ                        48000U
408 /**
409   * @}
410   */
411 
412 /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines
413   * @{
414   */
415 #define HPRT0_PRTSPD_HIGH_SPEED                0U
416 #define HPRT0_PRTSPD_FULL_SPEED                1U
417 #define HPRT0_PRTSPD_LOW_SPEED                 2U
418 /**
419   * @}
420   */
421 
422 #define HCCHAR_CTRL                            0U
423 #define HCCHAR_ISOC                            1U
424 #define HCCHAR_BULK                            2U
425 #define HCCHAR_INTR                            3U
426 
427 #define GRXSTS_PKTSTS_IN                       2U
428 #define GRXSTS_PKTSTS_IN_XFER_COMP             3U
429 #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR          5U
430 #define GRXSTS_PKTSTS_CH_HALTED                7U
431 
432 #define CLEAR_INTERRUPT_MASK          0xFFFFFFFFU
433 
434 #define HC_MAX_PKT_CNT                       256U
435 #define ISO_SPLT_MPS                         188U
436 
437 #define HCSPLT_BEGIN                           1U
438 #define HCSPLT_MIDDLE                          2U
439 #define HCSPLT_END                             3U
440 #define HCSPLT_FULL                            4U
441 
442 #define TEST_J                                 1U
443 #define TEST_K                                 2U
444 #define TEST_SE0_NAK                           3U
445 #define TEST_PACKET                            4U
446 #define TEST_FORCE_EN                          5U
447 
448 #define USBx_PCGCCTL    *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE)
449 #define USBx_HPRT0      *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE)
450 
451 #define USBx_DEVICE     ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE))
452 #define USBx_INEP(i)    ((USB_OTG_INEndpointTypeDef *)(USBx_BASE\
453                                                        + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
454 
455 #define USBx_OUTEP(i)   ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE\
456                                                         + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
457 
458 #define USBx_DFIFO(i)   *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE))
459 
460 #define USBx_HOST       ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE))
461 #define USBx_HC(i)      ((USB_OTG_HostChannelTypeDef *)(USBx_BASE\
462                                                         + USB_OTG_HOST_CHANNEL_BASE\
463                                                         + ((i) * USB_OTG_HOST_CHANNEL_SIZE)))
464 
465 
466 #define EP_ADDR_MSK                            0xFU
467 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
468 /**
469   * @}
470   */
471 
472 /* Exported macro ------------------------------------------------------------*/
473 /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros
474   * @{
475   */
476 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
477 #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)     ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
478 #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)   ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
479 
480 #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__)          (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
481 #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__)         (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
482 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
483 /**
484   * @}
485   */
486 
487 /* Exported functions --------------------------------------------------------*/
488 /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
489   * @{
490   */
491 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
492 HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
493 HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
494 HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
495 HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
496 HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed);
497 HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_OTG_ModeTypeDef mode);
498 HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed);
499 HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx);
500 HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num);
501 HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
502 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
503 HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
504 HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
505 HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep, uint8_t dma);
506 HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src,
507                                   uint8_t ch_ep_num, uint16_t len, uint8_t dma);
508 
509 void             *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
510 HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
511 HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
512 HAL_StatusTypeDef USB_EPStopXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
513 HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address);
514 HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx);
515 HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx);
516 HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
517 HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx);
518 HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uint8_t *psetup);
519 uint8_t           USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
520 uint32_t          USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
521 uint32_t          USB_ReadInterrupts(USB_OTG_GlobalTypeDef const *USBx);
522 uint32_t          USB_ReadChInterrupts(USB_OTG_GlobalTypeDef *USBx, uint8_t chnum);
523 uint32_t          USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
524 uint32_t          USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
525 uint32_t          USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
526 uint32_t          USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
527 void              USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
528 
529 HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
530 HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq);
531 HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
532 HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state);
533 uint32_t          USB_GetHostSpeed(USB_OTG_GlobalTypeDef const *USBx);
534 uint32_t          USB_GetCurrentFrame(USB_OTG_GlobalTypeDef const *USBx);
535 HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num,
536                               uint8_t epnum, uint8_t dev_address, uint8_t speed,
537                               uint8_t ep_type, uint16_t mps);
538 HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx,
539                                    USB_OTG_HCTypeDef *hc, uint8_t dma);
540 
541 uint32_t          USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx);
542 HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num);
543 HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num);
544 HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
545 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
546 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
547 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
548 
549 /**
550   * @}
551   */
552 
553 /**
554   * @}
555   */
556 
557 /**
558   * @}
559   */
560 
561 /**
562   * @}
563   */
564 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
565 
566 #ifdef __cplusplus
567 }
568 #endif /* __cplusplus */
569 
570 
571 #endif /* STM32F2xx_LL_USB_H */
572