1 /** 2 ****************************************************************************** 3 * @file stm32l4xx_ll_usb.h 4 * @author MCD Application Team 5 * @brief Header file of USB Low Layer HAL module. 6 ****************************************************************************** 7 * @attention 8 * 9 * Copyright (c) 2017 STMicroelectronics. 10 * All rights reserved. 11 * 12 * This software is licensed under terms that can be found in the LICENSE file 13 * in the root directory of this software component. 14 * If no LICENSE file comes with this software, it is provided AS-IS. 15 * 16 ****************************************************************************** 17 */ 18 19 /* Define to prevent recursive inclusion -------------------------------------*/ 20 #ifndef STM32L4xx_LL_USB_H 21 #define STM32L4xx_LL_USB_H 22 23 #ifdef __cplusplus 24 extern "C" { 25 #endif /* __cplusplus */ 26 27 /* Includes ------------------------------------------------------------------*/ 28 #include "stm32l4xx_hal_def.h" 29 30 #if defined (USB) || defined (USB_OTG_FS) 31 /** @addtogroup STM32L4xx_HAL_Driver 32 * @{ 33 */ 34 35 /** @addtogroup USB_LL 36 * @{ 37 */ 38 39 /* Exported types ------------------------------------------------------------*/ 40 41 /** 42 * @brief USB Mode definition 43 */ 44 #if defined (USB_OTG_FS) 45 46 typedef enum 47 { 48 USB_DEVICE_MODE = 0, 49 USB_HOST_MODE = 1, 50 USB_DRD_MODE = 2 51 } USB_ModeTypeDef; 52 53 /** 54 * @brief URB States definition 55 */ 56 typedef enum 57 { 58 URB_IDLE = 0, 59 URB_DONE, 60 URB_NOTREADY, 61 URB_NYET, 62 URB_ERROR, 63 URB_STALL 64 } USB_OTG_URBStateTypeDef; 65 66 /** 67 * @brief Host channel States definition 68 */ 69 typedef enum 70 { 71 HC_IDLE = 0, 72 HC_XFRC, 73 HC_HALTED, 74 HC_NAK, 75 HC_NYET, 76 HC_STALL, 77 HC_XACTERR, 78 HC_BBLERR, 79 HC_DATATGLERR 80 } USB_OTG_HCStateTypeDef; 81 82 83 /** 84 * @brief USB Instance Initialization Structure definition 85 */ 86 typedef struct 87 { 88 uint32_t dev_endpoints; /*!< Device Endpoints number. 89 This parameter depends on the used USB core. 90 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 91 92 uint32_t Host_channels; /*!< Host Channels number. 93 This parameter Depends on the used USB core. 94 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 95 96 uint32_t speed; /*!< USB Core speed. 97 This parameter can be any value of @ref PCD_Speed/HCD_Speed 98 (HCD_SPEED_xxx, HCD_SPEED_xxx) */ 99 100 uint32_t dma_enable; /*!< Enable or disable of the USB embedded DMA used only for OTG HS. */ 101 102 uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ 103 104 uint32_t phy_itface; /*!< Select the used PHY interface. 105 This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ 106 107 uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ 108 109 uint32_t low_power_enable; /*!< Enable or disable the low power mode. */ 110 111 uint32_t lpm_enable; /*!< Enable or disable Link Power Management. */ 112 113 uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ 114 115 uint32_t vbus_sensing_enable; /*!< Enable or disable the VBUS Sensing feature. */ 116 117 uint32_t use_dedicated_ep1; /*!< Enable or disable the use of the dedicated EP1 interrupt. */ 118 119 uint32_t use_external_vbus; /*!< Enable or disable the use of the external VBUS. */ 120 121 } USB_OTG_CfgTypeDef; 122 123 typedef struct 124 { 125 uint8_t num; /*!< Endpoint number 126 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 127 128 uint8_t is_in; /*!< Endpoint direction 129 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 130 131 uint8_t is_stall; /*!< Endpoint stall condition 132 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 133 134 uint8_t is_iso_incomplete; /*!< Endpoint isoc condition 135 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 136 137 uint8_t type; /*!< Endpoint type 138 This parameter can be any value of @ref USB_LL_EP_Type */ 139 140 uint8_t data_pid_start; /*!< Initial data PID 141 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 142 143 uint8_t even_odd_frame; /*!< IFrame parity 144 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 145 146 uint16_t tx_fifo_num; /*!< Transmission FIFO number 147 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 148 149 uint32_t maxpacket; /*!< Endpoint Max packet size 150 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ 151 152 uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ 153 154 uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address */ 155 156 uint32_t xfer_len; /*!< Current transfer length */ 157 158 uint32_t xfer_size; /*!< requested transfer size */ 159 160 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ 161 } USB_OTG_EPTypeDef; 162 163 typedef struct 164 { 165 uint8_t dev_addr; /*!< USB device address. 166 This parameter must be a number between Min_Data = 1 and Max_Data = 255 */ 167 168 uint8_t ch_num; /*!< Host channel number. 169 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 170 171 uint8_t ep_num; /*!< Endpoint number. 172 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 173 174 uint8_t ep_is_in; /*!< Endpoint direction 175 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 176 177 uint8_t speed; /*!< USB Host Channel speed. 178 This parameter can be any value of @ref HCD_Device_Speed: 179 (HCD_DEVICE_SPEED_xxx) */ 180 181 uint8_t do_ping; /*!< Enable or disable the use of the PING protocol for HS mode. */ 182 183 uint8_t process_ping; /*!< Execute the PING protocol for HS mode. */ 184 185 uint8_t ep_type; /*!< Endpoint Type. 186 This parameter can be any value of @ref USB_LL_EP_Type */ 187 188 uint16_t max_packet; /*!< Endpoint Max packet size. 189 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ 190 191 uint8_t data_pid; /*!< Initial data PID. 192 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 193 194 uint8_t *xfer_buff; /*!< Pointer to transfer buffer. */ 195 196 uint32_t XferSize; /*!< OTG Channel transfer size. */ 197 198 uint32_t xfer_len; /*!< Current transfer length. */ 199 200 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer. */ 201 202 uint8_t toggle_in; /*!< IN transfer current toggle flag. 203 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 204 205 uint8_t toggle_out; /*!< OUT transfer current toggle flag 206 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 207 208 uint32_t dma_addr; /*!< 32 bits aligned transfer buffer address. */ 209 210 uint32_t ErrCnt; /*!< Host channel error count. */ 211 212 USB_OTG_URBStateTypeDef urb_state; /*!< URB state. 213 This parameter can be any value of @ref USB_OTG_URBStateTypeDef */ 214 215 USB_OTG_HCStateTypeDef state; /*!< Host Channel state. 216 This parameter can be any value of @ref USB_OTG_HCStateTypeDef */ 217 } USB_OTG_HCTypeDef; 218 #endif /* defined (USB_OTG_FS) */ 219 220 #if defined (USB) 221 222 typedef enum 223 { 224 USB_DEVICE_MODE = 0 225 } USB_ModeTypeDef; 226 227 /** 228 * @brief USB Initialization Structure definition 229 */ 230 typedef struct 231 { 232 uint32_t dev_endpoints; /*!< Device Endpoints number. 233 This parameter depends on the used USB core. 234 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 235 236 uint32_t speed; /*!< USB Core speed. 237 This parameter can be any value of @ref PCD_Speed/HCD_Speed 238 (HCD_SPEED_xxx, HCD_SPEED_xxx) */ 239 240 uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. */ 241 242 uint32_t phy_itface; /*!< Select the used PHY interface. 243 This parameter can be any value of @ref PCD_PHY_Module/HCD_PHY_Module */ 244 245 uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. */ 246 247 uint32_t low_power_enable; /*!< Enable or disable Low Power mode */ 248 249 uint32_t lpm_enable; /*!< Enable or disable Battery charging. */ 250 251 uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. */ 252 253 uint32_t dma_enable; /*!< dma_enable state unused, DMA not supported by FS instance */ 254 } USB_CfgTypeDef; 255 256 typedef struct 257 { 258 uint8_t num; /*!< Endpoint number 259 This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ 260 261 uint8_t is_in; /*!< Endpoint direction 262 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 263 264 uint8_t is_stall; /*!< Endpoint stall condition 265 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 266 267 uint8_t type; /*!< Endpoint type 268 This parameter can be any value of @ref USB_EP_Type */ 269 270 uint8_t data_pid_start; /*!< Initial data PID 271 This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ 272 273 uint16_t pmaadress; /*!< PMA Address 274 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ 275 276 uint16_t pmaaddr0; /*!< PMA Address0 277 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ 278 279 uint16_t pmaaddr1; /*!< PMA Address1 280 This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ 281 282 uint8_t doublebuffer; /*!< Double buffer enable 283 This parameter can be 0 or 1 */ 284 285 uint16_t tx_fifo_num; /*!< This parameter is not required by USB Device FS peripheral, it is used 286 only by USB OTG FS peripheral 287 This parameter is added to ensure compatibility across USB peripherals */ 288 289 uint32_t maxpacket; /*!< Endpoint Max packet size 290 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ 291 292 uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ 293 294 uint32_t xfer_len; /*!< Current transfer length */ 295 296 uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ 297 298 uint32_t xfer_len_db; /*!< double buffer transfer length used with bulk double buffer in */ 299 300 uint8_t xfer_fill_db; /*!< double buffer Need to Fill new buffer used with bulk_in */ 301 302 } USB_EPTypeDef; 303 #endif /* defined (USB) */ 304 305 /* Exported constants --------------------------------------------------------*/ 306 307 /** @defgroup PCD_Exported_Constants PCD Exported Constants 308 * @{ 309 */ 310 311 #if defined (USB_OTG_FS) 312 /** @defgroup USB_OTG_CORE VERSION ID 313 * @{ 314 */ 315 #define USB_OTG_CORE_ID_300A 0x4F54300AU 316 #define USB_OTG_CORE_ID_310A 0x4F54310AU 317 /** 318 * @} 319 */ 320 321 /** @defgroup USB_Core_Mode_ USB Core Mode 322 * @{ 323 */ 324 #define USB_OTG_MODE_DEVICE 0U 325 #define USB_OTG_MODE_HOST 1U 326 #define USB_OTG_MODE_DRD 2U 327 /** 328 * @} 329 */ 330 331 /** @defgroup USB_LL Device Speed 332 * @{ 333 */ 334 #define USBD_FS_SPEED 2U 335 #define USBH_FSLS_SPEED 1U 336 /** 337 * @} 338 */ 339 340 /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed 341 * @{ 342 */ 343 #define USB_OTG_SPEED_FULL 3U 344 /** 345 * @} 346 */ 347 348 /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY 349 * @{ 350 */ 351 #define USB_OTG_EMBEDDED_PHY 2U 352 /** 353 * @} 354 */ 355 356 /** @defgroup USB_LL_Turnaround_Timeout Turnaround Timeout Value 357 * @{ 358 */ 359 #ifndef USBD_FS_TRDT_VALUE 360 #define USBD_FS_TRDT_VALUE 5U 361 #define USBD_DEFAULT_TRDT_VALUE 9U 362 #endif /* USBD_HS_TRDT_VALUE */ 363 /** 364 * @} 365 */ 366 367 /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS 368 * @{ 369 */ 370 #define USB_OTG_FS_MAX_PACKET_SIZE 64U 371 #define USB_OTG_MAX_EP0_SIZE 64U 372 /** 373 * @} 374 */ 375 376 /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency 377 * @{ 378 */ 379 #define DSTS_ENUMSPD_HS_PHY_30MHZ_OR_60MHZ (0U << 1) 380 #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ (1U << 1) 381 #define DSTS_ENUMSPD_FS_PHY_48MHZ (3U << 1) 382 /** 383 * @} 384 */ 385 386 /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval 387 * @{ 388 */ 389 #define DCFG_FRAME_INTERVAL_80 0U 390 #define DCFG_FRAME_INTERVAL_85 1U 391 #define DCFG_FRAME_INTERVAL_90 2U 392 #define DCFG_FRAME_INTERVAL_95 3U 393 /** 394 * @} 395 */ 396 397 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS 398 * @{ 399 */ 400 #define EP_MPS_64 0U 401 #define EP_MPS_32 1U 402 #define EP_MPS_16 2U 403 #define EP_MPS_8 3U 404 /** 405 * @} 406 */ 407 408 /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed 409 * @{ 410 */ 411 #define EP_SPEED_LOW 0U 412 #define EP_SPEED_FULL 1U 413 #define EP_SPEED_HIGH 2U 414 /** 415 * @} 416 */ 417 418 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type 419 * @{ 420 */ 421 #define EP_TYPE_CTRL 0U 422 #define EP_TYPE_ISOC 1U 423 #define EP_TYPE_BULK 2U 424 #define EP_TYPE_INTR 3U 425 #define EP_TYPE_MSK 3U 426 /** 427 * @} 428 */ 429 430 /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines 431 * @{ 432 */ 433 #define STS_GOUT_NAK 1U 434 #define STS_DATA_UPDT 2U 435 #define STS_XFER_COMP 3U 436 #define STS_SETUP_COMP 4U 437 #define STS_SETUP_UPDT 6U 438 /** 439 * @} 440 */ 441 442 /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines 443 * @{ 444 */ 445 #define HCFG_30_60_MHZ 0U 446 #define HCFG_48_MHZ 1U 447 #define HCFG_6_MHZ 2U 448 /** 449 * @} 450 */ 451 452 /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines 453 * @{ 454 */ 455 #define HPRT0_PRTSPD_HIGH_SPEED 0U 456 #define HPRT0_PRTSPD_FULL_SPEED 1U 457 #define HPRT0_PRTSPD_LOW_SPEED 2U 458 /** 459 * @} 460 */ 461 462 #define HCCHAR_CTRL 0U 463 #define HCCHAR_ISOC 1U 464 #define HCCHAR_BULK 2U 465 #define HCCHAR_INTR 3U 466 467 #define HC_PID_DATA0 0U 468 #define HC_PID_DATA2 1U 469 #define HC_PID_DATA1 2U 470 #define HC_PID_SETUP 3U 471 472 #define GRXSTS_PKTSTS_IN 2U 473 #define GRXSTS_PKTSTS_IN_XFER_COMP 3U 474 #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR 5U 475 #define GRXSTS_PKTSTS_CH_HALTED 7U 476 477 #define USBx_PCGCCTL *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_PCGCCTL_BASE) 478 #define USBx_HPRT0 *(__IO uint32_t *)((uint32_t)USBx_BASE + USB_OTG_HOST_PORT_BASE) 479 480 #define USBx_DEVICE ((USB_OTG_DeviceTypeDef *)(USBx_BASE + USB_OTG_DEVICE_BASE)) 481 #define USBx_INEP(i) ((USB_OTG_INEndpointTypeDef *)(USBx_BASE\ 482 + USB_OTG_IN_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) 483 484 #define USBx_OUTEP(i) ((USB_OTG_OUTEndpointTypeDef *)(USBx_BASE\ 485 + USB_OTG_OUT_ENDPOINT_BASE + ((i) * USB_OTG_EP_REG_SIZE))) 486 487 #define USBx_DFIFO(i) *(__IO uint32_t *)(USBx_BASE + USB_OTG_FIFO_BASE + ((i) * USB_OTG_FIFO_SIZE)) 488 489 #define USBx_HOST ((USB_OTG_HostTypeDef *)(USBx_BASE + USB_OTG_HOST_BASE)) 490 #define USBx_HC(i) ((USB_OTG_HostChannelTypeDef *)(USBx_BASE\ 491 + USB_OTG_HOST_CHANNEL_BASE\ 492 + ((i) * USB_OTG_HOST_CHANNEL_SIZE))) 493 494 #endif /* defined (USB_OTG_FS) */ 495 496 #if defined (USB) 497 /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS 498 * @{ 499 */ 500 #define EP_MPS_64 0U 501 #define EP_MPS_32 1U 502 #define EP_MPS_16 2U 503 #define EP_MPS_8 3U 504 /** 505 * @} 506 */ 507 508 /** @defgroup USB_LL_EP_Type USB Low Layer EP Type 509 * @{ 510 */ 511 #define EP_TYPE_CTRL 0U 512 #define EP_TYPE_ISOC 1U 513 #define EP_TYPE_BULK 2U 514 #define EP_TYPE_INTR 3U 515 #define EP_TYPE_MSK 3U 516 /** 517 * @} 518 */ 519 520 /** @defgroup USB_LL Device Speed 521 * @{ 522 */ 523 #define USBD_FS_SPEED 2U 524 /** 525 * @} 526 */ 527 528 #define BTABLE_ADDRESS 0x000U 529 #define PMA_ACCESS 1U 530 #endif /* defined (USB) */ 531 #if defined (USB_OTG_FS) 532 #define EP_ADDR_MSK 0xFU 533 #endif /* defined (USB_OTG_FS) */ 534 #if defined (USB) 535 #define EP_ADDR_MSK 0x7U 536 #endif /* defined (USB) */ 537 538 #ifndef USB_EP_RX_STRX 539 #define USB_EP_RX_STRX (0x3U << 12) 540 #endif /* USB_EP_RX_STRX */ 541 542 #ifndef USE_USB_DOUBLE_BUFFER 543 #define USE_USB_DOUBLE_BUFFER 1U 544 #endif /* USE_USB_DOUBLE_BUFFER */ 545 /** 546 * @} 547 */ 548 549 /* Exported macro ------------------------------------------------------------*/ 550 /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros 551 * @{ 552 */ 553 #if defined (USB_OTG_FS) 554 #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__)) 555 #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__) ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__)) 556 557 #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__)) 558 #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__) (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__)) 559 #endif /* defined (USB_OTG_FS) */ 560 /** 561 * @} 562 */ 563 564 /* Exported functions --------------------------------------------------------*/ 565 /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions 566 * @{ 567 */ 568 #if defined (USB_OTG_FS) 569 HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); 570 HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); 571 HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx); 572 HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx); 573 HAL_StatusTypeDef USB_SetTurnaroundTime(USB_OTG_GlobalTypeDef *USBx, uint32_t hclk, uint8_t speed); 574 HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx, USB_ModeTypeDef mode); 575 HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx, uint8_t speed); 576 HAL_StatusTypeDef USB_FlushRxFifo(USB_OTG_GlobalTypeDef *USBx); 577 HAL_StatusTypeDef USB_FlushTxFifo(USB_OTG_GlobalTypeDef *USBx, uint32_t num); 578 HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 579 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 580 HAL_StatusTypeDef USB_ActivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 581 HAL_StatusTypeDef USB_DeactivateDedicatedEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 582 HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 583 HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 584 HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, 585 uint8_t ch_ep_num, uint16_t len); 586 587 void *USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len); 588 HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 589 HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 590 HAL_StatusTypeDef USB_EPStopXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep); 591 HAL_StatusTypeDef USB_SetDevAddress(USB_OTG_GlobalTypeDef *USBx, uint8_t address); 592 HAL_StatusTypeDef USB_DevConnect(USB_OTG_GlobalTypeDef *USBx); 593 HAL_StatusTypeDef USB_DevDisconnect(USB_OTG_GlobalTypeDef *USBx); 594 HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx); 595 HAL_StatusTypeDef USB_ActivateSetup(USB_OTG_GlobalTypeDef *USBx); 596 HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup); 597 uint8_t USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx); 598 uint32_t USB_GetMode(USB_OTG_GlobalTypeDef *USBx); 599 uint32_t USB_ReadInterrupts(USB_OTG_GlobalTypeDef *USBx); 600 uint32_t USB_ReadDevAllOutEpInterrupt(USB_OTG_GlobalTypeDef *USBx); 601 uint32_t USB_ReadDevOutEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); 602 uint32_t USB_ReadDevAllInEpInterrupt(USB_OTG_GlobalTypeDef *USBx); 603 uint32_t USB_ReadDevInEPInterrupt(USB_OTG_GlobalTypeDef *USBx, uint8_t epnum); 604 void USB_ClearInterrupts(USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt); 605 606 HAL_StatusTypeDef USB_HostInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg); 607 HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx, uint8_t freq); 608 HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx); 609 HAL_StatusTypeDef USB_DriveVbus(USB_OTG_GlobalTypeDef *USBx, uint8_t state); 610 uint32_t USB_GetHostSpeed(USB_OTG_GlobalTypeDef *USBx); 611 uint32_t USB_GetCurrentFrame(USB_OTG_GlobalTypeDef *USBx); 612 HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num, 613 uint8_t epnum, uint8_t dev_address, uint8_t speed, 614 uint8_t ep_type, uint16_t mps); 615 HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, 616 USB_OTG_HCTypeDef *hc); 617 618 uint32_t USB_HC_ReadInterrupt(USB_OTG_GlobalTypeDef *USBx); 619 HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx, uint8_t hc_num); 620 HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx, uint8_t ch_num); 621 HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx); 622 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); 623 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx); 624 #endif /* defined (USB_OTG_FS) */ 625 626 #if defined (USB) 627 HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); 628 HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef cfg); 629 HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx); 630 HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx); 631 HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx, USB_ModeTypeDef mode); 632 HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx, uint8_t speed); 633 HAL_StatusTypeDef USB_FlushRxFifo(USB_TypeDef *USBx); 634 HAL_StatusTypeDef USB_FlushTxFifo(USB_TypeDef *USBx, uint32_t num); 635 636 #if defined (HAL_PCD_MODULE_ENABLED) 637 HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); 638 HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep); 639 HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); 640 HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); 641 HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx, USB_EPTypeDef *ep); 642 HAL_StatusTypeDef USB_EPStopXfer(USB_TypeDef *USBx, USB_EPTypeDef *ep); 643 #endif /* defined (HAL_PCD_MODULE_ENABLED) */ 644 645 HAL_StatusTypeDef USB_SetDevAddress(USB_TypeDef *USBx, uint8_t address); 646 HAL_StatusTypeDef USB_DevConnect(USB_TypeDef *USBx); 647 HAL_StatusTypeDef USB_DevDisconnect(USB_TypeDef *USBx); 648 HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx); 649 HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup); 650 HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, 651 uint8_t ch_ep_num, uint16_t len); 652 653 void *USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len); 654 655 uint32_t USB_ReadInterrupts(USB_TypeDef *USBx); 656 uint32_t USB_ReadDevAllOutEpInterrupt(USB_TypeDef *USBx); 657 uint32_t USB_ReadDevOutEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); 658 uint32_t USB_ReadDevAllInEpInterrupt(USB_TypeDef *USBx); 659 uint32_t USB_ReadDevInEPInterrupt(USB_TypeDef *USBx, uint8_t epnum); 660 void USB_ClearInterrupts(USB_TypeDef *USBx, uint32_t interrupt); 661 HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx); 662 HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx); 663 664 void USB_WritePMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, 665 uint16_t wPMABufAddr, uint16_t wNBytes); 666 667 void USB_ReadPMA(USB_TypeDef *USBx, uint8_t *pbUsrBuf, 668 uint16_t wPMABufAddr, uint16_t wNBytes); 669 #endif /* defined (USB) */ 670 /** 671 * @} 672 */ 673 674 /** 675 * @} 676 */ 677 678 /** 679 * @} 680 */ 681 682 /** 683 * @} 684 */ 685 #endif /* defined (USB) || defined (USB_OTG_FS) */ 686 687 #ifdef __cplusplus 688 } 689 #endif /* __cplusplus */ 690 691 692 #endif /* STM32L4xx_LL_USB_H */ 693