1 /**
2   ******************************************************************************
3   * @file    stm32l4xx_ll_usb.h
4   * @author  MCD Application Team
5   * @brief   Header file of USB Low Layer HAL module.
6   ******************************************************************************
7   * @attention
8   *
9   * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
10   *
11   * Redistribution and use in source and binary forms, with or without modification,
12   * are permitted provided that the following conditions are met:
13   *   1. Redistributions of source code must retain the above copyright notice,
14   *      this list of conditions and the following disclaimer.
15   *   2. Redistributions in binary form must reproduce the above copyright notice,
16   *      this list of conditions and the following disclaimer in the documentation
17   *      and/or other materials provided with the distribution.
18   *   3. Neither the name of STMicroelectronics nor the names of its contributors
19   *      may be used to endorse or promote products derived from this software
20   *      without specific prior written permission.
21   *
22   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32   *
33   ******************************************************************************
34   */
35 
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32L4xx_LL_USB_H
38 #define __STM32L4xx_LL_USB_H
39 
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
43 
44 /* Includes ------------------------------------------------------------------*/
45 #include "stm32l4xx_hal_def.h"
46 
47 #if defined (USB) || defined (USB_OTG_FS) || defined (USB_OTG_HS)
48 
49 /** @addtogroup STM32L4xx_HAL_Driver
50   * @{
51   */
52 
53 /** @addtogroup USB_LL
54   * @{
55   */
56 
57 /* Exported types ------------------------------------------------------------*/
58 
59 /**
60   * @brief  USB Mode definition
61   */
62 typedef enum
63 {
64   USB_DEVICE_MODE  = 0,
65   USB_HOST_MODE    = 1,
66   USB_DRD_MODE     = 2
67 } USB_ModeTypeDef;
68 
69 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
70 /**
71   * @brief  URB States definition
72   */
73 typedef enum
74 {
75   URB_IDLE = 0,
76   URB_DONE,
77   URB_NOTREADY,
78   URB_NYET,
79   URB_ERROR,
80   URB_STALL
81 } USB_OTG_URBStateTypeDef;
82 
83 /**
84   * @brief  Host channel States  definition
85   */
86 typedef enum
87 {
88   HC_IDLE = 0,
89   HC_XFRC,
90   HC_HALTED,
91   HC_NAK,
92   HC_NYET,
93   HC_STALL,
94   HC_XACTERR,
95   HC_BBLERR,
96   HC_DATATGLERR
97 } USB_OTG_HCStateTypeDef;
98 
99 /**
100   * @brief  USB OTG Initialization Structure definition
101   */
102 typedef struct
103 {
104   uint32_t dev_endpoints;        /*!< Device Endpoints number.
105                                       This parameter depends on the used USB core.
106                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
107 
108   uint32_t Host_channels;        /*!< Host Channels number.
109                                       This parameter Depends on the used USB core.
110                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
111 
112   uint32_t speed;                /*!< USB Core speed.
113                                       This parameter can be any value of @ref USB_Core_Speed_                */
114 
115   uint32_t dma_enable;           /*!< Enable or disable of the USB embedded DMA used only for OTG HS.                             */
116 
117   uint32_t ep0_mps;              /*!< Set the Endpoint 0 Max Packet size.
118                                       This parameter can be any value of @ref USB_EP0_MPS_                   */
119 
120   uint32_t phy_itface;           /*!< Select the used PHY interface.
121                                       This parameter can be any value of @ref USB_Core_PHY_                  */
122 
123   uint32_t Sof_enable;           /*!< Enable or disable the output of the SOF signal.                        */
124 
125   uint32_t low_power_enable;     /*!< Enable or disable the low power mode.                                  */
126 
127   uint32_t lpm_enable;           /*!< Enable or disable Link Power Management.                               */
128 
129   uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                 */
130 
131   uint32_t vbus_sensing_enable;  /*!< Enable or disable the VBUS Sensing feature.                            */
132 
133   uint32_t use_dedicated_ep1;    /*!< Enable or disable the use of the dedicated EP1 interrupt.              */
134 
135   uint32_t use_external_vbus;    /*!< Enable or disable the use of the external VBUS.                        */
136 } USB_OTG_CfgTypeDef;
137 
138 typedef struct
139 {
140   uint8_t   num;            /*!< Endpoint number
141                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15    */
142 
143   uint8_t   is_in;          /*!< Endpoint direction
144                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
145 
146   uint8_t   is_stall;       /*!< Endpoint stall condition
147                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
148 
149   uint8_t   type;           /*!< Endpoint type
150                                  This parameter can be any value of @ref USB_EP_Type_                     */
151 
152   uint8_t   data_pid_start; /*!< Initial data PID
153                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
154 
155   uint8_t   even_odd_frame; /*!< IFrame parity
156                                  This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
157 
158   uint16_t  tx_fifo_num;    /*!< Transmission FIFO number
159                                  This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
160 
161   uint32_t  maxpacket;      /*!< Endpoint Max packet size
162                                  This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
163 
164   uint8_t   *xfer_buff;     /*!< Pointer to transfer buffer                                               */
165 
166   uint32_t  dma_addr;       /*!< 32 bits aligned transfer buffer address                                  */
167 
168   uint32_t  xfer_len;       /*!< Current transfer length                                                  */
169 
170   uint32_t  xfer_count;     /*!< Partial transfer length in case of multi packet transfer                 */
171 } USB_OTG_EPTypeDef;
172 
173 typedef struct
174 {
175   uint8_t   dev_addr ;     /*!< USB device address.
176                                 This parameter must be a number between Min_Data = 1 and Max_Data = 255    */
177 
178   uint8_t   ch_num;        /*!< Host channel number.
179                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
180 
181   uint8_t   ep_num;        /*!< Endpoint number.
182                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
183 
184   uint8_t   ep_is_in;      /*!< Endpoint direction
185                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
186 
187   uint8_t   speed;         /*!< USB Host speed.
188                                 This parameter can be any value of @ref USB_Core_Speed_                    */
189 
190   uint8_t   do_ping;       /*!< Enable or disable the use of the PING protocol for HS mode.                */
191 
192   uint8_t   process_ping;  /*!< Execute the PING protocol for HS mode.                                     */
193 
194   uint8_t   ep_type;       /*!< Endpoint Type.
195                                 This parameter can be any value of @ref USB_EP_Type_                       */
196 
197   uint16_t  max_packet;    /*!< Endpoint Max packet size.
198                                 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB   */
199 
200   uint8_t   data_pid;      /*!< Initial data PID.
201                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
202 
203   uint8_t   *xfer_buff;    /*!< Pointer to transfer buffer.                                                */
204 
205   uint32_t  xfer_len;      /*!< Current transfer length.                                                   */
206 
207   uint32_t  xfer_count;    /*!< Partial transfer length in case of multi packet transfer.                  */
208 
209   uint8_t   toggle_in;     /*!< IN transfer current toggle flag.
210                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
211 
212   uint8_t   toggle_out;    /*!< OUT transfer current toggle flag
213                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
214 
215   uint32_t  dma_addr;      /*!< 32 bits aligned transfer buffer address.                                   */
216 
217   uint32_t  ErrCnt;        /*!< Host channel error count.*/
218 
219   USB_OTG_URBStateTypeDef  urb_state;  /*!< URB state.
220                                            This parameter can be any value of @ref USB_OTG_URBStateTypeDef */
221 
222   USB_OTG_HCStateTypeDef   state;     /*!< Host Channel state.
223                                            This parameter can be any value of @ref USB_OTG_HCStateTypeDef  */
224 } USB_OTG_HCTypeDef;
225 #endif /* defined USB_OTG_FS || USB_OTG_HS */
226 
227 #if defined (USB)
228 /**
229   * @brief  USB Initialization Structure definition
230   */
231 typedef struct
232 {
233   uint32_t dev_endpoints;        /*!< Device Endpoints number.
234                                       This parameter depends on the used USB core.
235                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
236 
237   uint32_t speed;                /*!< USB Core speed.
238                                       This parameter can be any value of @ref USB_Core_Speed                 */
239 
240   uint32_t ep0_mps;              /*!< Set the Endpoint 0 Max Packet size.
241                                       This parameter can be any value of @ref USB_EP0_MPS                    */
242 
243   uint32_t phy_itface;           /*!< Select the used PHY interface.
244                                       This parameter can be any value of @ref USB_Core_PHY                   */
245 
246   uint32_t Sof_enable;           /*!< Enable or disable the output of the SOF signal.                        */
247 
248   uint32_t low_power_enable;       /*!< Enable or disable Low Power mode                                      */
249 
250   uint32_t lpm_enable;             /*!< Enable or disable Battery charging.                                  */
251 
252   uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                  */
253 } USB_CfgTypeDef;
254 
255 typedef struct
256 {
257   uint8_t   num;            /*!< Endpoint number
258                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15    */
259 
260   uint8_t   is_in;          /*!< Endpoint direction
261                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
262 
263   uint8_t   is_stall;       /*!< Endpoint stall condition
264                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
265 
266   uint8_t   type;           /*!< Endpoint type
267                                  This parameter can be any value of @ref USB_EP_Type                      */
268 
269   uint8_t   data_pid_start; /*!< Initial data PID
270                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
271 
272   uint16_t  pmaadress;      /*!< PMA Address
273                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
274 
275   uint16_t  pmaaddr0;       /*!< PMA Address0
276                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
277 
278   uint16_t  pmaaddr1;        /*!< PMA Address1
279                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
280 
281   uint8_t   doublebuffer;    /*!< Double buffer enable
282                                  This parameter can be 0 or 1                                             */
283 
284   uint16_t  tx_fifo_num;    /*!< This parameter is not required by USB Device FS peripheral, it is used
285                                  only by USB OTG FS peripheral
286                                  This parameter is added to ensure compatibility across USB peripherals   */
287 
288   uint32_t  maxpacket;      /*!< Endpoint Max packet size
289                                  This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
290 
291   uint8_t   *xfer_buff;     /*!< Pointer to transfer buffer                                               */
292 
293   uint32_t  xfer_len;       /*!< Current transfer length                                                  */
294 
295   uint32_t  xfer_count;     /*!< Partial transfer length in case of multi packet transfer                 */
296 
297 } USB_EPTypeDef;
298 #endif /* USB */
299 
300 /* Exported constants --------------------------------------------------------*/
301 
302 /** @defgroup PCD_Exported_Constants PCD Exported Constants
303   * @{
304   */
305 
306 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
307 /** @defgroup USB_Core_Mode_ USB Core Mode
308   * @{
309   */
310 #define USB_OTG_MODE_DEVICE                    0U
311 #define USB_OTG_MODE_HOST                      1U
312 #define USB_OTG_MODE_DRD                       2U
313 /**
314   * @}
315   */
316 
317 /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed
318   * @{
319   */
320 #define USB_OTG_SPEED_LOW                      2U
321 #define USB_OTG_SPEED_FULL                     3U
322 /**
323   * @}
324   */
325 
326 /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY
327   * @{
328   */
329 #define USB_OTG_ULPI_PHY                       1U
330 #define USB_OTG_EMBEDDED_PHY                   2U
331 /**
332   * @}
333   */
334 
335 /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS
336   * @{
337   */
338 #define USB_OTG_FS_MAX_PACKET_SIZE             64U
339 #define USB_OTG_MAX_EP0_SIZE                   64U
340 /**
341   * @}
342   */
343 
344 /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency
345   * @{
346   */
347 #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ     (0U << 1)
348 #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ     (1U << 1)
349 #define DSTS_ENUMSPD_LS_PHY_6MHZ               (2U << 1)
350 #define DSTS_ENUMSPD_FS_PHY_48MHZ              (3U << 1)
351 /**
352   * @}
353   */
354 
355 /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval
356   * @{
357   */
358 #define DCFG_FRAME_INTERVAL_80                 0U
359 #define DCFG_FRAME_INTERVAL_85                 1U
360 #define DCFG_FRAME_INTERVAL_90                 2U
361 #define DCFG_FRAME_INTERVAL_95                 3U
362 /**
363   * @}
364   */
365 
366 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
367   * @{
368   */
369 #define DEP0CTL_MPS_64                         0U
370 #define DEP0CTL_MPS_32                         1U
371 #define DEP0CTL_MPS_16                         2U
372 #define DEP0CTL_MPS_8                          3U
373 /**
374   * @}
375   */
376 
377 /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed
378   * @{
379   */
380 #define EP_SPEED_LOW                           0U
381 #define EP_SPEED_FULL                          1U
382 #define EP_SPEED_HIGH                          2U
383 /**
384   * @}
385   */
386 
387 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
388   * @{
389   */
390 #define EP_TYPE_CTRL                           0U
391 #define EP_TYPE_ISOC                           1U
392 #define EP_TYPE_BULK                           2U
393 #define EP_TYPE_INTR                           3U
394 #define EP_TYPE_MSK                            3U
395 /**
396   * @}
397   */
398 
399 /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines
400   * @{
401   */
402 #define STS_GOUT_NAK                           1U
403 #define STS_DATA_UPDT                          2U
404 #define STS_XFER_COMP                          3U
405 #define STS_SETUP_COMP                         4U
406 #define STS_SETUP_UPDT                         6U
407 /**
408   * @}
409   */
410 
411 /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines
412   * @{
413   */
414 #define HCFG_30_60_MHZ                         0U
415 #define HCFG_48_MHZ                            1U
416 #define HCFG_6_MHZ                             2U
417 /**
418   * @}
419   */
420 
421 /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines
422   * @{
423   */
424 #define HPRT0_PRTSPD_HIGH_SPEED                0U
425 #define HPRT0_PRTSPD_FULL_SPEED                1U
426 #define HPRT0_PRTSPD_LOW_SPEED                 2U
427 /**
428   * @}
429   */
430 
431 #define HCCHAR_CTRL                            0U
432 #define HCCHAR_ISOC                            1U
433 #define HCCHAR_BULK                            2U
434 #define HCCHAR_INTR                            3U
435 
436 #define HC_PID_DATA0                           0U
437 #define HC_PID_DATA2                           1U
438 #define HC_PID_DATA1                           2U
439 #define HC_PID_SETUP                           3U
440 
441 #define GRXSTS_PKTSTS_IN                       2U
442 #define GRXSTS_PKTSTS_IN_XFER_COMP             3U
443 #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR          5U
444 #define GRXSTS_PKTSTS_CH_HALTED                7U
445 
446 #define USBx_PCGCCTL    *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE)
447 #define USBx_HPRT0      *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE)
448 
449 #define USBx_DEVICE     ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE))
450 #define USBx_INEP(i)    ((USB_OTG_INEndpointTypeDef *)(USBx_BASE + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
451 #define USBx_OUTEP(i)   ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE)))
452 #define USBx_DFIFO(i)   *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE))
453 
454 #define USBx_HOST       ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE))
455 #define USBx_HC(i)      ((USB_OTG_HostChannelTypeDef *)(USBx_BASE + USB_OTG_HOST_CHANNEL_BASE + ((i) * USB_OTG_HOST_CHANNEL_SIZE)))
456 #endif /* USB_OTG_FS || USB_OTG_HS */
457 
458 #if defined (USB)
459 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
460   * @{
461   */
462 #define DEP0CTL_MPS_64                         0U
463 #define DEP0CTL_MPS_32                         1U
464 #define DEP0CTL_MPS_16                         2U
465 #define DEP0CTL_MPS_8                          3U
466 /**
467   * @}
468   */
469 
470 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
471   * @{
472   */
473 #define EP_TYPE_CTRL                           0U
474 #define EP_TYPE_ISOC                           1U
475 #define EP_TYPE_BULK                           2U
476 #define EP_TYPE_INTR                           3U
477 #define EP_TYPE_MSK                            3U
478 /**
479   * @}
480   */
481 
482 #define BTABLE_ADDRESS                         0x000U
483 #define PMA_ACCESS                             1U
484 #endif /* USB */
485 /**
486   * @}
487   */
488 
489 /* Exported macro ------------------------------------------------------------*/
490 /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros
491   * @{
492   */
493 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
494 #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)     ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
495 #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)   ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
496 
497 #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__)          (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
498 #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__)         (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
499 #endif /* USB_OTG_FS || USB_OTG_HS */
500 /**
501   * @}
502   */
503 
504 /* Exported functions --------------------------------------------------------*/
505 /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
506   * @{
507   */
508 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
509 HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
510 HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
511 HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
512 HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
513 HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_ModeTypeDef mode);
514 HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed);
515 HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx);
516 HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num);
517 HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
518 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
519 HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
520 HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
521 HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
522 HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
523 HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
524 void             *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
525 HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
526 HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
527 HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address);
528 HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx);
529 HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx);
530 HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
531 HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx);
532 HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup);
533 uint8_t           USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
534 uint32_t          USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
535 uint32_t          USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx);
536 uint32_t          USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
537 uint32_t          USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
538 uint32_t          USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx);
539 uint32_t          USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum);
540 void              USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
541 
542 HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
543 HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq);
544 HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
545 HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state);
546 uint32_t          USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx);
547 uint32_t          USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx);
548 HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
549                               uint8_t ch_num,
550                               uint8_t epnum,
551                               uint8_t dev_address,
552                               uint8_t speed,
553                               uint8_t ep_type,
554                               uint16_t mps);
555 HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc);
556 uint32_t          USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx);
557 HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num);
558 HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num);
559 HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
560 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
561 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
562 #endif /* USB_OTG_FS || USB_OTG_HS */
563 
564 #if defined (USB)
565 HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef Init);
566 HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef Init);
567 HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
568 HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
569 HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);
570 HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed);
571 HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx);
572 HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num);
573 HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
574 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
575 HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep);
576 HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
577 void             *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len);
578 HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
579 HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
580 HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address);
581 HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx);
582 HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx);
583 HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
584 HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup);
585 uint32_t          USB_ReadInterrupts(USB_TypeDef *USBx);
586 uint32_t          USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx);
587 uint32_t          USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
588 uint32_t          USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx);
589 uint32_t          USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
590 void              USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt);
591 
592 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
593 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
594 void USB_WritePMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
595 void USB_ReadPMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
596 #endif /* USB */
597 /**
598   * @}
599   */
600 
601 /**
602   * @}
603   */
604 
605 /**
606   * @}
607   */
608 
609 /**
610   * @}
611   */
612 
613 #endif /* defined (USB) || defined (USB_OTG_FS) || defined (USB_OTG_HS) */
614 
615 #ifdef __cplusplus
616 }
617 #endif
618 
619 
620 #endif /* __STM32L4xx_LL_USB_H */
621 
622 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
623