Initial commit

Dependencies:   FastPWM

Committer:
lypinator
Date:
Wed Sep 16 01:11:49 2020 +0000
Revision:
0:bb348c97df44
Added PWM

Who changed what in which revision?

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