Hal Drivers for L4

Dependents:   BSP OneHopeOnePrayer FINAL_AUDIO_RECORD AudioDemo

Fork of STM32L4xx_HAL_Driver by Senior Design: Sound Monitor

Committer:
EricLew
Date:
Wed Nov 25 17:30:43 2015 +0000
Revision:
2:7aef7655b0a8
Parent:
0:80ee8f3b695e
commit;

Who changed what in which revision?

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