Lancaster University's (short term!) clone of mbed-src for micro:bit. This is a copy of the github branch https://github.com/lancaster-university/mbed-classic

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Fri Aug 14 13:15:17 2015 +0100
Revision:
610:813dcc80987e
Synchronized with git revision 6d84db41c6833e0b9b024741eb0616a5f62d5599

Full URL: https://github.com/mbedmicro/mbed/commit/6d84db41c6833e0b9b024741eb0616a5f62d5599/

DISCO_F746NG - Improvements

Who changed what in which revision?

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