comparison Common/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pcd.h @ 128:c78bcbd5deda FlipDisplay

Added current STM32 standandard libraries in version independend folder structure
author Ideenmodellierer
date Sun, 17 Feb 2019 21:12:22 +0100
parents
children
comparison
equal deleted inserted replaced
127:1369f8660eaa 128:c78bcbd5deda
1 /**
2 ******************************************************************************
3 * @file stm32f4xx_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) 2017 STMicroelectronics</center></h2>
10 *
11 * Redistribution and use in source and binary forms, with or without modification,
12 * are permitted provided that the following conditions are met:
13 * 1. Redistributions of source code must retain the above copyright notice,
14 * this list of conditions and the following disclaimer.
15 * 2. Redistributions in binary form must reproduce the above copyright notice,
16 * this list of conditions and the following disclaimer in the documentation
17 * and/or other materials provided with the distribution.
18 * 3. Neither the name of STMicroelectronics nor the names of its contributors
19 * may be used to endorse or promote products derived from this software
20 * without specific prior written permission.
21 *
22 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
23 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
24 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
25 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
26 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
27 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
28 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
29 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
30 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
31 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
32 *
33 ******************************************************************************
34 */
35
36 /* Define to prevent recursive inclusion -------------------------------------*/
37 #ifndef __STM32F4xx_HAL_PCD_H
38 #define __STM32F4xx_HAL_PCD_H
39
40 #ifdef __cplusplus
41 extern "C" {
42 #endif
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)
48 /* Includes ------------------------------------------------------------------*/
49 #include "stm32f4xx_ll_usb.h"
50
51 /** @addtogroup STM32F4xx_HAL_Driver
52 * @{
53 */
54
55 /** @addtogroup PCD
56 * @{
57 */
58
59 /* Exported types ------------------------------------------------------------*/
60 /** @defgroup PCD_Exported_Types PCD Exported Types
61 * @{
62 */
63
64 /**
65 * @brief PCD State structure definition
66 */
67 typedef enum
68 {
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
74 } PCD_StateTypeDef;
75
76 #ifdef USB_OTG_GLPMCFG_LPMEN
77 /* Device LPM suspend state */
78 typedef enum
79 {
80 LPM_L0 = 0x00U, /* on */
81 LPM_L1 = 0x01U, /* LPM L1 sleep */
82 LPM_L2 = 0x02U, /* suspend */
83 LPM_L3 = 0x03U /* off */
84 }PCD_LPM_StateTypeDef;
85 #endif /* USB_OTG_GLPMCFG_LPMEN */
86
87 typedef USB_OTG_GlobalTypeDef PCD_TypeDef;
88 typedef USB_OTG_CfgTypeDef PCD_InitTypeDef;
89 typedef USB_OTG_EPTypeDef PCD_EPTypeDef ;
90
91 /**
92 * @brief PCD Handle Structure definition
93 */
94 typedef struct
95 {
96 PCD_TypeDef *Instance; /*!< Register base address */
97 PCD_InitTypeDef Init; /*!< PCD required parameters */
98 PCD_EPTypeDef IN_ep[16U]; /*!< IN endpoint parameters */
99 PCD_EPTypeDef OUT_ep[16U]; /*!< OUT endpoint parameters */
100 HAL_LockTypeDef Lock; /*!< PCD peripheral status */
101 __IO PCD_StateTypeDef State; /*!< PCD communication state */
102 uint32_t Setup[12U]; /*!< Setup packet buffer */
103 #ifdef USB_OTG_GLPMCFG_LPMEN
104 PCD_LPM_StateTypeDef LPM_State; /*!< LPM State */
105 uint32_t BESL;
106 uint32_t lpm_active; /*!< Enable or disable the Link Power Management .
107 This parameter can be set to ENABLE or DISABLE */
108 #endif /* USB_OTG_GLPMCFG_LPMEN */
109 #ifdef USB_OTG_GCCFG_BCDEN
110 uint32_t battery_charging_active; /*!< Enable or disable Battery charging.
111 This parameter can be set to ENABLE or DISABLE */
112 #endif /* USB_OTG_GCCFG_BCDEN */
113 void *pData; /*!< Pointer to upper stack Handler */
114 } PCD_HandleTypeDef;
115
116 /**
117 * @}
118 */
119
120 /* Include PCD HAL Extension module */
121 #include "stm32f4xx_hal_pcd_ex.h"
122
123 /* Exported constants --------------------------------------------------------*/
124 /** @defgroup PCD_Exported_Constants PCD Exported Constants
125 * @{
126 */
127
128 /** @defgroup PCD_Speed PCD Speed
129 * @{
130 */
131 #define PCD_SPEED_HIGH 0U
132 #define PCD_SPEED_HIGH_IN_FULL 1U
133 #define PCD_SPEED_FULL 2U
134 /**
135 * @}
136 */
137
138 /** @defgroup PCD_PHY_Module PCD PHY Module
139 * @{
140 */
141 #define PCD_PHY_ULPI 1U
142 #define PCD_PHY_EMBEDDED 2U
143 /**
144 * @}
145 */
146
147 /** @defgroup PCD_Turnaround_Timeout Turnaround Timeout Value
148 * @{
149 */
150 #ifndef USBD_HS_TRDT_VALUE
151 #define USBD_HS_TRDT_VALUE 9U
152 #endif /* USBD_HS_TRDT_VALUE */
153 #ifndef USBD_FS_TRDT_VALUE
154 #define USBD_FS_TRDT_VALUE 5U
155 #endif /* USBD_FS_TRDT_VALUE */
156 /**
157 * @}
158 */
159
160 /**
161 * @}
162 */
163
164 /* Exported macros -----------------------------------------------------------*/
165 /** @defgroup PCD_Exported_Macros PCD Exported Macros
166 * @brief macros to handle interrupts and specific clock configurations
167 * @{
168 */
169 #define __HAL_PCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
170 #define __HAL_PCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
171
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)
175
176 #define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= \
177 ~(USB_OTG_PCGCCTL_STOPCLK)
178
179 #define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK
180
181 #define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE))&0x10U)
182
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
186
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
190
191 #define USB_OTG_HS_WAKEUP_EXTI_LINE 0x00100000U /*!< External interrupt line 20 Connected to the USB HS EXTI Line */
192 #define USB_OTG_FS_WAKEUP_EXTI_LINE 0x00040000U /*!< External interrupt line 18 Connected to the USB FS EXTI Line */
193
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)
198
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;\
201 }while(0U)
202
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);\
205 }while(0U)
206
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;\
211 }while(0U)
212
213 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
214
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
219
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;\
222 }while(0U)
223
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);\
226 }while(0U)
227
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;\
232 }while(0U)
233
234 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
235 /**
236 * @}
237 */
238
239 /* Exported functions --------------------------------------------------------*/
240 /** @addtogroup PCD_Exported_Functions PCD Exported Functions
241 * @{
242 */
243
244 /* Initialization/de-initialization functions ********************************/
245 /** @addtogroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions
246 * @{
247 */
248 HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd);
249 HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd);
250 void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd);
251 void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd);
252 /**
253 * @}
254 */
255
256 /* I/O operation functions ***************************************************/
257 /* Non-Blocking mode: Interrupt */
258 /** @addtogroup PCD_Exported_Functions_Group2 Input and Output operation functions
259 * @{
260 */
261 /* Non-Blocking mode: Interrupt */
262 HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd);
263 HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd);
264 void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd);
265
266 void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
267 void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
268 void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd);
269 void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd);
270 void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd);
271 void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd);
272 void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd);
273 void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
274 void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
275 void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd);
276 void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd);
277 /**
278 * @}
279 */
280
281 /* Peripheral Control functions **********************************************/
282 /** @addtogroup PCD_Exported_Functions_Group3 Peripheral Control functions
283 * @{
284 */
285 HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd);
286 HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd);
287 HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address);
288 HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type);
289 HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
290 HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
291 HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
292 uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
293 HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
294 HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
295 HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
296 HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
297 HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
298 /**
299 * @}
300 */
301
302 /* Peripheral State functions ************************************************/
303 /** @addtogroup PCD_Exported_Functions_Group4 Peripheral State functions
304 * @{
305 */
306 PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd);
307 /**
308 * @}
309 */
310
311 /**
312 * @}
313 */
314
315 /* Private macros ------------------------------------------------------------*/
316 /** @defgroup PCD_Private_Macros PCD Private Macros
317 * @{
318 */
319
320 /**
321 * @}
322 */
323
324 /**
325 * @}
326 */
327
328 /**
329 * @}
330 */
331 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
332 STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Rx ||
333 STM32F412Vx || STM32F412Cx || STM32F413xx || STM32F423xx */
334 #ifdef __cplusplus
335 }
336 #endif
337
338
339 #endif /* __STM32F4xx_HAL_PCD_H */
340
341 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/