37 #ifndef __STM32F4xx_HAL_PCD_H
38 #define __STM32F4xx_HAL_PCD_H
43 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
44 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
45 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
46 defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
47 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
69 HAL_PCD_STATE_RESET = 0x00U,
70 HAL_PCD_STATE_READY = 0x01U,
71 HAL_PCD_STATE_ERROR = 0x02U,
72 HAL_PCD_STATE_BUSY = 0x03U,
73 HAL_PCD_STATE_TIMEOUT = 0x04U
76 #ifdef USB_OTG_GLPMCFG_LPMEN
84 }PCD_LPM_StateTypeDef;
87 typedef USB_OTG_GlobalTypeDef PCD_TypeDef;
88 typedef USB_OTG_CfgTypeDef PCD_InitTypeDef;
89 typedef USB_OTG_EPTypeDef PCD_EPTypeDef ;
98 PCD_EPTypeDef IN_ep[16U];
99 PCD_EPTypeDef OUT_ep[16U];
101 __IO PCD_StateTypeDef
State;
103 #ifdef USB_OTG_GLPMCFG_LPMEN
104 PCD_LPM_StateTypeDef LPM_State;
109 #ifdef USB_OTG_GCCFG_BCDEN
110 uint32_t battery_charging_active;
131 #define PCD_SPEED_HIGH 0U
132 #define PCD_SPEED_HIGH_IN_FULL 1U
133 #define PCD_SPEED_FULL 2U
141 #define PCD_PHY_ULPI 1U
142 #define PCD_PHY_EMBEDDED 2U
150 #ifndef USBD_HS_TRDT_VALUE
151 #define USBD_HS_TRDT_VALUE 9U
153 #ifndef USBD_FS_TRDT_VALUE
154 #define USBD_FS_TRDT_VALUE 5U
169 #define __HAL_PCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
170 #define __HAL_PCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
172 #define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
173 #define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) &= (__INTERRUPT__))
174 #define __HAL_PCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0U)
176 #define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= \
177 ~(USB_OTG_PCGCCTL_STOPCLK)
179 #define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK
181 #define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE))&0x10U)
183 #define USB_OTG_FS_WAKEUP_EXTI_RISING_EDGE 0x08U
184 #define USB_OTG_FS_WAKEUP_EXTI_FALLING_EDGE 0x0CU
185 #define USB_OTG_FS_WAKEUP_EXTI_RISING_FALLING_EDGE 0x10U
187 #define USB_OTG_HS_WAKEUP_EXTI_RISING_EDGE 0x08U
188 #define USB_OTG_HS_WAKEUP_EXTI_FALLING_EDGE 0x0CU
189 #define USB_OTG_HS_WAKEUP_EXTI_RISING_FALLING_EDGE 0x10U
191 #define USB_OTG_HS_WAKEUP_EXTI_LINE 0x00100000U
192 #define USB_OTG_FS_WAKEUP_EXTI_LINE 0x00040000U
194 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= (USB_OTG_HS_WAKEUP_EXTI_LINE)
195 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE)
196 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (USB_OTG_HS_WAKEUP_EXTI_LINE)
197 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = (USB_OTG_HS_WAKEUP_EXTI_LINE)
199 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_RISING_EDGE() do{EXTI->FTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
200 EXTI->RTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE;\
203 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_FALLING_EDGE() do{EXTI->FTSR |= (USB_OTG_HS_WAKEUP_EXTI_LINE);\
204 EXTI->RTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
207 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE() do{EXTI->RTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
208 EXTI->FTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
209 EXTI->RTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE;\
210 EXTI->FTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE;\
213 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
215 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= USB_OTG_FS_WAKEUP_EXTI_LINE
216 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE)
217 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (USB_OTG_FS_WAKEUP_EXTI_LINE)
218 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = USB_OTG_FS_WAKEUP_EXTI_LINE
220 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_EDGE() do{EXTI->FTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
221 EXTI->RTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE;\
224 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_FALLING_EDGE() do{EXTI->FTSR |= (USB_OTG_FS_WAKEUP_EXTI_LINE);\
225 EXTI->RTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
228 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE() do{EXTI->RTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
229 EXTI->FTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
230 EXTI->RTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE;\
231 EXTI->FTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE;\
234 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
264 void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd);
292 uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd,
uint8_t ep_addr);
306 PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd);