stm32f1xx_ll_usb.h 24 KB

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