Mouse code for the MacroRat

Dependencies:   ITG3200 QEI

Committer:
sahilmgandhi
Date:
Sun May 14 23:18:57 2017 +0000
Revision:
18:6a4db94011d3
Publishing again

Who changed what in which revision?

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