stm32f1xx_ll_usb.h 26 KB

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