Merge pull request #10592 from iNavFlight/MrD_Update-parameter-description
[inav.git] / lib / main / STM32F7 / Drivers / STM32F7xx_HAL_Driver / Inc / stm32f7xx_hal_pcd.h
blob88755374fcef872a39d409088b4b68387a6b2b6c
1 /**
2 ******************************************************************************
3 * @file stm32f7xx_hal_pcd.h
4 * @author MCD Application Team
5 * @version V1.2.2
6 * @date 14-April-2017
7 * @brief Header file of PCD HAL module.
8 ******************************************************************************
9 * @attention
11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
13 * Redistribution and use in source and binary forms, with or without modification,
14 * are permitted provided that the following conditions are met:
15 * 1. Redistributions of source code must retain the above copyright notice,
16 * this list of conditions and the following disclaimer.
17 * 2. Redistributions in binary form must reproduce the above copyright notice,
18 * this list of conditions and the following disclaimer in the documentation
19 * and/or other materials provided with the distribution.
20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
21 * may be used to endorse or promote products derived from this software
22 * without specific prior written permission.
24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
35 ******************************************************************************
36 */
38 /* Define to prevent recursive inclusion -------------------------------------*/
39 #ifndef __STM32F7xx_HAL_PCD_H
40 #define __STM32F7xx_HAL_PCD_H
42 #ifdef __cplusplus
43 extern "C" {
44 #endif
46 /* Includes ------------------------------------------------------------------*/
47 #include "stm32f7xx_ll_usb.h"
49 /** @addtogroup STM32F7xx_HAL_Driver
50 * @{
53 /** @addtogroup PCD
54 * @{
55 */
57 /* Exported types ------------------------------------------------------------*/
58 /** @defgroup PCD_Exported_Types PCD Exported Types
59 * @{
62 /**
63 * @brief PCD State structure definition
64 */
65 typedef enum
67 HAL_PCD_STATE_RESET = 0x00U,
68 HAL_PCD_STATE_READY = 0x01U,
69 HAL_PCD_STATE_ERROR = 0x02U,
70 HAL_PCD_STATE_BUSY = 0x03U,
71 HAL_PCD_STATE_TIMEOUT = 0x04U
72 } PCD_StateTypeDef;
74 /* Device LPM suspend state */
75 typedef enum
77 LPM_L0 = 0x00U, /* on */
78 LPM_L1 = 0x01U, /* LPM L1 sleep */
79 LPM_L2 = 0x02U, /* suspend */
80 LPM_L3 = 0x03U, /* off */
81 }PCD_LPM_StateTypeDef;
83 typedef USB_OTG_GlobalTypeDef PCD_TypeDef;
84 typedef USB_OTG_CfgTypeDef PCD_InitTypeDef;
85 typedef USB_OTG_EPTypeDef PCD_EPTypeDef ;
87 /**
88 * @brief PCD Handle Structure definition
89 */
90 typedef struct
92 PCD_TypeDef *Instance; /*!< Register base address */
93 PCD_InitTypeDef Init; /*!< PCD required parameters */
94 PCD_EPTypeDef IN_ep[16]; /*!< IN endpoint parameters */
95 PCD_EPTypeDef OUT_ep[16]; /*!< OUT endpoint parameters */
96 HAL_LockTypeDef Lock; /*!< PCD peripheral status */
97 __IO PCD_StateTypeDef State; /*!< PCD communication state */
98 uint32_t Setup[12]; /*!< Setup packet buffer */
99 PCD_LPM_StateTypeDef LPM_State; /*!< LPM State */
100 uint32_t BESL;
101 uint32_t lpm_active; /*!< Enable or disable the Link Power Management .
102 This parameter can be set to ENABLE or DISABLE */
104 uint32_t battery_charging_active; /*!< Enable or disable Battery charging.
105 This parameter can be set to ENABLE or DISABLE */
106 void *pData; /*!< Pointer to upper stack Handler */
107 } PCD_HandleTypeDef;
110 * @}
113 /* Include PCD HAL Extension module */
114 #include "stm32f7xx_hal_pcd_ex.h"
116 /* Exported constants --------------------------------------------------------*/
117 /** @defgroup PCD_Exported_Constants PCD Exported Constants
118 * @{
121 /** @defgroup PCD_Speed PCD Speed
122 * @{
124 #define PCD_SPEED_HIGH 0U
125 #define PCD_SPEED_HIGH_IN_FULL 1U
126 #define PCD_SPEED_FULL 2U
128 * @}
131 /** @defgroup PCD_PHY_Module PCD PHY Module
132 * @{
134 #define PCD_PHY_ULPI 1U
135 #define PCD_PHY_EMBEDDED 2U
136 #define PCD_PHY_UTMI 3U
138 * @}
141 /** @defgroup PCD_Turnaround_Timeout Turnaround Timeout Value
142 * @{
144 #ifndef USBD_HS_TRDT_VALUE
145 #define USBD_HS_TRDT_VALUE 9U
146 #endif /* USBD_HS_TRDT_VALUE */
147 #ifndef USBD_FS_TRDT_VALUE
148 #define USBD_FS_TRDT_VALUE 5U
149 #endif /* USBD_HS_TRDT_VALUE */
152 * @}
156 * @}
159 /* Exported macros -----------------------------------------------------------*/
160 /** @defgroup PCD_Exported_Macros PCD Exported Macros
161 * @brief macros to handle interrupts and specific clock configurations
162 * @{
164 #define __HAL_PCD_ENABLE(__HANDLE__) USB_EnableGlobalInt ((__HANDLE__)->Instance)
165 #define __HAL_PCD_DISABLE(__HANDLE__) USB_DisableGlobalInt ((__HANDLE__)->Instance)
167 #define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((USB_ReadInterrupts((__HANDLE__)->Instance) & (__INTERRUPT__)) == (__INTERRUPT__))
168 #define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->GINTSTS) = (__INTERRUPT__))
169 #define __HAL_PCD_IS_INVALID_INTERRUPT(__HANDLE__) (USB_ReadInterrupts((__HANDLE__)->Instance) == 0)
172 #define __HAL_PCD_UNGATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) &= \
173 ~(USB_OTG_PCGCCTL_STOPCLK)
175 #define __HAL_PCD_GATE_PHYCLOCK(__HANDLE__) *(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE) |= USB_OTG_PCGCCTL_STOPCLK
177 #define __HAL_PCD_IS_PHY_SUSPENDED(__HANDLE__) ((*(__IO uint32_t *)((uint32_t)((__HANDLE__)->Instance) + USB_OTG_PCGCCTL_BASE))&0x10)
179 #define USB_OTG_FS_WAKEUP_EXTI_RISING_EDGE ((uint32_t)0x08U)
180 #define USB_OTG_FS_WAKEUP_EXTI_FALLING_EDGE ((uint32_t)0x0CU)
181 #define USB_OTG_FS_WAKEUP_EXTI_RISING_FALLING_EDGE ((uint32_t)0x10U)
183 #define USB_OTG_HS_WAKEUP_EXTI_RISING_EDGE ((uint32_t)0x08U)
184 #define USB_OTG_HS_WAKEUP_EXTI_FALLING_EDGE ((uint32_t)0x0CU)
185 #define USB_OTG_HS_WAKEUP_EXTI_RISING_FALLING_EDGE ((uint32_t)0x10U)
187 #define USB_OTG_HS_WAKEUP_EXTI_LINE ((uint32_t)0x00100000U) /*!< External interrupt line 20 Connected to the USB HS EXTI Line */
188 #define USB_OTG_FS_WAKEUP_EXTI_LINE ((uint32_t)0x00040000U) /*!< External interrupt line 18 Connected to the USB FS EXTI Line */
190 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= (USB_OTG_HS_WAKEUP_EXTI_LINE)
191 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE)
192 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (USB_OTG_HS_WAKEUP_EXTI_LINE)
193 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = (USB_OTG_HS_WAKEUP_EXTI_LINE)
195 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_RISING_EDGE() EXTI->FTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
196 EXTI->RTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE
198 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_FALLING_EDGE() EXTI->FTSR |= (USB_OTG_HS_WAKEUP_EXTI_LINE);\
199 EXTI->RTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE)
201 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE() EXTI->RTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE);\
202 EXTI->FTSR &= ~(USB_OTG_HS_WAKEUP_EXTI_LINE;)\
203 EXTI->RTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE;\
204 EXTI->FTSR |= USB_OTG_HS_WAKEUP_EXTI_LINE
206 #define __HAL_USB_OTG_HS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
208 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_IT() EXTI->IMR |= USB_OTG_FS_WAKEUP_EXTI_LINE
209 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE)
210 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_GET_FLAG() EXTI->PR & (USB_OTG_FS_WAKEUP_EXTI_LINE)
211 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_CLEAR_FLAG() EXTI->PR = USB_OTG_FS_WAKEUP_EXTI_LINE
213 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_EDGE() EXTI->FTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
214 EXTI->RTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE
217 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_FALLING_EDGE() EXTI->FTSR |= (USB_OTG_FS_WAKEUP_EXTI_LINE);\
218 EXTI->RTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE)
220 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_ENABLE_RISING_FALLING_EDGE() EXTI->RTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
221 EXTI->FTSR &= ~(USB_OTG_FS_WAKEUP_EXTI_LINE);\
222 EXTI->RTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE;\
223 EXTI->FTSR |= USB_OTG_FS_WAKEUP_EXTI_LINE
225 #define __HAL_USB_OTG_FS_WAKEUP_EXTI_GENERATE_SWIT() (EXTI->SWIER |= USB_OTG_FS_WAKEUP_EXTI_LINE)
227 * @}
230 /* Exported functions --------------------------------------------------------*/
231 /** @addtogroup PCD_Exported_Functions PCD Exported Functions
232 * @{
235 /* Initialization/de-initialization functions ********************************/
236 /** @addtogroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions
237 * @{
239 HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd);
240 HAL_StatusTypeDef HAL_PCD_DeInit (PCD_HandleTypeDef *hpcd);
241 void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd);
242 void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd);
244 * @}
247 /* I/O operation functions ***************************************************/
248 /* Non-Blocking mode: Interrupt */
249 /** @addtogroup PCD_Exported_Functions_Group2 Input and Output operation functions
250 * @{
252 HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd);
253 HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd);
254 void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd);
256 void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
257 void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
258 void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd);
259 void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd);
260 void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd);
261 void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd);
262 void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd);
263 void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
264 void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum);
265 void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd);
266 void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd);
268 * @}
271 /* Peripheral Control functions **********************************************/
272 /** @addtogroup PCD_Exported_Functions_Group3 Peripheral Control functions
273 * @{
275 HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd);
276 HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd);
277 HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address);
278 HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type);
279 HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
280 HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
281 HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len);
282 uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
283 HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
284 HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
285 HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr);
286 HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
287 HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd);
289 * @}
292 /* Peripheral State functions ************************************************/
293 /** @addtogroup PCD_Exported_Functions_Group4 Peripheral State functions
294 * @{
296 PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd);
298 * @}
302 * @}
305 /* Private macros ------------------------------------------------------------*/
306 /** @defgroup PCD_Private_Macros PCD Private Macros
307 * @{
309 /** @defgroup PCD_Instance_definition PCD Instance definition
310 * @{
312 #define IS_PCD_ALL_INSTANCE(INSTANCE) (((INSTANCE) == USB_OTG_FS) || \
313 ((INSTANCE) == USB_OTG_HS))
315 * @}
319 * @}
323 * @}
327 * @}
330 #ifdef __cplusplus
332 #endif
335 #endif /* __STM32F7xx_HAL_PCD_H */
337 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/