mbed library sources

Dependents:   Encrypted my_mbed lklk CyaSSL_DTLS_Cellular ... more

Superseded

This library was superseded by mbed-dev - https://os.mbed.com/users/mbed_official/code/mbed-dev/.

Development branch of the mbed library sources. This library is kept in synch with the latest changes from the mbed SDK and it is not guaranteed to work.

If you are looking for a stable and tested release, please import one of the official mbed library releases:

Import librarymbed

The official Mbed 2 C/C++ SDK provides the software platform and libraries to build your applications.

Committer:
mbed_official
Date:
Wed Jul 01 09:45:11 2015 +0100
Revision:
579:53297373a894
Parent:
573:ad23fe03a082
Child:
610:813dcc80987e
Synchronized with git revision d5b4d2ab9c47edb4dc5776e7177b0c2263459081

Full URL: https://github.com/mbedmicro/mbed/commit/d5b4d2ab9c47edb4dc5776e7177b0c2263459081/

Initial version of drivers for SAMR21

Who changed what in which revision?

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