stm32l4xx_ll_usb.h 27 KB

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