mbed(SerialHalfDuplex入り)

Fork of mbed by mbed official

Committer:
yusuke_kyo
Date:
Wed Apr 08 08:04:18 2015 +0000
Revision:
98:01a414ca7d6d
Parent:
93:e188a91d3eaa
remove SerialHalfDuplex.h

Who changed what in which revision?

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