inport from local

Dependents:   Hobbyking_Cheetah_0511

Committer:
NYX
Date:
Mon Mar 16 06:35:48 2020 +0000
Revision:
0:85b3fd62ea1a
reinport to mbed;

Who changed what in which revision?

UserRevisionLine numberNew contents of line
NYX 0:85b3fd62ea1a 1 /**
NYX 0:85b3fd62ea1a 2 ******************************************************************************
NYX 0:85b3fd62ea1a 3 * @file stm32f4xx_ll_usb.h
NYX 0:85b3fd62ea1a 4 * @author MCD Application Team
NYX 0:85b3fd62ea1a 5 * @version V1.7.1
NYX 0:85b3fd62ea1a 6 * @date 14-April-2017
NYX 0:85b3fd62ea1a 7 * @brief Header file of USB Core HAL module.
NYX 0:85b3fd62ea1a 8 ******************************************************************************
NYX 0:85b3fd62ea1a 9 * @attention
NYX 0:85b3fd62ea1a 10 *
NYX 0:85b3fd62ea1a 11 * <h2><center>&copy; COPYRIGHT(c) 2017 STMicroelectronics</center></h2>
NYX 0:85b3fd62ea1a 12 *
NYX 0:85b3fd62ea1a 13 * Redistribution and use in source and binary forms, with or without modification,
NYX 0:85b3fd62ea1a 14 * are permitted provided that the following conditions are met:
NYX 0:85b3fd62ea1a 15 * 1. Redistributions of source code must retain the above copyright notice,
NYX 0:85b3fd62ea1a 16 * this list of conditions and the following disclaimer.
NYX 0:85b3fd62ea1a 17 * 2. Redistributions in binary form must reproduce the above copyright notice,
NYX 0:85b3fd62ea1a 18 * this list of conditions and the following disclaimer in the documentation
NYX 0:85b3fd62ea1a 19 * and/or other materials provided with the distribution.
NYX 0:85b3fd62ea1a 20 * 3. Neither the name of STMicroelectronics nor the names of its contributors
NYX 0:85b3fd62ea1a 21 * may be used to endorse or promote products derived from this software
NYX 0:85b3fd62ea1a 22 * without specific prior written permission.
NYX 0:85b3fd62ea1a 23 *
NYX 0:85b3fd62ea1a 24 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
NYX 0:85b3fd62ea1a 25 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
NYX 0:85b3fd62ea1a 26 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
NYX 0:85b3fd62ea1a 27 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
NYX 0:85b3fd62ea1a 28 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
NYX 0:85b3fd62ea1a 29 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
NYX 0:85b3fd62ea1a 30 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
NYX 0:85b3fd62ea1a 31 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
NYX 0:85b3fd62ea1a 32 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
NYX 0:85b3fd62ea1a 33 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
NYX 0:85b3fd62ea1a 34 *
NYX 0:85b3fd62ea1a 35 ******************************************************************************
NYX 0:85b3fd62ea1a 36 */
NYX 0:85b3fd62ea1a 37
NYX 0:85b3fd62ea1a 38 /* Define to prevent recursive inclusion -------------------------------------*/
NYX 0:85b3fd62ea1a 39 #ifndef __STM32F4xx_LL_USB_H
NYX 0:85b3fd62ea1a 40 #define __STM32F4xx_LL_USB_H
NYX 0:85b3fd62ea1a 41
NYX 0:85b3fd62ea1a 42 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 43 extern "C" {
NYX 0:85b3fd62ea1a 44 #endif
NYX 0:85b3fd62ea1a 45 #if defined(STM32F405xx) || defined(STM32F415xx) || defined(STM32F407xx) || defined(STM32F417xx) || \
NYX 0:85b3fd62ea1a 46 defined(STM32F427xx) || defined(STM32F437xx) || defined(STM32F429xx) || defined(STM32F439xx) || \
NYX 0:85b3fd62ea1a 47 defined(STM32F401xC) || defined(STM32F401xE) || defined(STM32F411xE) || defined(STM32F446xx) || \
NYX 0:85b3fd62ea1a 48 defined(STM32F469xx) || defined(STM32F479xx) || defined(STM32F412Zx) || defined(STM32F412Vx) || \
NYX 0:85b3fd62ea1a 49 defined(STM32F412Rx) || defined(STM32F412Cx) || defined(STM32F413xx) || defined(STM32F423xx)
NYX 0:85b3fd62ea1a 50 /* Includes ------------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 51 #include "stm32f4xx_hal_def.h"
NYX 0:85b3fd62ea1a 52
NYX 0:85b3fd62ea1a 53 /** @addtogroup STM32F4xx_HAL
NYX 0:85b3fd62ea1a 54 * @{
NYX 0:85b3fd62ea1a 55 */
NYX 0:85b3fd62ea1a 56
NYX 0:85b3fd62ea1a 57 /** @addtogroup USB_Core
NYX 0:85b3fd62ea1a 58 * @{
NYX 0:85b3fd62ea1a 59 */
NYX 0:85b3fd62ea1a 60
NYX 0:85b3fd62ea1a 61 /* Exported types ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 62
NYX 0:85b3fd62ea1a 63 /**
NYX 0:85b3fd62ea1a 64 * @brief USB Mode definition
NYX 0:85b3fd62ea1a 65 */
NYX 0:85b3fd62ea1a 66 typedef enum
NYX 0:85b3fd62ea1a 67 {
NYX 0:85b3fd62ea1a 68 USB_OTG_DEVICE_MODE = 0U,
NYX 0:85b3fd62ea1a 69 USB_OTG_HOST_MODE = 1U,
NYX 0:85b3fd62ea1a 70 USB_OTG_DRD_MODE = 2U
NYX 0:85b3fd62ea1a 71
NYX 0:85b3fd62ea1a 72 }USB_OTG_ModeTypeDef;
NYX 0:85b3fd62ea1a 73
NYX 0:85b3fd62ea1a 74 /**
NYX 0:85b3fd62ea1a 75 * @brief URB States definition
NYX 0:85b3fd62ea1a 76 */
NYX 0:85b3fd62ea1a 77 typedef enum {
NYX 0:85b3fd62ea1a 78 URB_IDLE = 0U,
NYX 0:85b3fd62ea1a 79 URB_DONE,
NYX 0:85b3fd62ea1a 80 URB_NOTREADY,
NYX 0:85b3fd62ea1a 81 URB_NYET,
NYX 0:85b3fd62ea1a 82 URB_ERROR,
NYX 0:85b3fd62ea1a 83 URB_STALL
NYX 0:85b3fd62ea1a 84
NYX 0:85b3fd62ea1a 85 }USB_OTG_URBStateTypeDef;
NYX 0:85b3fd62ea1a 86
NYX 0:85b3fd62ea1a 87 /**
NYX 0:85b3fd62ea1a 88 * @brief Host channel States definition
NYX 0:85b3fd62ea1a 89 */
NYX 0:85b3fd62ea1a 90 typedef enum {
NYX 0:85b3fd62ea1a 91 HC_IDLE = 0U,
NYX 0:85b3fd62ea1a 92 HC_XFRC,
NYX 0:85b3fd62ea1a 93 HC_HALTED,
NYX 0:85b3fd62ea1a 94 HC_NAK,
NYX 0:85b3fd62ea1a 95 HC_NYET,
NYX 0:85b3fd62ea1a 96 HC_STALL,
NYX 0:85b3fd62ea1a 97 HC_XACTERR,
NYX 0:85b3fd62ea1a 98 HC_BBLERR,
NYX 0:85b3fd62ea1a 99 HC_DATATGLERR
NYX 0:85b3fd62ea1a 100
NYX 0:85b3fd62ea1a 101 }USB_OTG_HCStateTypeDef;
NYX 0:85b3fd62ea1a 102
NYX 0:85b3fd62ea1a 103 /**
NYX 0:85b3fd62ea1a 104 * @brief PCD Initialization Structure definition
NYX 0:85b3fd62ea1a 105 */
NYX 0:85b3fd62ea1a 106 typedef struct
NYX 0:85b3fd62ea1a 107 {
NYX 0:85b3fd62ea1a 108 uint32_t dev_endpoints; /*!< Device Endpoints number.
NYX 0:85b3fd62ea1a 109 This parameter depends on the used USB core.
NYX 0:85b3fd62ea1a 110 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 111
NYX 0:85b3fd62ea1a 112 uint32_t Host_channels; /*!< Host Channels number.
NYX 0:85b3fd62ea1a 113 This parameter Depends on the used USB core.
NYX 0:85b3fd62ea1a 114 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 115
NYX 0:85b3fd62ea1a 116 uint32_t speed; /*!< USB Core speed.
NYX 0:85b3fd62ea1a 117 This parameter can be any value of @ref USB_Core_Speed_ */
NYX 0:85b3fd62ea1a 118
NYX 0:85b3fd62ea1a 119 uint32_t dma_enable; /*!< Enable or disable of the USB embedded DMA. */
NYX 0:85b3fd62ea1a 120
NYX 0:85b3fd62ea1a 121 uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size.
NYX 0:85b3fd62ea1a 122 This parameter can be any value of @ref USB_EP0_MPS_ */
NYX 0:85b3fd62ea1a 123
NYX 0:85b3fd62ea1a 124 uint32_t phy_itface; /*!< Select the used PHY interface.
NYX 0:85b3fd62ea1a 125 This parameter can be any value of @ref USB_Core_PHY_ */
NYX 0:85b3fd62ea1a 126
NYX 0:85b3fd62ea1a 127 uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */
NYX 0:85b3fd62ea1a 128
NYX 0:85b3fd62ea1a 129 uint32_t low_power_enable; /*!< Enable or disable the low power mode. */
NYX 0:85b3fd62ea1a 130
NYX 0:85b3fd62ea1a 131 uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */
NYX 0:85b3fd62ea1a 132
NYX 0:85b3fd62ea1a 133 uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */
NYX 0:85b3fd62ea1a 134
NYX 0:85b3fd62ea1a 135 uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */
NYX 0:85b3fd62ea1a 136
NYX 0:85b3fd62ea1a 137 uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */
NYX 0:85b3fd62ea1a 138
NYX 0:85b3fd62ea1a 139 uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */
NYX 0:85b3fd62ea1a 140
NYX 0:85b3fd62ea1a 141 }USB_OTG_CfgTypeDef;
NYX 0:85b3fd62ea1a 142
NYX 0:85b3fd62ea1a 143 /**
NYX 0:85b3fd62ea1a 144 * @brief OTG End Point Initialization Structure definition
NYX 0:85b3fd62ea1a 145 */
NYX 0:85b3fd62ea1a 146 typedef struct
NYX 0:85b3fd62ea1a 147 {
NYX 0:85b3fd62ea1a 148 uint8_t num; /*!< Endpoint number
NYX 0:85b3fd62ea1a 149 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 150
NYX 0:85b3fd62ea1a 151 uint8_t is_in; /*!< Endpoint direction
NYX 0:85b3fd62ea1a 152 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 153
NYX 0:85b3fd62ea1a 154 uint8_t is_stall; /*!< Endpoint stall condition
NYX 0:85b3fd62ea1a 155 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 156
NYX 0:85b3fd62ea1a 157 uint8_t type; /*!< Endpoint type
NYX 0:85b3fd62ea1a 158 This parameter can be any value of @ref USB_EP_Type_ */
NYX 0:85b3fd62ea1a 159
NYX 0:85b3fd62ea1a 160 uint8_t data_pid_start; /*!< Initial data PID
NYX 0:85b3fd62ea1a 161 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 162
NYX 0:85b3fd62ea1a 163 uint8_t even_odd_frame; /*!< IFrame parity
NYX 0:85b3fd62ea1a 164 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 165
NYX 0:85b3fd62ea1a 166 uint16_t tx_fifo_num; /*!< Transmission FIFO number
NYX 0:85b3fd62ea1a 167 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 168
NYX 0:85b3fd62ea1a 169 uint32_t maxpacket; /*!< Endpoint Max packet size
NYX 0:85b3fd62ea1a 170 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
NYX 0:85b3fd62ea1a 171
NYX 0:85b3fd62ea1a 172 uint8_t *xfer_buff; /*!< Pointer to transfer buffer */
NYX 0:85b3fd62ea1a 173
NYX 0:85b3fd62ea1a 174 uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */
NYX 0:85b3fd62ea1a 175
NYX 0:85b3fd62ea1a 176 uint32_t xfer_len; /*!< Current transfer length */
NYX 0:85b3fd62ea1a 177
NYX 0:85b3fd62ea1a 178 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */
NYX 0:85b3fd62ea1a 179
NYX 0:85b3fd62ea1a 180 }USB_OTG_EPTypeDef;
NYX 0:85b3fd62ea1a 181
NYX 0:85b3fd62ea1a 182 /**
NYX 0:85b3fd62ea1a 183 * @brief OTG HC Initialization Structure definition
NYX 0:85b3fd62ea1a 184 */
NYX 0:85b3fd62ea1a 185 typedef struct
NYX 0:85b3fd62ea1a 186 {
NYX 0:85b3fd62ea1a 187 uint8_t dev_addr ; /*!< USB device address.
NYX 0:85b3fd62ea1a 188 This parameter must be a number between Min_Data = 1 and Max_Data = 255 */
NYX 0:85b3fd62ea1a 189
NYX 0:85b3fd62ea1a 190 uint8_t ch_num; /*!< Host channel number.
NYX 0:85b3fd62ea1a 191 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 192
NYX 0:85b3fd62ea1a 193 uint8_t ep_num; /*!< Endpoint number.
NYX 0:85b3fd62ea1a 194 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
NYX 0:85b3fd62ea1a 195
NYX 0:85b3fd62ea1a 196 uint8_t ep_is_in; /*!< Endpoint direction
NYX 0:85b3fd62ea1a 197 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 198
NYX 0:85b3fd62ea1a 199 uint8_t speed; /*!< USB Host speed.
NYX 0:85b3fd62ea1a 200 This parameter can be any value of @ref USB_Core_Speed_ */
NYX 0:85b3fd62ea1a 201
NYX 0:85b3fd62ea1a 202 uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */
NYX 0:85b3fd62ea1a 203
NYX 0:85b3fd62ea1a 204 uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */
NYX 0:85b3fd62ea1a 205
NYX 0:85b3fd62ea1a 206 uint8_t ep_type; /*!< Endpoint Type.
NYX 0:85b3fd62ea1a 207 This parameter can be any value of @ref USB_EP_Type_ */
NYX 0:85b3fd62ea1a 208
NYX 0:85b3fd62ea1a 209 uint16_t max_packet; /*!< Endpoint Max packet size.
NYX 0:85b3fd62ea1a 210 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
NYX 0:85b3fd62ea1a 211
NYX 0:85b3fd62ea1a 212 uint8_t data_pid; /*!< Initial data PID.
NYX 0:85b3fd62ea1a 213 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 214
NYX 0:85b3fd62ea1a 215 uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */
NYX 0:85b3fd62ea1a 216
NYX 0:85b3fd62ea1a 217 uint32_t xfer_len; /*!< Current transfer length. */
NYX 0:85b3fd62ea1a 218
NYX 0:85b3fd62ea1a 219 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */
NYX 0:85b3fd62ea1a 220
NYX 0:85b3fd62ea1a 221 uint8_t toggle_in; /*!< IN transfer current toggle flag.
NYX 0:85b3fd62ea1a 222 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 223
NYX 0:85b3fd62ea1a 224 uint8_t toggle_out; /*!< OUT transfer current toggle flag
NYX 0:85b3fd62ea1a 225 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */
NYX 0:85b3fd62ea1a 226
NYX 0:85b3fd62ea1a 227 uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */
NYX 0:85b3fd62ea1a 228
NYX 0:85b3fd62ea1a 229 uint32_t ErrCnt; /*!< Host channel error count.*/
NYX 0:85b3fd62ea1a 230
NYX 0:85b3fd62ea1a 231 USB_OTG_URBStateTypeDef urb_state; /*!< URB state.
NYX 0:85b3fd62ea1a 232 This parameter can be any value of @ref USB_OTG_URBStateTypeDef */
NYX 0:85b3fd62ea1a 233
NYX 0:85b3fd62ea1a 234 USB_OTG_HCStateTypeDef state; /*!< Host Channel state.
NYX 0:85b3fd62ea1a 235 This parameter can be any value of @ref USB_OTG_HCStateTypeDef */
NYX 0:85b3fd62ea1a 236
NYX 0:85b3fd62ea1a 237 }USB_OTG_HCTypeDef;
NYX 0:85b3fd62ea1a 238
NYX 0:85b3fd62ea1a 239 /* Exported constants --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 240
NYX 0:85b3fd62ea1a 241 /** @defgroup PCD_Exported_Constants PCD Exported Constants
NYX 0:85b3fd62ea1a 242 * @{
NYX 0:85b3fd62ea1a 243 */
NYX 0:85b3fd62ea1a 244
NYX 0:85b3fd62ea1a 245 /** @defgroup USB_Core_Mode_ USB Core Mode
NYX 0:85b3fd62ea1a 246 * @{
NYX 0:85b3fd62ea1a 247 */
NYX 0:85b3fd62ea1a 248 #define USB_OTG_MODE_DEVICE 0U
NYX 0:85b3fd62ea1a 249 #define USB_OTG_MODE_HOST 1U
NYX 0:85b3fd62ea1a 250 #define USB_OTG_MODE_DRD 2U
NYX 0:85b3fd62ea1a 251 /**
NYX 0:85b3fd62ea1a 252 * @}
NYX 0:85b3fd62ea1a 253 */
NYX 0:85b3fd62ea1a 254
NYX 0:85b3fd62ea1a 255 /** @defgroup USB_Core_Speed_ USB Core Speed
NYX 0:85b3fd62ea1a 256 * @{
NYX 0:85b3fd62ea1a 257 */
NYX 0:85b3fd62ea1a 258 #define USB_OTG_SPEED_HIGH 0U
NYX 0:85b3fd62ea1a 259 #define USB_OTG_SPEED_HIGH_IN_FULL 1U
NYX 0:85b3fd62ea1a 260 #define USB_OTG_SPEED_LOW 2U
NYX 0:85b3fd62ea1a 261 #define USB_OTG_SPEED_FULL 3U
NYX 0:85b3fd62ea1a 262 /**
NYX 0:85b3fd62ea1a 263 * @}
NYX 0:85b3fd62ea1a 264 */
NYX 0:85b3fd62ea1a 265
NYX 0:85b3fd62ea1a 266 /** @defgroup USB_Core_PHY_ USB Core PHY
NYX 0:85b3fd62ea1a 267 * @{
NYX 0:85b3fd62ea1a 268 */
NYX 0:85b3fd62ea1a 269 #define USB_OTG_ULPI_PHY 1U
NYX 0:85b3fd62ea1a 270 #define USB_OTG_EMBEDDED_PHY 2U
NYX 0:85b3fd62ea1a 271 /**
NYX 0:85b3fd62ea1a 272 * @}
NYX 0:85b3fd62ea1a 273 */
NYX 0:85b3fd62ea1a 274
NYX 0:85b3fd62ea1a 275 /** @defgroup USB_Core_MPS_ USB Core MPS
NYX 0:85b3fd62ea1a 276 * @{
NYX 0:85b3fd62ea1a 277 */
NYX 0:85b3fd62ea1a 278 #define USB_OTG_HS_MAX_PACKET_SIZE 512U
NYX 0:85b3fd62ea1a 279 #define USB_OTG_FS_MAX_PACKET_SIZE 64U
NYX 0:85b3fd62ea1a 280 #define USB_OTG_MAX_EP0_SIZE 64U
NYX 0:85b3fd62ea1a 281 /**
NYX 0:85b3fd62ea1a 282 * @}
NYX 0:85b3fd62ea1a 283 */
NYX 0:85b3fd62ea1a 284
NYX 0:85b3fd62ea1a 285 /** @defgroup USB_Core_Phy_Frequency_ USB Core Phy Frequency
NYX 0:85b3fd62ea1a 286 * @{
NYX 0:85b3fd62ea1a 287 */
NYX 0:85b3fd62ea1a 288 #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1U)
NYX 0:85b3fd62ea1a 289 #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1U)
NYX 0:85b3fd62ea1a 290 #define DSTS_ENUMSPD_LS_PHY_6MHZ (2U << 1U)
NYX 0:85b3fd62ea1a 291 #define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1U)
NYX 0:85b3fd62ea1a 292 /**
NYX 0:85b3fd62ea1a 293 * @}
NYX 0:85b3fd62ea1a 294 */
NYX 0:85b3fd62ea1a 295
NYX 0:85b3fd62ea1a 296 /** @defgroup USB_CORE_Frame_Interval_ USB CORE Frame Interval
NYX 0:85b3fd62ea1a 297 * @{
NYX 0:85b3fd62ea1a 298 */
NYX 0:85b3fd62ea1a 299 #define DCFG_FRAME_INTERVAL_80 0U
NYX 0:85b3fd62ea1a 300 #define DCFG_FRAME_INTERVAL_85 1U
NYX 0:85b3fd62ea1a 301 #define DCFG_FRAME_INTERVAL_90 2U
NYX 0:85b3fd62ea1a 302 #define DCFG_FRAME_INTERVAL_95 3U
NYX 0:85b3fd62ea1a 303 /**
NYX 0:85b3fd62ea1a 304 * @}
NYX 0:85b3fd62ea1a 305 */
NYX 0:85b3fd62ea1a 306
NYX 0:85b3fd62ea1a 307 /** @defgroup USB_EP0_MPS_ USB EP0 MPS
NYX 0:85b3fd62ea1a 308 * @{
NYX 0:85b3fd62ea1a 309 */
NYX 0:85b3fd62ea1a 310 #define DEP0CTL_MPS_64 0U
NYX 0:85b3fd62ea1a 311 #define DEP0CTL_MPS_32 1U
NYX 0:85b3fd62ea1a 312 #define DEP0CTL_MPS_16 2U
NYX 0:85b3fd62ea1a 313 #define DEP0CTL_MPS_8 3U
NYX 0:85b3fd62ea1a 314 /**
NYX 0:85b3fd62ea1a 315 * @}
NYX 0:85b3fd62ea1a 316 */
NYX 0:85b3fd62ea1a 317
NYX 0:85b3fd62ea1a 318 /** @defgroup USB_EP_Speed_ USB EP Speed
NYX 0:85b3fd62ea1a 319 * @{
NYX 0:85b3fd62ea1a 320 */
NYX 0:85b3fd62ea1a 321 #define EP_SPEED_LOW 0U
NYX 0:85b3fd62ea1a 322 #define EP_SPEED_FULL 1U
NYX 0:85b3fd62ea1a 323 #define EP_SPEED_HIGH 2U
NYX 0:85b3fd62ea1a 324 /**
NYX 0:85b3fd62ea1a 325 * @}
NYX 0:85b3fd62ea1a 326 */
NYX 0:85b3fd62ea1a 327
NYX 0:85b3fd62ea1a 328 /** @defgroup USB_EP_Type_ USB EP Type
NYX 0:85b3fd62ea1a 329 * @{
NYX 0:85b3fd62ea1a 330 */
NYX 0:85b3fd62ea1a 331 #define EP_TYPE_CTRL 0U
NYX 0:85b3fd62ea1a 332 #define EP_TYPE_ISOC 1U
NYX 0:85b3fd62ea1a 333 #define EP_TYPE_BULK 2U
NYX 0:85b3fd62ea1a 334 #define EP_TYPE_INTR 3U
NYX 0:85b3fd62ea1a 335 #define EP_TYPE_MSK 3U
NYX 0:85b3fd62ea1a 336 /**
NYX 0:85b3fd62ea1a 337 * @}
NYX 0:85b3fd62ea1a 338 */
NYX 0:85b3fd62ea1a 339
NYX 0:85b3fd62ea1a 340 /** @defgroup USB_STS_Defines_ USB STS Defines
NYX 0:85b3fd62ea1a 341 * @{
NYX 0:85b3fd62ea1a 342 */
NYX 0:85b3fd62ea1a 343 #define STS_GOUT_NAK 1U
NYX 0:85b3fd62ea1a 344 #define STS_DATA_UPDT 2U
NYX 0:85b3fd62ea1a 345 #define STS_XFER_COMP 3U
NYX 0:85b3fd62ea1a 346 #define STS_SETUP_COMP 4U
NYX 0:85b3fd62ea1a 347 #define STS_SETUP_UPDT 6U
NYX 0:85b3fd62ea1a 348 /**
NYX 0:85b3fd62ea1a 349 * @}
NYX 0:85b3fd62ea1a 350 */
NYX 0:85b3fd62ea1a 351
NYX 0:85b3fd62ea1a 352 /** @defgroup HCFG_SPEED_Defines_ HCFG SPEED Defines
NYX 0:85b3fd62ea1a 353 * @{
NYX 0:85b3fd62ea1a 354 */
NYX 0:85b3fd62ea1a 355 #define HCFG_30_60_MHZ 0U
NYX 0:85b3fd62ea1a 356 #define HCFG_48_MHZ 1U
NYX 0:85b3fd62ea1a 357 #define HCFG_6_MHZ 2U
NYX 0:85b3fd62ea1a 358 /**
NYX 0:85b3fd62ea1a 359 * @}
NYX 0:85b3fd62ea1a 360 */
NYX 0:85b3fd62ea1a 361
NYX 0:85b3fd62ea1a 362 /** @defgroup HPRT0_PRTSPD_SPEED_Defines_ HPRT0 PRTSPD SPEED Defines
NYX 0:85b3fd62ea1a 363 * @{
NYX 0:85b3fd62ea1a 364 */
NYX 0:85b3fd62ea1a 365 #define HPRT0_PRTSPD_HIGH_SPEED 0U
NYX 0:85b3fd62ea1a 366 #define HPRT0_PRTSPD_FULL_SPEED 1U
NYX 0:85b3fd62ea1a 367 #define HPRT0_PRTSPD_LOW_SPEED 2U
NYX 0:85b3fd62ea1a 368 /**
NYX 0:85b3fd62ea1a 369 * @}
NYX 0:85b3fd62ea1a 370 */
NYX 0:85b3fd62ea1a 371
NYX 0:85b3fd62ea1a 372 #define HCCHAR_CTRL 0U
NYX 0:85b3fd62ea1a 373 #define HCCHAR_ISOC 1U
NYX 0:85b3fd62ea1a 374 #define HCCHAR_BULK 2U
NYX 0:85b3fd62ea1a 375 #define HCCHAR_INTR 3U
NYX 0:85b3fd62ea1a 376
NYX 0:85b3fd62ea1a 377 #define HC_PID_DATA0 0U
NYX 0:85b3fd62ea1a 378 #define HC_PID_DATA2 1U
NYX 0:85b3fd62ea1a 379 #define HC_PID_DATA1 2U
NYX 0:85b3fd62ea1a 380 #define HC_PID_SETUP 3U
NYX 0:85b3fd62ea1a 381
NYX 0:85b3fd62ea1a 382 #define GRXSTS_PKTSTS_IN 2U
NYX 0:85b3fd62ea1a 383 #define GRXSTS_PKTSTS_IN_XFER_COMP 3U
NYX 0:85b3fd62ea1a 384 #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U
NYX 0:85b3fd62ea1a 385 #define GRXSTS_PKTSTS_CH_HALTED 7U
NYX 0:85b3fd62ea1a 386
NYX 0:85b3fd62ea1a 387 #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE)
NYX 0:85b3fd62ea1a 388 #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)
NYX 0:85b3fd62ea1a 389
NYX 0:85b3fd62ea1a 390 #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)((uint32_t )USBx + USB_OTG_DEVICE_BASE))
NYX 0:85b3fd62ea1a 391 #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE))
NYX 0:85b3fd62ea1a 392 #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE))
NYX 0:85b3fd62ea1a 393 #define USBx_DFIFO(i) *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + (i) * USB_OTG_FIFO_SIZE)
NYX 0:85b3fd62ea1a 394
NYX 0:85b3fd62ea1a 395 #define USBx_HOST ((USB_OTG_HostTypeDef *)((uint32_t )USBx + USB_OTG_HOST_BASE))
NYX 0:85b3fd62ea1a 396 #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)((uint32_t)USBx + USB_OTG_HOST_CHANNEL_BASE + (i)*USB_OTG_HOST_CHANNEL_SIZE))
NYX 0:85b3fd62ea1a 397 /**
NYX 0:85b3fd62ea1a 398 * @}
NYX 0:85b3fd62ea1a 399 */
NYX 0:85b3fd62ea1a 400 /* Exported macro ------------------------------------------------------------*/
NYX 0:85b3fd62ea1a 401 #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
NYX 0:85b3fd62ea1a 402 #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
NYX 0:85b3fd62ea1a 403
NYX 0:85b3fd62ea1a 404 #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
NYX 0:85b3fd62ea1a 405 #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
NYX 0:85b3fd62ea1a 406
NYX 0:85b3fd62ea1a 407 /* Exported functions --------------------------------------------------------*/
NYX 0:85b3fd62ea1a 408 HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
NYX 0:85b3fd62ea1a 409 HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
NYX 0:85b3fd62ea1a 410 HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 411 HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 412 HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_OTG_ModeTypeDef mode);
NYX 0:85b3fd62ea1a 413 HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed);
NYX 0:85b3fd62ea1a 414 HAL_StatusTypeDef USB_FlushRxFifo (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 415 HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num );
NYX 0:85b3fd62ea1a 416 HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 417 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 418 HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 419 HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 420 HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma);
NYX 0:85b3fd62ea1a 421 HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep, uint8_t dma);
NYX 0:85b3fd62ea1a 422 HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len, uint8_t dma);
NYX 0:85b3fd62ea1a 423 void * USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
NYX 0:85b3fd62ea1a 424 HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 425 HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
NYX 0:85b3fd62ea1a 426 HAL_StatusTypeDef USB_SetDevAddress (USB_OTG_GlobalTypeDef *USBx, uint8_t address);
NYX 0:85b3fd62ea1a 427 HAL_StatusTypeDef USB_DevConnect (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 428 HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 429 HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 430 HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 431 HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t dma, uint8_t *psetup);
NYX 0:85b3fd62ea1a 432 uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 433 uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 434 uint32_t USB_ReadInterrupts (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 435 uint32_t USB_ReadDevAllOutEpInterrupt (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 436 uint32_t USB_ReadDevOutEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum);
NYX 0:85b3fd62ea1a 437 uint32_t USB_ReadDevAllInEpInterrupt (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 438 uint32_t USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum);
NYX 0:85b3fd62ea1a 439 void USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
NYX 0:85b3fd62ea1a 440
NYX 0:85b3fd62ea1a 441 HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
NYX 0:85b3fd62ea1a 442 HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq);
NYX 0:85b3fd62ea1a 443 HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 444 HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state);
NYX 0:85b3fd62ea1a 445 uint32_t USB_GetHostSpeed (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 446 uint32_t USB_GetCurrentFrame (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 447 HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,
NYX 0:85b3fd62ea1a 448 uint8_t ch_num,
NYX 0:85b3fd62ea1a 449 uint8_t epnum,
NYX 0:85b3fd62ea1a 450 uint8_t dev_address,
NYX 0:85b3fd62ea1a 451 uint8_t speed,
NYX 0:85b3fd62ea1a 452 uint8_t ep_type,
NYX 0:85b3fd62ea1a 453 uint16_t mps);
NYX 0:85b3fd62ea1a 454 HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc, uint8_t dma);
NYX 0:85b3fd62ea1a 455 uint32_t USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 456 HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num);
NYX 0:85b3fd62ea1a 457 HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num);
NYX 0:85b3fd62ea1a 458 HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
NYX 0:85b3fd62ea1a 459
NYX 0:85b3fd62ea1a 460 /**
NYX 0:85b3fd62ea1a 461 * @}
NYX 0:85b3fd62ea1a 462 */
NYX 0:85b3fd62ea1a 463
NYX 0:85b3fd62ea1a 464 /**
NYX 0:85b3fd62ea1a 465 * @}
NYX 0:85b3fd62ea1a 466 */
NYX 0:85b3fd62ea1a 467 #endif /* STM32F405xx || STM32F415xx || STM32F407xx || STM32F417xx || STM32F427xx || STM32F437xx || STM32F429xx || STM32F439xx ||
NYX 0:85b3fd62ea1a 468 STM32F401xC || STM32F401xE || STM32F411xE || STM32F446xx || STM32F469xx || STM32F479xx || STM32F412Zx || STM32F412Rx ||
NYX 0:85b3fd62ea1a 469 STM32F412Vx || STM32F412Cx || STM32F413xx || STM32F423xx */
NYX 0:85b3fd62ea1a 470 #ifdef __cplusplus
NYX 0:85b3fd62ea1a 471 }
NYX 0:85b3fd62ea1a 472 #endif
NYX 0:85b3fd62ea1a 473
NYX 0:85b3fd62ea1a 474
NYX 0:85b3fd62ea1a 475 #endif /* __STM32F4xx_LL_USB_H */
NYX 0:85b3fd62ea1a 476
NYX 0:85b3fd62ea1a 477 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/