Merge pull request #11189 from klutvott123/move-telemetry-displayport-init
[betaflight.git] / lib / main / STM32G4 / Drivers / STM32G4xx_HAL_Driver / Inc / stm32g4xx_ll_usb.h
blobbe08dd8159a08bc2b6a0ad90deec9c81c7b6feee
1 /**
2 ******************************************************************************
3 * @file stm32g4xx_ll_usb.h
4 * @author MCD Application Team
5 * @brief Header file of USB Low Layer HAL module.
6 ******************************************************************************
7 * @attention
9 * <h2><center>&copy; Copyright (c) 2017 STMicroelectronics.
10 * All rights reserved.</center></h2>
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
17 ******************************************************************************
20 /* Define to prevent recursive inclusion -------------------------------------*/
21 #ifndef STM32G4xx_LL_USB_H
22 #define STM32G4xx_LL_USB_H
24 #ifdef __cplusplus
25 extern "C" {
26 #endif
28 /* Includes ------------------------------------------------------------------*/
29 #include "stm32g4xx_hal_def.h"
31 #if defined (USB)
32 /** @addtogroup STM32G4xx_HAL_Driver
33 * @{
36 /** @addtogroup USB_LL
37 * @{
40 /* Exported types ------------------------------------------------------------*/
42 /**
43 * @brief USB Mode definition
48 typedef enum
50 USB_DEVICE_MODE = 0
51 } USB_ModeTypeDef;
53 /**
54 * @brief USB Initialization Structure definition
56 typedef struct
58 uint32_t dev_endpoints; /*!< Device Endpoints number.
59 This parameter depends on the used USB core.
60 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
62 uint32_t speed; /*!< USB Core speed.
63 This parameter can be any value of @ref USB_Core_Speed */
65 uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */
67 uint32_t phy_itface; /*!< Select the used PHY interface.
68 This parameter can be any value of @ref USB_Core_PHY */
70 uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */
72 uint32_t low_power_enable; /*!< Enable or disable Low Power mode */
74 uint32_t lpm_enable; /*!< Enable or disable Battery charging. */
76 uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */
77 } USB_CfgTypeDef;
79 typedef struct
81 uint8_t num; /*!< Endpoint number
82 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
84 uint8_t is_in; /*!< Endpoint direction
85 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
87 uint8_t is_stall; /*!< Endpoint stall condition
88 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
90 uint8_t type; /*!< Endpoint type
91 This parameter can be any value of @ref USB_EP_Type */
93 uint8_t data_pid_start; /*!< Initial data PID
94 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
96 uint16_t pmaadress; /*!< PMA Address
97 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
99 uint16_t pmaaddr0; /*!< PMA Address0
100 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
102 uint16_t pmaaddr1; /*!< PMA Address1
103 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */
105 uint8_t doublebuffer; /*!< Double buffer enable
106 This parameter can be 0 or 1 */
108 uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used
109 only by USB OTG FS peripheral
110 This parameter is added to ensure compatibility across USB peripherals */
112 uint32_t maxpacket; /*!< Endpoint Max packet size
113 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
115 uint8_t *xfer_buff; /*!< Pointer to transfer buffer */
117 uint32_t xfer_len; /*!< Current transfer length */
119 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */
121 } USB_EPTypeDef;
124 /* Exported constants --------------------------------------------------------*/
126 /** @defgroup PCD_Exported_Constants PCD Exported Constants
127 * @{
131 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
132 * @{
134 #define DEP0CTL_MPS_64 0U
135 #define DEP0CTL_MPS_32 1U
136 #define DEP0CTL_MPS_16 2U
137 #define DEP0CTL_MPS_8 3U
139 * @}
142 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
143 * @{
145 #define EP_TYPE_CTRL 0U
146 #define EP_TYPE_ISOC 1U
147 #define EP_TYPE_BULK 2U
148 #define EP_TYPE_INTR 3U
149 #define EP_TYPE_MSK 3U
151 * @}
154 #define BTABLE_ADDRESS 0x000U
155 #define PMA_ACCESS 1U
157 #define EP_ADDR_MSK 0x7U
159 * @}
162 /* Exported macro ------------------------------------------------------------*/
164 * @}
167 /* Exported functions --------------------------------------------------------*/
168 /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
169 * @{
173 HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
174 HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg);
175 HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
176 HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
177 HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode);
178 HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed);
179 HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx);
180 HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num);
181 HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
182 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
183 HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep);
184 HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
185 void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len);
186 HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
187 HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep);
188 HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address);
189 HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx);
190 HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx);
191 HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
192 HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup);
193 uint32_t USB_ReadInterrupts(USB_TypeDef *USBx);
194 uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx);
195 uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
196 uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx);
197 uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum);
198 void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt);
200 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
201 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
202 void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
203 void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
206 * @}
210 * @}
214 * @}
218 * @}
220 #endif /* defined (USB) */
222 #ifdef __cplusplus
224 #endif
227 #endif /* STM32G4xx_LL_USB_H */
229 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/