Subversion Repositories DashDisplay

Rev

Rev 2 | Blame | Compare with Previous | Last modification | View Log | Download | RSS feed

  1. /**
  2.   ******************************************************************************
  3.   * @file    stm32f1xx_ll_usb.h
  4.   * @author  MCD Application Team
  5.   * @version V1.0.4
  6.   * @date    29-April-2016
  7.   * @brief   Header file of USB Low Layer HAL module.
  8.   ******************************************************************************
  9.   * @attention
  10.   *
  11.   * <h2><center>&copy; COPYRIGHT(c) 2016 STMicroelectronics</center></h2>
  12.   *
  13.   * Redistribution and use in source and binary forms, with or without modification,
  14.   * are permitted provided that the following conditions are met:
  15.   *   1. Redistributions of source code must retain the above copyright notice,
  16.   *      this list of conditions and the following disclaimer.
  17.   *   2. Redistributions in binary form must reproduce the above copyright notice,
  18.   *      this list of conditions and the following disclaimer in the documentation
  19.   *      and/or other materials provided with the distribution.
  20.   *   3. Neither the name of STMicroelectronics nor the names of its contributors
  21.   *      may be used to endorse or promote products derived from this software
  22.   *      without specific prior written permission.
  23.   *
  24.   * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25.   * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26.   * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27.   * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28.   * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29.   * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30.   * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31.   * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32.   * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33.   * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34.   *
  35.   ******************************************************************************
  36.   */
  37.  
  38. /* Define to prevent recursive inclusion -------------------------------------*/
  39. #ifndef __STM32F1xx_LL_USB_H
  40. #define __STM32F1xx_LL_USB_H
  41.  
  42. #ifdef __cplusplus
  43.  extern "C" {
  44. #endif
  45.  
  46. #if defined(STM32F102x6) || defined(STM32F102xB) || \
  47.     defined(STM32F103x6) || defined(STM32F103xB) || \
  48.     defined(STM32F103xE) || defined(STM32F103xG) || \
  49.     defined(STM32F105xC) || defined(STM32F107xC)
  50.  
  51. /* Includes ------------------------------------------------------------------*/
  52. #include "stm32f1xx_hal_def.h"
  53.  
  54. /** @addtogroup STM32F1xx_HAL_Driver
  55.   * @{
  56.   */
  57.  
  58. /** @addtogroup USB_LL
  59.   * @{
  60.   */
  61.  
  62. /* Exported types ------------------------------------------------------------*/
  63. /** @defgroup USB_LL_Exported_Types USB Low Layer Exported Types
  64.   * @{
  65.   */
  66. /**
  67.   * @brief  USB Mode definition  
  68.   */
  69. typedef enum
  70. {
  71.    USB_DEVICE_MODE  = 0,
  72.    USB_HOST_MODE    = 1,
  73.    USB_DRD_MODE     = 2
  74. }USB_ModeTypeDef;
  75.  
  76. #if defined (USB_OTG_FS)
  77. /**
  78.   * @brief  URB States definition
  79.   */
  80. typedef enum {
  81.   URB_IDLE = 0,
  82.   URB_DONE,
  83.   URB_NOTREADY,
  84.   URB_NYET,
  85.   URB_ERROR,
  86.   URB_STALL
  87. }USB_OTG_URBStateTypeDef;
  88.  
  89. /**
  90.   * @brief  Host channel States  definition
  91.   */
  92. typedef enum {
  93.   HC_IDLE = 0,
  94.   HC_XFRC,
  95.   HC_HALTED,
  96.   HC_NAK,
  97.   HC_NYET,
  98.   HC_STALL,
  99.   HC_XACTERR,  
  100.   HC_BBLERR,  
  101.   HC_DATATGLERR
  102. }USB_OTG_HCStateTypeDef;
  103.  
  104. /**
  105.   * @brief  USB OTG Initialization Structure definition  
  106.   */
  107. typedef struct
  108. {
  109.   uint32_t dev_endpoints;        /*!< Device Endpoints number.
  110.                                       This parameter depends on the used USB core.
  111.                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
  112.  
  113.   uint32_t Host_channels;        /*!< Host Channels number.
  114.                                       This parameter Depends on the used USB core.  
  115.                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
  116.  
  117.   uint32_t speed;                /*!< USB Core speed.
  118.                                       This parameter can be any value of @ref USB_Core_Speed_                */
  119.  
  120.   uint32_t ep0_mps;              /*!< Set the Endpoint 0 Max Packet size.
  121.                                       This parameter can be any value of @ref USB_EP0_MPS_                   */
  122.  
  123.   uint32_t Sof_enable;           /*!< Enable or disable the output of the SOF signal.                        */
  124.  
  125.   uint32_t low_power_enable;     /*!< Enable or disable the low power mode.                                  */
  126.  
  127.   uint32_t vbus_sensing_enable;  /*!< Enable or disable the VBUS Sensing feature.                            */
  128.  
  129.   uint32_t use_external_vbus;    /*!< Enable or disable the use of the external VBUS.                        */
  130. }USB_OTG_CfgTypeDef;
  131.  
  132. typedef struct
  133. {
  134.   uint8_t   num;            /*!< Endpoint number
  135.                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15    */
  136.  
  137.   uint8_t   is_in;          /*!< Endpoint direction
  138.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
  139.  
  140.   uint8_t   is_stall;       /*!< Endpoint stall condition
  141.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
  142.  
  143.   uint8_t   type;           /*!< Endpoint type
  144.                                  This parameter can be any value of @ref USB_EP_Type_                     */
  145.  
  146.   uint8_t   data_pid_start; /*!< Initial data PID
  147.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
  148.  
  149.   uint8_t   even_odd_frame; /*!< IFrame parity
  150.                                  This parameter must be a number between Min_Data = 0 and Max_Data = 1    */
  151.  
  152.   uint16_t  tx_fifo_num;    /*!< Transmission FIFO number
  153.                                  This parameter must be a number between Min_Data = 1 and Max_Data = 15   */
  154.  
  155.   uint32_t  maxpacket;      /*!< Endpoint Max packet size
  156.                                  This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
  157.  
  158.   uint8_t   *xfer_buff;     /*!< Pointer to transfer buffer                                               */
  159.  
  160.   uint32_t  dma_addr;       /*!< 32 bits aligned transfer buffer address                                  */
  161.  
  162.   uint32_t  xfer_len;       /*!< Current transfer length                                                  */
  163.  
  164.   uint32_t  xfer_count;     /*!< Partial transfer length in case of multi packet transfer                 */
  165. }USB_OTG_EPTypeDef;
  166.  
  167. typedef struct
  168. {
  169.   uint8_t   dev_addr ;     /*!< USB device address.
  170.                                 This parameter must be a number between Min_Data = 1 and Max_Data = 255    */
  171.  
  172.   uint8_t   ch_num;        /*!< Host channel number.
  173.                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
  174.  
  175.   uint8_t   ep_num;        /*!< Endpoint number.
  176.                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15     */
  177.  
  178.   uint8_t   ep_is_in;      /*!< Endpoint direction
  179.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
  180.  
  181.   uint8_t   speed;         /*!< USB Host speed.
  182.                                 This parameter can be any value of @ref USB_Core_Speed_                    */
  183.  
  184.   uint8_t   do_ping;       /*!< Enable or disable the use of the PING protocol for HS mode.                */
  185.  
  186.   uint8_t   process_ping;  /*!< Execute the PING protocol for HS mode.                                     */
  187.  
  188.   uint8_t   ep_type;       /*!< Endpoint Type.
  189.                                 This parameter can be any value of @ref USB_EP_Type_                       */
  190.  
  191.   uint16_t  max_packet;    /*!< Endpoint Max packet size.
  192.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 64KB   */
  193.  
  194.   uint8_t   data_pid;      /*!< Initial data PID.
  195.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
  196.  
  197.   uint8_t   *xfer_buff;    /*!< Pointer to transfer buffer.                                                */
  198.  
  199.   uint32_t  xfer_len;      /*!< Current transfer length.                                                   */
  200.  
  201.   uint32_t  xfer_count;    /*!< Partial transfer length in case of multi packet transfer.                  */
  202.  
  203.   uint8_t   toggle_in;     /*!< IN transfer current toggle flag.
  204.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
  205.  
  206.   uint8_t   toggle_out;    /*!< OUT transfer current toggle flag
  207.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1      */
  208.  
  209.   uint32_t  dma_addr;      /*!< 32 bits aligned transfer buffer address.                                   */
  210.  
  211.   uint32_t  ErrCnt;        /*!< Host channel error count.*/
  212.  
  213.   USB_OTG_URBStateTypeDef  urb_state;  /*!< URB state.
  214.                                            This parameter can be any value of @ref USB_OTG_URBStateTypeDef */
  215.  
  216.   USB_OTG_HCStateTypeDef   state;     /*!< Host Channel state.
  217.                                            This parameter can be any value of @ref USB_OTG_HCStateTypeDef  */
  218. }USB_OTG_HCTypeDef;
  219. #endif /* USB_OTG_FS */
  220.  
  221. #if defined (USB)
  222. /**
  223.   * @brief  USB Initialization Structure definition  
  224.   */
  225. typedef struct
  226. {
  227.   uint32_t dev_endpoints;        /*!< Device Endpoints number.
  228.                                       This parameter depends on the used USB core.  
  229.                                       This parameter must be a number between Min_Data = 1 and Max_Data = 15 */
  230.  
  231.   uint32_t speed;                /*!< USB Core speed.
  232.                                       This parameter can be any value of @ref USB_Core_Speed                 */
  233.  
  234.   uint32_t ep0_mps;              /*!< Set the Endpoint 0 Max Packet size.
  235.                                       This parameter can be any value of @ref USB_EP0_MPS                    */
  236.  
  237.   uint32_t phy_itface;           /*!< Select the used PHY interface.
  238.                                       This parameter can be any value of @ref USB_Core_PHY                   */
  239.  
  240.   uint32_t Sof_enable;           /*!< Enable or disable the output of the SOF signal.                        */
  241.  
  242.   uint32_t low_power_enable;       /*!< Enable or disable Low Power mode                                      */
  243.  
  244.   uint32_t lpm_enable;             /*!< Enable or disable Battery charging.                                  */
  245.  
  246.   uint32_t battery_charging_enable; /*!< Enable or disable Battery charging.                                  */
  247. } USB_CfgTypeDef;
  248.  
  249. typedef struct
  250. {
  251.   uint8_t   num;            /*!< Endpoint number
  252.                                 This parameter must be a number between Min_Data = 1 and Max_Data = 15    */
  253.  
  254.   uint8_t   is_in;          /*!< Endpoint direction
  255.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
  256.  
  257.   uint8_t   is_stall;       /*!< Endpoint stall condition
  258.                                 This parameter must be a number between Min_Data = 0 and Max_Data = 1     */
  259.  
  260.   uint8_t   type;           /*!< Endpoint type
  261.                                  This parameter can be any value of @ref USB_EP_Type                      */
  262.  
  263.   uint16_t  pmaadress;      /*!< PMA Address
  264.                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
  265.  
  266.   uint16_t  pmaaddr0;       /*!< PMA Address0
  267.                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
  268.  
  269.   uint16_t  pmaaddr1;        /*!< PMA Address1
  270.                                  This parameter can be any value between Min_addr = 0 and Max_addr = 1K   */
  271.  
  272.   uint8_t   doublebuffer;    /*!< Double buffer enable
  273.                                  This parameter can be 0 or 1                                             */
  274.  
  275.   uint16_t  tx_fifo_num;    /*!< This parameter is not required by USB Device FS peripheral, it is used
  276.                                  only by USB OTG FS peripheral    
  277.                                  This parameter is added to ensure compatibility across USB peripherals   */
  278.  
  279.   uint32_t  maxpacket;      /*!< Endpoint Max packet size
  280.                                  This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */
  281.  
  282.   uint8_t   *xfer_buff;     /*!< Pointer to transfer buffer                                               */
  283.  
  284.   uint32_t  xfer_len;       /*!< Current transfer length                                                  */
  285.  
  286.   uint32_t  xfer_count;     /*!< Partial transfer length in case of multi packet transfer                 */
  287.  
  288. } USB_EPTypeDef;
  289. #endif /* USB */
  290. /**
  291.   * @}
  292.   */
  293.  
  294. /* Exported constants --------------------------------------------------------*/
  295. /** @defgroup USB_LL_Exported_Constants USB Low Layer Exported Constants
  296.   * @{
  297.   */
  298. #if defined (USB_OTG_FS)
  299. /** @defgroup USB_LL_Core_Mode USB Low Layer Core Mode
  300.   * @{
  301.   */
  302. #define USB_OTG_MODE_DEVICE                    0
  303. #define USB_OTG_MODE_HOST                      1
  304. #define USB_OTG_MODE_DRD                       2
  305. /**
  306.   * @}
  307.   */
  308.  
  309. /** @defgroup USB_LL_Core_Speed USB Low Layer Core Speed
  310.   * @{
  311.   */
  312. #define USB_OTG_SPEED_LOW                      2
  313. #define USB_OTG_SPEED_FULL                     3
  314.  
  315. /**
  316.   * @}
  317.   */
  318.  
  319. /** @defgroup USB_LL_Core_PHY USB Low Layer Core PHY
  320.   * @{
  321.   */
  322. #define USB_OTG_ULPI_PHY                       1
  323. #define USB_OTG_EMBEDDED_PHY                   2
  324. /**
  325.   * @}
  326.   */
  327.  
  328. /** @defgroup USB_LL_Core_MPS USB Low Layer Core MPS
  329.   * @{
  330.   */
  331. #define USB_OTG_FS_MAX_PACKET_SIZE             64
  332. #define USB_OTG_MAX_EP0_SIZE                   64
  333. /**
  334.   * @}
  335.   */
  336.  
  337. /** @defgroup USB_LL_Core_PHY_Frequency USB Low Layer Core PHY Frequency
  338.   * @{
  339.   */
  340. #define DSTS_ENUMSPD_FS_PHY_30MHZ_OR_60MHZ     (1 << 1)
  341. #define DSTS_ENUMSPD_LS_PHY_6MHZ               (2 << 1)
  342. #define DSTS_ENUMSPD_FS_PHY_48MHZ              (3 << 1)
  343. /**
  344.   * @}
  345.   */
  346.  
  347. /** @defgroup USB_LL_CORE_Frame_Interval USB Low Layer Core Frame Interval
  348.   * @{
  349.   */
  350. #define DCFG_FRAME_INTERVAL_80                 0
  351. #define DCFG_FRAME_INTERVAL_85                 1
  352. #define DCFG_FRAME_INTERVAL_90                 2
  353. #define DCFG_FRAME_INTERVAL_95                 3
  354. /**
  355.   * @}
  356.   */
  357.  
  358. /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
  359.   * @{
  360.   */
  361. #define DEP0CTL_MPS_64                         0
  362. #define DEP0CTL_MPS_32                         1
  363. #define DEP0CTL_MPS_16                         2
  364. #define DEP0CTL_MPS_8                          3
  365. /**
  366.   * @}
  367.   */
  368.  
  369. /** @defgroup USB_LL_EP_Speed USB Low Layer EP Speed
  370.   * @{
  371.   */
  372. #define EP_SPEED_LOW                           0
  373. #define EP_SPEED_FULL                          1
  374. #define EP_SPEED_HIGH                          2
  375. /**
  376.   * @}
  377.   */
  378.  
  379. /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
  380.   * @{
  381.   */
  382. #define EP_TYPE_CTRL                           0
  383. #define EP_TYPE_ISOC                           1
  384. #define EP_TYPE_BULK                           2
  385. #define EP_TYPE_INTR                           3
  386. #define EP_TYPE_MSK                            3
  387. /**
  388.   * @}
  389.   */
  390.  
  391. /** @defgroup USB_LL_STS_Defines USB Low Layer STS Defines
  392.   * @{
  393.   */
  394. #define STS_GOUT_NAK                           1
  395. #define STS_DATA_UPDT                          2
  396. #define STS_XFER_COMP                          3
  397. #define STS_SETUP_COMP                         4
  398. #define STS_SETUP_UPDT                         6
  399. /**
  400.   * @}
  401.   */
  402.  
  403. /** @defgroup USB_LL_HCFG_SPEED_Defines USB Low Layer HCFG Speed Defines
  404.   * @{
  405.   */
  406. #define HCFG_30_60_MHZ                         0
  407. #define HCFG_48_MHZ                            1
  408. #define HCFG_6_MHZ                             2
  409. /**
  410.   * @}
  411.   */
  412.  
  413. /** @defgroup USB_LL_HPRT0_PRTSPD_SPEED_Defines USB Low Layer HPRT0 PRTSPD Speed Defines
  414.   * @{
  415.   */
  416. #define HPRT0_PRTSPD_HIGH_SPEED                0
  417. #define HPRT0_PRTSPD_FULL_SPEED                1
  418. #define HPRT0_PRTSPD_LOW_SPEED                 2
  419. /**
  420.   * @}
  421.   */
  422.  
  423. #define HCCHAR_CTRL                            0
  424. #define HCCHAR_ISOC                            1
  425. #define HCCHAR_BULK                            2
  426. #define HCCHAR_INTR                            3
  427.  
  428. #define HC_PID_DATA0                           0
  429. #define HC_PID_DATA2                           1
  430. #define HC_PID_DATA1                           2
  431. #define HC_PID_SETUP                           3
  432.  
  433. #define GRXSTS_PKTSTS_IN                       2
  434. #define GRXSTS_PKTSTS_IN_XFER_COMP             3
  435. #define GRXSTS_PKTSTS_DATA_TOGGLE_ERR          5
  436. #define GRXSTS_PKTSTS_CH_HALTED                7
  437.  
  438. #define USBx_PCGCCTL                           *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_PCGCCTL_BASE)
  439. #define USBx_HPRT0                             *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_HOST_PORT_BASE)
  440.  
  441. #define USBx_DEVICE                            ((USB_OTG_DeviceTypeDef *)((uint32_t )USBx + USB_OTG_DEVICE_BASE))
  442. #define USBx_INEP(i)                           ((USB_OTG_INEndpointTypeDef *)((uint32_t)USBx + USB_OTG_IN_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE))
  443. #define USBx_OUTEP(i)                          ((USB_OTG_OUTEndpointTypeDef *)((uint32_t)USBx + USB_OTG_OUT_ENDPOINT_BASE + (i)*USB_OTG_EP_REG_SIZE))
  444. #define USBx_DFIFO(i)                          *(__IO uint32_t *)((uint32_t)USBx + USB_OTG_FIFO_BASE + (i) * USB_OTG_FIFO_SIZE)
  445.  
  446. #define USBx_HOST                              ((USB_OTG_HostTypeDef *)((uint32_t )USBx + USB_OTG_HOST_BASE))
  447. #define USBx_HC(i)                             ((USB_OTG_HostChannelTypeDef *)((uint32_t)USBx + USB_OTG_HOST_CHANNEL_BASE + (i)*USB_OTG_HOST_CHANNEL_SIZE))
  448. #endif /* USB_OTG_FS */
  449.  
  450. #if defined (USB)  
  451. /** @defgroup USB_LL_EP0_MPS USB Low Layer EP0 MPS
  452.   * @{
  453.   */
  454. #define DEP0CTL_MPS_64                         0
  455. #define DEP0CTL_MPS_32                         1
  456. #define DEP0CTL_MPS_16                         2
  457. #define DEP0CTL_MPS_8                          3
  458. /**
  459.   * @}
  460.   */
  461.  
  462. /** @defgroup USB_LL_EP_Type USB Low Layer EP Type
  463.   * @{
  464.   */
  465. #define EP_TYPE_CTRL                           0
  466. #define EP_TYPE_ISOC                           1
  467. #define EP_TYPE_BULK                           2
  468. #define EP_TYPE_INTR                           3
  469. #define EP_TYPE_MSK                            3
  470. /**
  471.   * @}
  472.   */
  473.  
  474. #define BTABLE_ADDRESS                         (0x000)
  475. #endif /* USB */
  476. /**
  477.   * @}
  478.   */
  479.  
  480. /* Exported macros -----------------------------------------------------------*/
  481. /** @defgroup USB_LL_Exported_Macros USB Low Layer Exported Macros
  482.   * @{
  483.   */
  484. #if defined (USB_OTG_FS)
  485. #define USB_MASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)     ((__INSTANCE__)->GINTMSK &= ~(__INTERRUPT__))
  486. #define USB_UNMASK_INTERRUPT(__INSTANCE__, __INTERRUPT__)   ((__INSTANCE__)->GINTMSK |= (__INTERRUPT__))
  487.  
  488. #define CLEAR_IN_EP_INTR(__EPNUM__, __INTERRUPT__)          (USBx_INEP(__EPNUM__)->DIEPINT = (__INTERRUPT__))
  489. #define CLEAR_OUT_EP_INTR(__EPNUM__, __INTERRUPT__)         (USBx_OUTEP(__EPNUM__)->DOEPINT = (__INTERRUPT__))
  490. #endif /* USB_OTG_FS */
  491. /**
  492.   * @}
  493.   */
  494.  
  495. /* Exported functions --------------------------------------------------------*/
  496. /** @addtogroup USB_LL_Exported_Functions USB Low Layer Exported Functions
  497.   * @{
  498.   */
  499. /** @addtogroup USB_LL_Exported_Functions_Group1 Peripheral Control functions
  500.   * @{
  501.   */
  502. #if defined (USB_OTG_FS)
  503. HAL_StatusTypeDef USB_CoreInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
  504. HAL_StatusTypeDef USB_DevInit(USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef Init);
  505. HAL_StatusTypeDef USB_EnableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
  506. HAL_StatusTypeDef USB_DisableGlobalInt(USB_OTG_GlobalTypeDef *USBx);
  507. HAL_StatusTypeDef USB_SetCurrentMode(USB_OTG_GlobalTypeDef *USBx , USB_ModeTypeDef mode);
  508. HAL_StatusTypeDef USB_SetDevSpeed(USB_OTG_GlobalTypeDef *USBx , uint8_t speed);
  509. HAL_StatusTypeDef USB_FlushRxFifo (USB_OTG_GlobalTypeDef *USBx);
  510. HAL_StatusTypeDef USB_FlushTxFifo (USB_OTG_GlobalTypeDef *USBx, uint32_t num );
  511. HAL_StatusTypeDef USB_ActivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
  512. HAL_StatusTypeDef USB_DeactivateEndpoint(USB_OTG_GlobalTypeDef *USBx, USB_OTG_EPTypeDef *ep);
  513. HAL_StatusTypeDef USB_EPStartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
  514. HAL_StatusTypeDef USB_EP0StartXfer(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
  515. HAL_StatusTypeDef USB_WritePacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
  516. void *            USB_ReadPacket(USB_OTG_GlobalTypeDef *USBx, uint8_t *dest, uint16_t len);
  517. HAL_StatusTypeDef USB_EPSetStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
  518. HAL_StatusTypeDef USB_EPClearStall(USB_OTG_GlobalTypeDef *USBx , USB_OTG_EPTypeDef *ep);
  519. HAL_StatusTypeDef USB_SetDevAddress (USB_OTG_GlobalTypeDef *USBx, uint8_t address);
  520. HAL_StatusTypeDef USB_DevConnect (USB_OTG_GlobalTypeDef *USBx);
  521. HAL_StatusTypeDef USB_DevDisconnect (USB_OTG_GlobalTypeDef *USBx);
  522. HAL_StatusTypeDef USB_StopDevice(USB_OTG_GlobalTypeDef *USBx);
  523. HAL_StatusTypeDef USB_ActivateSetup (USB_OTG_GlobalTypeDef *USBx);
  524. HAL_StatusTypeDef USB_EP0_OutStart(USB_OTG_GlobalTypeDef *USBx, uint8_t *psetup);
  525. uint8_t           USB_GetDevSpeed(USB_OTG_GlobalTypeDef *USBx);
  526. uint32_t          USB_GetMode(USB_OTG_GlobalTypeDef *USBx);
  527. uint32_t          USB_ReadInterrupts (USB_OTG_GlobalTypeDef *USBx);
  528. uint32_t          USB_ReadDevAllOutEpInterrupt (USB_OTG_GlobalTypeDef *USBx);
  529. uint32_t          USB_ReadDevOutEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum);
  530. uint32_t          USB_ReadDevAllInEpInterrupt (USB_OTG_GlobalTypeDef *USBx);
  531. uint32_t          USB_ReadDevInEPInterrupt (USB_OTG_GlobalTypeDef *USBx , uint8_t epnum);
  532. void              USB_ClearInterrupts (USB_OTG_GlobalTypeDef *USBx, uint32_t interrupt);
  533.  
  534. HAL_StatusTypeDef USB_HostInit (USB_OTG_GlobalTypeDef *USBx, USB_OTG_CfgTypeDef cfg);
  535. HAL_StatusTypeDef USB_InitFSLSPClkSel(USB_OTG_GlobalTypeDef *USBx , uint8_t freq);
  536. HAL_StatusTypeDef USB_ResetPort(USB_OTG_GlobalTypeDef *USBx);
  537. HAL_StatusTypeDef USB_DriveVbus (USB_OTG_GlobalTypeDef *USBx, uint8_t state);
  538. uint32_t          USB_GetHostSpeed (USB_OTG_GlobalTypeDef *USBx);
  539. uint32_t          USB_GetCurrentFrame (USB_OTG_GlobalTypeDef *USBx);
  540. HAL_StatusTypeDef USB_HC_Init(USB_OTG_GlobalTypeDef *USBx,  
  541.                               uint8_t ch_num,
  542.                               uint8_t epnum,
  543.                               uint8_t dev_address,
  544.                               uint8_t speed,
  545.                               uint8_t ep_type,
  546.                               uint16_t mps);
  547. HAL_StatusTypeDef USB_HC_StartXfer(USB_OTG_GlobalTypeDef *USBx, USB_OTG_HCTypeDef *hc);
  548. uint32_t          USB_HC_ReadInterrupt (USB_OTG_GlobalTypeDef *USBx);
  549. HAL_StatusTypeDef USB_HC_Halt(USB_OTG_GlobalTypeDef *USBx , uint8_t hc_num);
  550. HAL_StatusTypeDef USB_DoPing(USB_OTG_GlobalTypeDef *USBx , uint8_t ch_num);
  551. HAL_StatusTypeDef USB_StopHost(USB_OTG_GlobalTypeDef *USBx);
  552. HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
  553. HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_OTG_GlobalTypeDef *USBx);
  554. #endif /* USB_OTG_FS */
  555.  
  556. #if defined (USB)
  557. HAL_StatusTypeDef USB_CoreInit(USB_TypeDef *USBx, USB_CfgTypeDef Init);
  558. HAL_StatusTypeDef USB_DevInit(USB_TypeDef *USBx, USB_CfgTypeDef Init);
  559. HAL_StatusTypeDef USB_EnableGlobalInt(USB_TypeDef *USBx);
  560. HAL_StatusTypeDef USB_DisableGlobalInt(USB_TypeDef *USBx);
  561. HAL_StatusTypeDef USB_SetCurrentMode(USB_TypeDef *USBx , USB_ModeTypeDef mode);
  562. HAL_StatusTypeDef USB_SetDevSpeed(USB_TypeDef *USBx , uint8_t speed);
  563. HAL_StatusTypeDef USB_FlushRxFifo (USB_TypeDef *USBx);
  564. HAL_StatusTypeDef USB_FlushTxFifo (USB_TypeDef *USBx, uint32_t num );
  565. HAL_StatusTypeDef USB_ActivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  566. HAL_StatusTypeDef USB_DeactivateEndpoint(USB_TypeDef *USBx, USB_EPTypeDef *ep);
  567. HAL_StatusTypeDef USB_EPStartXfer(USB_TypeDef *USBx , USB_EPTypeDef *ep);
  568. HAL_StatusTypeDef USB_WritePacket(USB_TypeDef *USBx, uint8_t *src, uint8_t ch_ep_num, uint16_t len);
  569. void *            USB_ReadPacket(USB_TypeDef *USBx, uint8_t *dest, uint16_t len);
  570. HAL_StatusTypeDef USB_EPSetStall(USB_TypeDef *USBx , USB_EPTypeDef *ep);
  571. HAL_StatusTypeDef USB_EPClearStall(USB_TypeDef *USBx , USB_EPTypeDef *ep);
  572. HAL_StatusTypeDef USB_SetDevAddress (USB_TypeDef *USBx, uint8_t address);
  573. HAL_StatusTypeDef USB_DevConnect (USB_TypeDef *USBx);
  574. HAL_StatusTypeDef USB_DevDisconnect (USB_TypeDef *USBx);
  575. HAL_StatusTypeDef USB_StopDevice(USB_TypeDef *USBx);
  576. HAL_StatusTypeDef USB_EP0_OutStart(USB_TypeDef *USBx, uint8_t *psetup);
  577. uint32_t          USB_ReadInterrupts (USB_TypeDef *USBx);
  578. uint32_t          USB_ReadDevAllOutEpInterrupt (USB_TypeDef *USBx);
  579. uint32_t          USB_ReadDevOutEPInterrupt (USB_TypeDef *USBx , uint8_t epnum);
  580. uint32_t          USB_ReadDevAllInEpInterrupt (USB_TypeDef *USBx);
  581. uint32_t          USB_ReadDevInEPInterrupt (USB_TypeDef *USBx , uint8_t epnum);
  582. void              USB_ClearInterrupts (USB_TypeDef *USBx, uint32_t interrupt);
  583.  
  584. HAL_StatusTypeDef USB_ActivateRemoteWakeup(USB_TypeDef *USBx);
  585. HAL_StatusTypeDef USB_DeActivateRemoteWakeup(USB_TypeDef *USBx);
  586. void USB_WritePMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
  587. void USB_ReadPMA(USB_TypeDef  *USBx, uint8_t *pbUsrBuf, uint16_t wPMABufAddr, uint16_t wNBytes);
  588. #endif /* USB */
  589. /**
  590.   * @}
  591.   */
  592. /**
  593.   * @}
  594.   */
  595.  
  596. /**
  597.   * @}
  598.   */
  599.  
  600. /**
  601.   * @}
  602.   */
  603.  
  604. #endif /* STM32F102x6 || STM32F102xB || */
  605.        /* STM32F103x6 || STM32F103xB || */
  606.        /* STM32F103xE || STM32F103xG || */
  607.        /* STM32F105xC || STM32F107xC    */
  608.  
  609. #ifdef __cplusplus
  610. }
  611. #endif
  612.  
  613.  
  614. #endif /* __STM32F1xx_LL_USB_H */
  615.  
  616. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
  617.