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.
 
 
 

939 lines
33 KiB

  1. /**
  2. ******************************************************************************
  3. * @file stm32l1xx_hal_pcd.h
  4. * @author MCD Application Team
  5. * @brief Header file of PCD 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 STM32L1xx_HAL_PCD_H
  21. #define STM32L1xx_HAL_PCD_H
  22. #ifdef __cplusplus
  23. extern "C" {
  24. #endif
  25. /* Includes ------------------------------------------------------------------*/
  26. #include "stm32l1xx_ll_usb.h"
  27. #if defined (USB)
  28. /** @addtogroup STM32L1xx_HAL_Driver
  29. * @{
  30. */
  31. /** @addtogroup PCD
  32. * @{
  33. */
  34. /* Exported types ------------------------------------------------------------*/
  35. /** @defgroup PCD_Exported_Types PCD Exported Types
  36. * @{
  37. */
  38. /**
  39. * @brief PCD State structure definition
  40. */
  41. typedef enum
  42. {
  43. HAL_PCD_STATE_RESET = 0x00,
  44. HAL_PCD_STATE_READY = 0x01,
  45. HAL_PCD_STATE_ERROR = 0x02,
  46. HAL_PCD_STATE_BUSY = 0x03,
  47. HAL_PCD_STATE_TIMEOUT = 0x04
  48. } PCD_StateTypeDef;
  49. /* Device LPM suspend state */
  50. typedef enum
  51. {
  52. LPM_L0 = 0x00, /* on */
  53. LPM_L1 = 0x01, /* LPM L1 sleep */
  54. LPM_L2 = 0x02, /* suspend */
  55. LPM_L3 = 0x03, /* off */
  56. } PCD_LPM_StateTypeDef;
  57. typedef enum
  58. {
  59. PCD_LPM_L0_ACTIVE = 0x00, /* on */
  60. PCD_LPM_L1_ACTIVE = 0x01, /* LPM L1 sleep */
  61. } PCD_LPM_MsgTypeDef;
  62. typedef enum
  63. {
  64. PCD_BCD_ERROR = 0xFF,
  65. PCD_BCD_CONTACT_DETECTION = 0xFE,
  66. PCD_BCD_STD_DOWNSTREAM_PORT = 0xFD,
  67. PCD_BCD_CHARGING_DOWNSTREAM_PORT = 0xFC,
  68. PCD_BCD_DEDICATED_CHARGING_PORT = 0xFB,
  69. PCD_BCD_DISCOVERY_COMPLETED = 0x00,
  70. } PCD_BCD_MsgTypeDef;
  71. typedef USB_TypeDef PCD_TypeDef;
  72. typedef USB_CfgTypeDef PCD_InitTypeDef;
  73. typedef USB_EPTypeDef PCD_EPTypeDef;
  74. /**
  75. * @brief PCD Handle Structure definition
  76. */
  77. #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
  78. typedef struct __PCD_HandleTypeDef
  79. #else
  80. typedef struct
  81. #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
  82. {
  83. PCD_TypeDef *Instance; /*!< Register base address */
  84. PCD_InitTypeDef Init; /*!< PCD required parameters */
  85. __IO uint8_t USB_Address; /*!< USB Address */
  86. PCD_EPTypeDef IN_ep[8]; /*!< IN endpoint parameters */
  87. PCD_EPTypeDef OUT_ep[8]; /*!< OUT endpoint parameters */
  88. HAL_LockTypeDef Lock; /*!< PCD peripheral status */
  89. __IO PCD_StateTypeDef State; /*!< PCD communication state */
  90. __IO uint32_t ErrorCode; /*!< PCD Error code */
  91. uint32_t Setup[12]; /*!< Setup packet buffer */
  92. PCD_LPM_StateTypeDef LPM_State; /*!< LPM State */
  93. uint32_t BESL;
  94. void *pData; /*!< Pointer to upper stack Handler */
  95. #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
  96. void (* SOFCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD SOF callback */
  97. void (* SetupStageCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Setup Stage callback */
  98. void (* ResetCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Reset callback */
  99. void (* SuspendCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Suspend callback */
  100. void (* ResumeCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Resume callback */
  101. void (* ConnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Connect callback */
  102. void (* DisconnectCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Disconnect callback */
  103. void (* DataOutStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data OUT Stage callback */
  104. void (* DataInStageCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD Data IN Stage callback */
  105. void (* ISOOUTIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO OUT Incomplete callback */
  106. void (* ISOINIncompleteCallback)(struct __PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< USB OTG PCD ISO IN Incomplete callback */
  107. void (* MspInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp Init callback */
  108. void (* MspDeInitCallback)(struct __PCD_HandleTypeDef *hpcd); /*!< USB OTG PCD Msp DeInit callback */
  109. #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
  110. } PCD_HandleTypeDef;
  111. /**
  112. * @}
  113. */
  114. /* Include PCD HAL Extended module */
  115. #include "stm32l1xx_hal_pcd_ex.h"
  116. /* Exported constants --------------------------------------------------------*/
  117. /** @defgroup PCD_Exported_Constants PCD Exported Constants
  118. * @{
  119. */
  120. /** @defgroup PCD_Speed PCD Speed
  121. * @{
  122. */
  123. #define PCD_SPEED_FULL USBD_FS_SPEED
  124. /**
  125. * @}
  126. */
  127. /** @defgroup PCD_PHY_Module PCD PHY Module
  128. * @{
  129. */
  130. #define PCD_PHY_ULPI 1U
  131. #define PCD_PHY_EMBEDDED 2U
  132. #define PCD_PHY_UTMI 3U
  133. /**
  134. * @}
  135. */
  136. /** @defgroup PCD_Error_Code_definition PCD Error Code definition
  137. * @brief PCD Error Code definition
  138. * @{
  139. */
  140. #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
  141. #define HAL_PCD_ERROR_INVALID_CALLBACK (0x00000010U) /*!< Invalid Callback error */
  142. #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
  143. /**
  144. * @}
  145. */
  146. /**
  147. * @}
  148. */
  149. /* Exported macros -----------------------------------------------------------*/
  150. /** @defgroup PCD_Exported_Macros PCD Exported Macros
  151. * @brief macros to handle interrupts and specific clock configurations
  152. * @{
  153. */
  154. #define __HAL_PCD_ENABLE(__HANDLE__) (void)USB_EnableGlobalInt ((__HANDLE__)->Instance)
  155. #define __HAL_PCD_DISABLE(__HANDLE__) (void)USB_DisableGlobalInt ((__HANDLE__)->Instance)
  156. #define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
  157. #define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->ISTR) &= (uint16_t)(~(__INTERRUPT__)))
  158. #define __HAL_USB_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= USB_WAKEUP_EXTI_LINE
  159. #define __HAL_USB_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_WAKEUP_EXTI_LINE)
  160. #define __HAL_USB_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (USB_WAKEUP_EXTI_LINE)
  161. #define __HAL_USB_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = USB_WAKEUP_EXTI_LINE
  162. #define __HAL_USB_WAKEUP_EXTI_ENABLE_RISING_EDGE() \
  163. do { \
  164. EXTI->FTSR &= ~(USB_WAKEUP_EXTI_LINE); \
  165. EXTI->RTSR |= USB_WAKEUP_EXTI_LINE; \
  166. } while(0U)
  167. /**
  168. * @}
  169. */
  170. /* Exported functions --------------------------------------------------------*/
  171. /** @addtogroup PCD_Exported_Functions PCD Exported Functions
  172. * @{
  173. */
  174. /* Initialization/de-initialization functions ********************************/
  175. /** @addtogroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions
  176. * @{
  177. */
  178. HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd);
  179. HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd);
  180. void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd);
  181. void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd);
  182. #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
  183. /** @defgroup HAL_PCD_Callback_ID_enumeration_definition HAL USB OTG PCD Callback ID enumeration definition
  184. * @brief HAL USB OTG PCD Callback ID enumeration definition
  185. * @{
  186. */
  187. typedef enum
  188. {
  189. HAL_PCD_SOF_CB_ID = 0x01, /*!< USB PCD SOF callback ID */
  190. HAL_PCD_SETUPSTAGE_CB_ID = 0x02, /*!< USB PCD Setup Stage callback ID */
  191. HAL_PCD_RESET_CB_ID = 0x03, /*!< USB PCD Reset callback ID */
  192. HAL_PCD_SUSPEND_CB_ID = 0x04, /*!< USB PCD Suspend callback ID */
  193. HAL_PCD_RESUME_CB_ID = 0x05, /*!< USB PCD Resume callback ID */
  194. HAL_PCD_CONNECT_CB_ID = 0x06, /*!< USB PCD Connect callback ID */
  195. HAL_PCD_DISCONNECT_CB_ID = 0x07, /*!< USB PCD Disconnect callback ID */
  196. HAL_PCD_MSPINIT_CB_ID = 0x08, /*!< USB PCD MspInit callback ID */
  197. HAL_PCD_MSPDEINIT_CB_ID = 0x09 /*!< USB PCD MspDeInit callback ID */
  198. } HAL_PCD_CallbackIDTypeDef;
  199. /**
  200. * @}
  201. */
  202. /** @defgroup HAL_PCD_Callback_pointer_definition HAL USB OTG PCD Callback pointer definition
  203. * @brief HAL USB OTG PCD Callback pointer definition
  204. * @{
  205. */
  206. typedef void (*pPCD_CallbackTypeDef)(PCD_HandleTypeDef *hpcd); /*!< pointer to a common USB OTG PCD callback function */
  207. typedef void (*pPCD_DataOutStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data OUT Stage callback */
  208. typedef void (*pPCD_DataInStageCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD Data IN Stage callback */
  209. typedef void (*pPCD_IsoOutIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO OUT Incomplete callback */
  210. typedef void (*pPCD_IsoInIncpltCallbackTypeDef)(PCD_HandleTypeDef *hpcd, uint8_t epnum); /*!< pointer to USB OTG PCD ISO IN Incomplete callback */
  211. /**
  212. * @}
  213. */
  214. HAL_StatusTypeDef HAL_PCD_RegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID, pPCD_CallbackTypeDef pCallback);
  215. HAL_StatusTypeDef HAL_PCD_UnRegisterCallback(PCD_HandleTypeDef *hpcd, HAL_PCD_CallbackIDTypeDef CallbackID);
  216. HAL_StatusTypeDef HAL_PCD_RegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd, pPCD_DataOutStageCallbackTypeDef pCallback);
  217. HAL_StatusTypeDef HAL_PCD_UnRegisterDataOutStageCallback(PCD_HandleTypeDef *hpcd);
  218. HAL_StatusTypeDef HAL_PCD_RegisterDataInStageCallback(PCD_HandleTypeDef *hpcd, pPCD_DataInStageCallbackTypeDef pCallback);
  219. HAL_StatusTypeDef HAL_PCD_UnRegisterDataInStageCallback(PCD_HandleTypeDef *hpcd);
  220. HAL_StatusTypeDef HAL_PCD_RegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd, pPCD_IsoOutIncpltCallbackTypeDef pCallback);
  221. HAL_StatusTypeDef HAL_PCD_UnRegisterIsoOutIncpltCallback(PCD_HandleTypeDef *hpcd);
  222. HAL_StatusTypeDef HAL_PCD_RegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd, pPCD_IsoInIncpltCallbackTypeDef pCallback);
  223. HAL_StatusTypeDef HAL_PCD_UnRegisterIsoInIncpltCallback(PCD_HandleTypeDef *hpcd);
  224. #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
  225. /**
  226. * @}
  227. */
  228. /* I/O operation functions ***************************************************/
  229. /* Non-Blocking mode: Interrupt */
  230. /** @addtogroup PCD_Exported_Functions_Group2 Input and Output operation functions
  231. * @{
  232. */
  233. HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd);
  234. HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd);
  235. void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd);
  236. void HAL_PCD_WKUP_IRQHandler(PCD_HandleTypeDef *hpcd);
  237. void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd);
  238. void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd);
  239. void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd);
  240. void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd);
  241. void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd);
  242. void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd);
  243. void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd);
  244. void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
  245. void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
  246. void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
  247. void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
  248. /**
  249. * @}
  250. */
  251. /* Peripheral Control functions **********************************************/
  252. /** @addtogroup PCD_Exported_Functions_Group3 Peripheral Control functions
  253. * @{
  254. */
  255. HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd);
  256. HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd);
  257. HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address);
  258. HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type);
  259. HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
  260. HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
  261. HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
  262. uint32_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
  263. HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
  264. HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
  265. HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
  266. HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
  267. HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
  268. /**
  269. * @}
  270. */
  271. /* Peripheral State functions ************************************************/
  272. /** @addtogroup PCD_Exported_Functions_Group4 Peripheral State functions
  273. * @{
  274. */
  275. PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd);
  276. /**
  277. * @}
  278. */
  279. /**
  280. * @}
  281. */
  282. /* Private constants ---------------------------------------------------------*/
  283. /** @defgroup PCD_Private_Constants PCD Private Constants
  284. * @{
  285. */
  286. /** @defgroup USB_EXTI_Line_Interrupt USB EXTI line interrupt
  287. * @{
  288. */
  289. #define USB_WAKEUP_EXTI_LINE (0x1U << 18) /*!< USB FS EXTI Line WakeUp Interrupt */
  290. /**
  291. * @}
  292. */
  293. /** @defgroup PCD_EP0_MPS PCD EP0 MPS
  294. * @{
  295. */
  296. #define PCD_EP0MPS_64 EP_MPS_64
  297. #define PCD_EP0MPS_32 EP_MPS_32
  298. #define PCD_EP0MPS_16 EP_MPS_16
  299. #define PCD_EP0MPS_08 EP_MPS_8
  300. /**
  301. * @}
  302. */
  303. /** @defgroup PCD_ENDP PCD ENDP
  304. * @{
  305. */
  306. #define PCD_ENDP0 0U
  307. #define PCD_ENDP1 1U
  308. #define PCD_ENDP2 2U
  309. #define PCD_ENDP3 3U
  310. #define PCD_ENDP4 4U
  311. #define PCD_ENDP5 5U
  312. #define PCD_ENDP6 6U
  313. #define PCD_ENDP7 7U
  314. /**
  315. * @}
  316. */
  317. /** @defgroup PCD_ENDP_Kind PCD Endpoint Kind
  318. * @{
  319. */
  320. #define PCD_SNG_BUF 0U
  321. #define PCD_DBL_BUF 1U
  322. /**
  323. * @}
  324. */
  325. /**
  326. * @}
  327. */
  328. /* Private macros ------------------------------------------------------------*/
  329. /** @defgroup PCD_Private_Macros PCD Private Macros
  330. * @{
  331. */
  332. /******************** Bit definition for USB_COUNTn_RX register *************/
  333. #define USB_CNTRX_NBLK_MSK (0x1FU << 10)
  334. #define USB_CNTRX_BLSIZE (0x1U << 15)
  335. /* SetENDPOINT */
  336. #define PCD_SET_ENDPOINT(USBx, bEpNum, wRegValue) (*(__IO uint16_t *)(&(USBx)->EP0R + ((bEpNum) * 2U)) = (uint16_t)(wRegValue))
  337. /* GetENDPOINT */
  338. #define PCD_GET_ENDPOINT(USBx, bEpNum) (*(__IO uint16_t *)(&(USBx)->EP0R + ((bEpNum) * 2U)))
  339. /* ENDPOINT transfer */
  340. #define USB_EP0StartXfer USB_EPStartXfer
  341. /**
  342. * @brief sets the type in the endpoint register(bits EP_TYPE[1:0])
  343. * @param USBx USB peripheral instance register address.
  344. * @param bEpNum Endpoint Number.
  345. * @param wType Endpoint Type.
  346. * @retval None
  347. */
  348. #define PCD_SET_EPTYPE(USBx, bEpNum, wType) (PCD_SET_ENDPOINT((USBx), (bEpNum), \
  349. ((PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_MASK) | (wType) | USB_EP_CTR_TX | USB_EP_CTR_RX)))
  350. /**
  351. * @brief gets the type in the endpoint register(bits EP_TYPE[1:0])
  352. * @param USBx USB peripheral instance register address.
  353. * @param bEpNum Endpoint Number.
  354. * @retval Endpoint Type
  355. */
  356. #define PCD_GET_EPTYPE(USBx, bEpNum) (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_FIELD)
  357. /**
  358. * @brief free buffer used from the application realizing it to the line
  359. * toggles bit SW_BUF in the double buffered endpoint register
  360. * @param USBx USB device.
  361. * @param bEpNum, bDir
  362. * @retval None
  363. */
  364. #define PCD_FreeUserBuffer(USBx, bEpNum, bDir) do { \
  365. if ((bDir) == 0U) \
  366. { \
  367. /* OUT double buffered endpoint */ \
  368. PCD_TX_DTOG((USBx), (bEpNum)); \
  369. } \
  370. else if ((bDir) == 1U) \
  371. { \
  372. /* IN double buffered endpoint */ \
  373. PCD_RX_DTOG((USBx), (bEpNum)); \
  374. } \
  375. } while(0)
  376. /**
  377. * @brief sets the status for tx transfer (bits STAT_TX[1:0]).
  378. * @param USBx USB peripheral instance register address.
  379. * @param bEpNum Endpoint Number.
  380. * @param wState new state
  381. * @retval None
  382. */
  383. #define PCD_SET_EP_TX_STATUS(USBx, bEpNum, wState) do { \
  384. uint16_t _wRegVal; \
  385. \
  386. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_DTOGMASK; \
  387. /* toggle first bit ? */ \
  388. if ((USB_EPTX_DTOG1 & (wState))!= 0U) \
  389. { \
  390. _wRegVal ^= USB_EPTX_DTOG1; \
  391. } \
  392. /* toggle second bit ? */ \
  393. if ((USB_EPTX_DTOG2 & (wState))!= 0U) \
  394. { \
  395. _wRegVal ^= USB_EPTX_DTOG2; \
  396. } \
  397. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \
  398. } while(0) /* PCD_SET_EP_TX_STATUS */
  399. /**
  400. * @brief sets the status for rx transfer (bits STAT_TX[1:0])
  401. * @param USBx USB peripheral instance register address.
  402. * @param bEpNum Endpoint Number.
  403. * @param wState new state
  404. * @retval None
  405. */
  406. #define PCD_SET_EP_RX_STATUS(USBx, bEpNum,wState) do { \
  407. uint16_t _wRegVal; \
  408. \
  409. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_DTOGMASK; \
  410. /* toggle first bit ? */ \
  411. if ((USB_EPRX_DTOG1 & (wState))!= 0U) \
  412. { \
  413. _wRegVal ^= USB_EPRX_DTOG1; \
  414. } \
  415. /* toggle second bit ? */ \
  416. if ((USB_EPRX_DTOG2 & (wState))!= 0U) \
  417. { \
  418. _wRegVal ^= USB_EPRX_DTOG2; \
  419. } \
  420. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \
  421. } while(0) /* PCD_SET_EP_RX_STATUS */
  422. /**
  423. * @brief sets the status for rx & tx (bits STAT_TX[1:0] & STAT_RX[1:0])
  424. * @param USBx USB peripheral instance register address.
  425. * @param bEpNum Endpoint Number.
  426. * @param wStaterx new state.
  427. * @param wStatetx new state.
  428. * @retval None
  429. */
  430. #define PCD_SET_EP_TXRX_STATUS(USBx, bEpNum, wStaterx, wStatetx) do { \
  431. uint16_t _wRegVal; \
  432. \
  433. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (USB_EPRX_DTOGMASK | USB_EPTX_STAT); \
  434. /* toggle first bit ? */ \
  435. if ((USB_EPRX_DTOG1 & (wStaterx))!= 0U) \
  436. { \
  437. _wRegVal ^= USB_EPRX_DTOG1; \
  438. } \
  439. /* toggle second bit ? */ \
  440. if ((USB_EPRX_DTOG2 & (wStaterx))!= 0U) \
  441. { \
  442. _wRegVal ^= USB_EPRX_DTOG2; \
  443. } \
  444. /* toggle first bit ? */ \
  445. if ((USB_EPTX_DTOG1 & (wStatetx))!= 0U) \
  446. { \
  447. _wRegVal ^= USB_EPTX_DTOG1; \
  448. } \
  449. /* toggle second bit ? */ \
  450. if ((USB_EPTX_DTOG2 & (wStatetx))!= 0U) \
  451. { \
  452. _wRegVal ^= USB_EPTX_DTOG2; \
  453. } \
  454. \
  455. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \
  456. } while(0) /* PCD_SET_EP_TXRX_STATUS */
  457. /**
  458. * @brief gets the status for tx/rx transfer (bits STAT_TX[1:0]
  459. * /STAT_RX[1:0])
  460. * @param USBx USB peripheral instance register address.
  461. * @param bEpNum Endpoint Number.
  462. * @retval status
  463. */
  464. #define PCD_GET_EP_TX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_STAT)
  465. #define PCD_GET_EP_RX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_STAT)
  466. /**
  467. * @brief sets directly the VALID tx/rx-status into the endpoint register
  468. * @param USBx USB peripheral instance register address.
  469. * @param bEpNum Endpoint Number.
  470. * @retval None
  471. */
  472. #define PCD_SET_EP_TX_VALID(USBx, bEpNum) (PCD_SET_EP_TX_STATUS((USBx), (bEpNum), USB_EP_TX_VALID))
  473. #define PCD_SET_EP_RX_VALID(USBx, bEpNum) (PCD_SET_EP_RX_STATUS((USBx), (bEpNum), USB_EP_RX_VALID))
  474. /**
  475. * @brief checks stall condition in an endpoint.
  476. * @param USBx USB peripheral instance register address.
  477. * @param bEpNum Endpoint Number.
  478. * @retval TRUE = endpoint in stall condition.
  479. */
  480. #define PCD_GET_EP_TX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_TX_STATUS((USBx), (bEpNum)) == USB_EP_TX_STALL)
  481. #define PCD_GET_EP_RX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_RX_STATUS((USBx), (bEpNum)) == USB_EP_RX_STALL)
  482. /**
  483. * @brief set & clear EP_KIND bit.
  484. * @param USBx USB peripheral instance register address.
  485. * @param bEpNum Endpoint Number.
  486. * @retval None
  487. */
  488. #define PCD_SET_EP_KIND(USBx, bEpNum) do { \
  489. uint16_t _wRegVal; \
  490. \
  491. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \
  492. \
  493. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_KIND)); \
  494. } while(0) /* PCD_SET_EP_KIND */
  495. #define PCD_CLEAR_EP_KIND(USBx, bEpNum) do { \
  496. uint16_t _wRegVal; \
  497. \
  498. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPKIND_MASK; \
  499. \
  500. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \
  501. } while(0) /* PCD_CLEAR_EP_KIND */
  502. /**
  503. * @brief Sets/clears directly STATUS_OUT bit in the endpoint register.
  504. * @param USBx USB peripheral instance register address.
  505. * @param bEpNum Endpoint Number.
  506. * @retval None
  507. */
  508. #define PCD_SET_OUT_STATUS(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum))
  509. #define PCD_CLEAR_OUT_STATUS(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum))
  510. /**
  511. * @brief Sets/clears directly EP_KIND bit in the endpoint register.
  512. * @param USBx USB peripheral instance register address.
  513. * @param bEpNum Endpoint Number.
  514. * @retval None
  515. */
  516. #define PCD_SET_EP_DBUF(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum))
  517. #define PCD_CLEAR_EP_DBUF(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum))
  518. /**
  519. * @brief Clears bit CTR_RX / CTR_TX in the endpoint register.
  520. * @param USBx USB peripheral instance register address.
  521. * @param bEpNum Endpoint Number.
  522. * @retval None
  523. */
  524. #define PCD_CLEAR_RX_EP_CTR(USBx, bEpNum) do { \
  525. uint16_t _wRegVal; \
  526. \
  527. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (0x7FFFU & USB_EPREG_MASK); \
  528. \
  529. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_TX)); \
  530. } while(0) /* PCD_CLEAR_RX_EP_CTR */
  531. #define PCD_CLEAR_TX_EP_CTR(USBx, bEpNum) do { \
  532. uint16_t _wRegVal; \
  533. \
  534. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (0xFF7FU & USB_EPREG_MASK); \
  535. \
  536. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX)); \
  537. } while(0) /* PCD_CLEAR_TX_EP_CTR */
  538. /**
  539. * @brief Toggles DTOG_RX / DTOG_TX bit in the endpoint register.
  540. * @param USBx USB peripheral instance register address.
  541. * @param bEpNum Endpoint Number.
  542. * @retval None
  543. */
  544. #define PCD_RX_DTOG(USBx, bEpNum) do { \
  545. uint16_t _wEPVal; \
  546. \
  547. _wEPVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \
  548. \
  549. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wEPVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_DTOG_RX)); \
  550. } while(0) /* PCD_RX_DTOG */
  551. #define PCD_TX_DTOG(USBx, bEpNum) do { \
  552. uint16_t _wEPVal; \
  553. \
  554. _wEPVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK; \
  555. \
  556. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wEPVal | USB_EP_CTR_RX | USB_EP_CTR_TX | USB_EP_DTOG_TX)); \
  557. } while(0) /* PCD_TX_DTOG */
  558. /**
  559. * @brief Clears DTOG_RX / DTOG_TX bit in the endpoint register.
  560. * @param USBx USB peripheral instance register address.
  561. * @param bEpNum Endpoint Number.
  562. * @retval None
  563. */
  564. #define PCD_CLEAR_RX_DTOG(USBx, bEpNum) do { \
  565. uint16_t _wRegVal; \
  566. \
  567. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)); \
  568. \
  569. if ((_wRegVal & USB_EP_DTOG_RX) != 0U)\
  570. { \
  571. PCD_RX_DTOG((USBx), (bEpNum)); \
  572. } \
  573. } while(0) /* PCD_CLEAR_RX_DTOG */
  574. #define PCD_CLEAR_TX_DTOG(USBx, bEpNum) do { \
  575. uint16_t _wRegVal; \
  576. \
  577. _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)); \
  578. \
  579. if ((_wRegVal & USB_EP_DTOG_TX) != 0U)\
  580. { \
  581. PCD_TX_DTOG((USBx), (bEpNum)); \
  582. } \
  583. } while(0) /* PCD_CLEAR_TX_DTOG */
  584. /**
  585. * @brief Sets address in an endpoint register.
  586. * @param USBx USB peripheral instance register address.
  587. * @param bEpNum Endpoint Number.
  588. * @param bAddr Address.
  589. * @retval None
  590. */
  591. #define PCD_SET_EP_ADDRESS(USBx, bEpNum, bAddr) do { \
  592. uint16_t _wRegVal; \
  593. \
  594. _wRegVal = (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK) | (bAddr); \
  595. \
  596. PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX | USB_EP_CTR_TX)); \
  597. } while(0) /* PCD_SET_EP_ADDRESS */
  598. /**
  599. * @brief Gets address in an endpoint register.
  600. * @param USBx USB peripheral instance register address.
  601. * @param bEpNum Endpoint Number.
  602. * @retval None
  603. */
  604. #define PCD_GET_EP_ADDRESS(USBx, bEpNum) ((uint8_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPADDR_FIELD))
  605. #define PCD_EP_TX_CNT(USBx, bEpNum) ((uint16_t *)((((uint32_t)(USBx)->BTABLE + ((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS) + ((uint32_t)(USBx) + 0x400U)))
  606. #define PCD_EP_RX_CNT(USBx, bEpNum) ((uint16_t *)((((uint32_t)(USBx)->BTABLE + ((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS) + ((uint32_t)(USBx) + 0x400U)))
  607. /**
  608. * @brief sets address of the tx/rx buffer.
  609. * @param USBx USB peripheral instance register address.
  610. * @param bEpNum Endpoint Number.
  611. * @param wAddr address to be set (must be word aligned).
  612. * @retval None
  613. */
  614. #define PCD_SET_EP_TX_ADDRESS(USBx, bEpNum, wAddr) do { \
  615. __IO uint16_t *_wRegVal; \
  616. uint32_t _wRegBase = (uint32_t)USBx; \
  617. \
  618. _wRegBase += (uint32_t)(USBx)->BTABLE; \
  619. _wRegVal = (__IO uint16_t *)(_wRegBase + 0x400U + (((uint32_t)(bEpNum) * 8U) * PMA_ACCESS)); \
  620. *_wRegVal = ((wAddr) >> 1) << 1; \
  621. } while(0) /* PCD_SET_EP_TX_ADDRESS */
  622. #define PCD_SET_EP_RX_ADDRESS(USBx, bEpNum, wAddr) do { \
  623. __IO uint16_t *_wRegVal; \
  624. uint32_t _wRegBase = (uint32_t)USBx; \
  625. \
  626. _wRegBase += (uint32_t)(USBx)->BTABLE; \
  627. _wRegVal = (__IO uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 4U) * PMA_ACCESS)); \
  628. *_wRegVal = ((wAddr) >> 1) << 1; \
  629. } while(0) /* PCD_SET_EP_RX_ADDRESS */
  630. /**
  631. * @brief Gets address of the tx/rx buffer.
  632. * @param USBx USB peripheral instance register address.
  633. * @param bEpNum Endpoint Number.
  634. * @retval address of the buffer.
  635. */
  636. #define PCD_GET_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_TX_ADDRESS((USBx), (bEpNum)))
  637. #define PCD_GET_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_RX_ADDRESS((USBx), (bEpNum)))
  638. /**
  639. * @brief Sets counter of rx buffer with no. of blocks.
  640. * @param pdwReg Register pointer
  641. * @param wCount Counter.
  642. * @param wNBlocks no. of Blocks.
  643. * @retval None
  644. */
  645. #define PCD_CALC_BLK32(pdwReg, wCount, wNBlocks) do { \
  646. (wNBlocks) = (wCount) >> 5; \
  647. if (((wCount) & 0x1fU) == 0U) \
  648. { \
  649. (wNBlocks)--; \
  650. } \
  651. *(pdwReg) = (uint16_t)(((wNBlocks) << 10) | USB_CNTRX_BLSIZE); \
  652. } while(0) /* PCD_CALC_BLK32 */
  653. #define PCD_CALC_BLK2(pdwReg, wCount, wNBlocks) do { \
  654. (wNBlocks) = (wCount) >> 1; \
  655. if (((wCount) & 0x1U) != 0U) \
  656. { \
  657. (wNBlocks)++; \
  658. } \
  659. *(pdwReg) = (uint16_t)((wNBlocks) << 10); \
  660. } while(0) /* PCD_CALC_BLK2 */
  661. #define PCD_SET_EP_CNT_RX_REG(pdwReg, wCount) do { \
  662. uint32_t wNBlocks; \
  663. if ((wCount) == 0U) \
  664. { \
  665. *(pdwReg) &= (uint16_t)~USB_CNTRX_NBLK_MSK; \
  666. *(pdwReg) |= USB_CNTRX_BLSIZE; \
  667. } \
  668. else if((wCount) <= 62U) \
  669. { \
  670. PCD_CALC_BLK2((pdwReg), (wCount), wNBlocks); \
  671. } \
  672. else \
  673. { \
  674. PCD_CALC_BLK32((pdwReg), (wCount), wNBlocks); \
  675. } \
  676. } while(0) /* PCD_SET_EP_CNT_RX_REG */
  677. #define PCD_SET_EP_RX_DBUF0_CNT(USBx, bEpNum, wCount) do { \
  678. uint32_t _wRegBase = (uint32_t)(USBx); \
  679. __IO uint16_t *pdwReg; \
  680. \
  681. _wRegBase += (uint32_t)(USBx)->BTABLE; \
  682. pdwReg = (__IO uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS)); \
  683. PCD_SET_EP_CNT_RX_REG(pdwReg, (wCount)); \
  684. } while(0)
  685. /**
  686. * @brief sets counter for the tx/rx buffer.
  687. * @param USBx USB peripheral instance register address.
  688. * @param bEpNum Endpoint Number.
  689. * @param wCount Counter value.
  690. * @retval None
  691. */
  692. #define PCD_SET_EP_TX_CNT(USBx, bEpNum, wCount) do { \
  693. uint32_t _wRegBase = (uint32_t)(USBx); \
  694. __IO uint16_t *_wRegVal; \
  695. \
  696. _wRegBase += (uint32_t)(USBx)->BTABLE; \
  697. _wRegVal = (__IO uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 2U) * PMA_ACCESS)); \
  698. *_wRegVal = (uint16_t)(wCount); \
  699. } while(0)
  700. #define PCD_SET_EP_RX_CNT(USBx, bEpNum, wCount) do { \
  701. uint32_t _wRegBase = (uint32_t)(USBx); \
  702. __IO uint16_t *_wRegVal; \
  703. \
  704. _wRegBase += (uint32_t)(USBx)->BTABLE; \
  705. _wRegVal = (__IO uint16_t *)(_wRegBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS)); \
  706. PCD_SET_EP_CNT_RX_REG(_wRegVal, (wCount)); \
  707. } while(0)
  708. /**
  709. * @brief gets counter of the tx buffer.
  710. * @param USBx USB peripheral instance register address.
  711. * @param bEpNum Endpoint Number.
  712. * @retval Counter value
  713. */
  714. #define PCD_GET_EP_TX_CNT(USBx, bEpNum) ((uint32_t)(*PCD_EP_TX_CNT((USBx), (bEpNum))) & 0x3ffU)
  715. #define PCD_GET_EP_RX_CNT(USBx, bEpNum) ((uint32_t)(*PCD_EP_RX_CNT((USBx), (bEpNum))) & 0x3ffU)
  716. /**
  717. * @brief Sets buffer 0/1 address in a double buffer endpoint.
  718. * @param USBx USB peripheral instance register address.
  719. * @param bEpNum Endpoint Number.
  720. * @param wBuf0Addr buffer 0 address.
  721. * @retval Counter value
  722. */
  723. #define PCD_SET_EP_DBUF0_ADDR(USBx, bEpNum, wBuf0Addr) do { \
  724. PCD_SET_EP_TX_ADDRESS((USBx), (bEpNum), (wBuf0Addr)); \
  725. } while(0) /* PCD_SET_EP_DBUF0_ADDR */
  726. #define PCD_SET_EP_DBUF1_ADDR(USBx, bEpNum, wBuf1Addr) do { \
  727. PCD_SET_EP_RX_ADDRESS((USBx), (bEpNum), (wBuf1Addr)); \
  728. } while(0) /* PCD_SET_EP_DBUF1_ADDR */
  729. /**
  730. * @brief Sets addresses in a double buffer endpoint.
  731. * @param USBx USB peripheral instance register address.
  732. * @param bEpNum Endpoint Number.
  733. * @param wBuf0Addr: buffer 0 address.
  734. * @param wBuf1Addr = buffer 1 address.
  735. * @retval None
  736. */
  737. #define PCD_SET_EP_DBUF_ADDR(USBx, bEpNum, wBuf0Addr, wBuf1Addr) do { \
  738. PCD_SET_EP_DBUF0_ADDR((USBx), (bEpNum), (wBuf0Addr)); \
  739. PCD_SET_EP_DBUF1_ADDR((USBx), (bEpNum), (wBuf1Addr)); \
  740. } while(0) /* PCD_SET_EP_DBUF_ADDR */
  741. /**
  742. * @brief Gets buffer 0/1 address of a double buffer endpoint.
  743. * @param USBx USB peripheral instance register address.
  744. * @param bEpNum Endpoint Number.
  745. * @retval None
  746. */
  747. #define PCD_GET_EP_DBUF0_ADDR(USBx, bEpNum) (PCD_GET_EP_TX_ADDRESS((USBx), (bEpNum)))
  748. #define PCD_GET_EP_DBUF1_ADDR(USBx, bEpNum) (PCD_GET_EP_RX_ADDRESS((USBx), (bEpNum)))
  749. /**
  750. * @brief Gets buffer 0/1 address of a double buffer endpoint.
  751. * @param USBx USB peripheral instance register address.
  752. * @param bEpNum Endpoint Number.
  753. * @param bDir endpoint dir EP_DBUF_OUT = OUT
  754. * EP_DBUF_IN = IN
  755. * @param wCount: Counter value
  756. * @retval None
  757. */
  758. #define PCD_SET_EP_DBUF0_CNT(USBx, bEpNum, bDir, wCount) do { \
  759. if ((bDir) == 0U) \
  760. /* OUT endpoint */ \
  761. { \
  762. PCD_SET_EP_RX_DBUF0_CNT((USBx), (bEpNum), (wCount)); \
  763. } \
  764. else \
  765. { \
  766. if ((bDir) == 1U) \
  767. { \
  768. /* IN endpoint */ \
  769. PCD_SET_EP_TX_CNT((USBx), (bEpNum), (wCount)); \
  770. } \
  771. } \
  772. } while(0) /* SetEPDblBuf0Count*/
  773. #define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount) do { \
  774. uint32_t _wBase = (uint32_t)(USBx); \
  775. __IO uint16_t *_wEPRegVal; \
  776. \
  777. if ((bDir) == 0U) \
  778. { \
  779. /* OUT endpoint */ \
  780. PCD_SET_EP_RX_CNT((USBx), (bEpNum), (wCount)); \
  781. } \
  782. else \
  783. { \
  784. if ((bDir) == 1U) \
  785. { \
  786. /* IN endpoint */ \
  787. _wBase += (uint32_t)(USBx)->BTABLE; \
  788. _wEPRegVal = (__IO uint16_t *)(_wBase + 0x400U + ((((uint32_t)(bEpNum) * 8U) + 6U) * PMA_ACCESS)); \
  789. *_wEPRegVal = (uint16_t)(wCount); \
  790. } \
  791. } \
  792. } while(0) /* SetEPDblBuf1Count */
  793. #define PCD_SET_EP_DBUF_CNT(USBx, bEpNum, bDir, wCount) do { \
  794. PCD_SET_EP_DBUF0_CNT((USBx), (bEpNum), (bDir), (wCount)); \
  795. PCD_SET_EP_DBUF1_CNT((USBx), (bEpNum), (bDir), (wCount)); \
  796. } while(0) /* PCD_SET_EP_DBUF_CNT */
  797. /**
  798. * @brief Gets buffer 0/1 rx/tx counter for double buffering.
  799. * @param USBx USB peripheral instance register address.
  800. * @param bEpNum Endpoint Number.
  801. * @retval None
  802. */
  803. #define PCD_GET_EP_DBUF0_CNT(USBx, bEpNum) (PCD_GET_EP_TX_CNT((USBx), (bEpNum)))
  804. #define PCD_GET_EP_DBUF1_CNT(USBx, bEpNum) (PCD_GET_EP_RX_CNT((USBx), (bEpNum)))
  805. /**
  806. * @}
  807. */
  808. /**
  809. * @}
  810. */
  811. /**
  812. * @}
  813. */
  814. #endif /* defined (USB) */
  815. #ifdef __cplusplus
  816. }
  817. #endif
  818. #endif /* STM32L1xx_HAL_PCD_H */
  819. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/