Implement a secure ICS protocol targeting LoRa Node151 microcontroller for controlling irrigation.
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
 
 
 
 

679 lines
26 KiB

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