Dataloger
TARGET_NUCLEO_F072RB/stm32f0xx_hal_pcd.h@0:666850d06c9f, 2015-08-20 (annotated)
- Committer:
- jhon309
- Date:
- Thu Aug 20 00:37:14 2015 +0000
- Revision:
- 0:666850d06c9f
ok
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
jhon309 | 0:666850d06c9f | 1 | /** |
jhon309 | 0:666850d06c9f | 2 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 3 | * @file stm32f0xx_hal_pcd.h |
jhon309 | 0:666850d06c9f | 4 | * @author MCD Application Team |
jhon309 | 0:666850d06c9f | 5 | * @version V1.2.0 |
jhon309 | 0:666850d06c9f | 6 | * @date 11-December-2014 |
jhon309 | 0:666850d06c9f | 7 | * @brief Header file of PCD HAL module. |
jhon309 | 0:666850d06c9f | 8 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 9 | * @attention |
jhon309 | 0:666850d06c9f | 10 | * |
jhon309 | 0:666850d06c9f | 11 | * <h2><center>© COPYRIGHT(c) 2014 STMicroelectronics</center></h2> |
jhon309 | 0:666850d06c9f | 12 | * |
jhon309 | 0:666850d06c9f | 13 | * Redistribution and use in source and binary forms, with or without modification, |
jhon309 | 0:666850d06c9f | 14 | * are permitted provided that the following conditions are met: |
jhon309 | 0:666850d06c9f | 15 | * 1. Redistributions of source code must retain the above copyright notice, |
jhon309 | 0:666850d06c9f | 16 | * this list of conditions and the following disclaimer. |
jhon309 | 0:666850d06c9f | 17 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
jhon309 | 0:666850d06c9f | 18 | * this list of conditions and the following disclaimer in the documentation |
jhon309 | 0:666850d06c9f | 19 | * and/or other materials provided with the distribution. |
jhon309 | 0:666850d06c9f | 20 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
jhon309 | 0:666850d06c9f | 21 | * may be used to endorse or promote products derived from this software |
jhon309 | 0:666850d06c9f | 22 | * without specific prior written permission. |
jhon309 | 0:666850d06c9f | 23 | * |
jhon309 | 0:666850d06c9f | 24 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
jhon309 | 0:666850d06c9f | 25 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
jhon309 | 0:666850d06c9f | 26 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
jhon309 | 0:666850d06c9f | 27 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
jhon309 | 0:666850d06c9f | 28 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
jhon309 | 0:666850d06c9f | 29 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
jhon309 | 0:666850d06c9f | 30 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
jhon309 | 0:666850d06c9f | 31 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
jhon309 | 0:666850d06c9f | 32 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
jhon309 | 0:666850d06c9f | 33 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
jhon309 | 0:666850d06c9f | 34 | * |
jhon309 | 0:666850d06c9f | 35 | ****************************************************************************** |
jhon309 | 0:666850d06c9f | 36 | */ |
jhon309 | 0:666850d06c9f | 37 | |
jhon309 | 0:666850d06c9f | 38 | /* Define to prevent recursive inclusion -------------------------------------*/ |
jhon309 | 0:666850d06c9f | 39 | #ifndef __STM32F0xx_HAL_PCD_H |
jhon309 | 0:666850d06c9f | 40 | #define __STM32F0xx_HAL_PCD_H |
jhon309 | 0:666850d06c9f | 41 | |
jhon309 | 0:666850d06c9f | 42 | #ifdef __cplusplus |
jhon309 | 0:666850d06c9f | 43 | extern "C" { |
jhon309 | 0:666850d06c9f | 44 | #endif |
jhon309 | 0:666850d06c9f | 45 | |
jhon309 | 0:666850d06c9f | 46 | #if defined(STM32F042x6) || defined(STM32F048xx) || defined(STM32F072xB) || defined(STM32F078xx) || defined(STM32F070xB)|| defined(STM32F070x6) |
jhon309 | 0:666850d06c9f | 47 | |
jhon309 | 0:666850d06c9f | 48 | /* Includes ------------------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 49 | #include "stm32f0xx_hal_def.h" |
jhon309 | 0:666850d06c9f | 50 | |
jhon309 | 0:666850d06c9f | 51 | /** @addtogroup STM32F0xx_HAL_Driver |
jhon309 | 0:666850d06c9f | 52 | * @{ |
jhon309 | 0:666850d06c9f | 53 | */ |
jhon309 | 0:666850d06c9f | 54 | |
jhon309 | 0:666850d06c9f | 55 | /** @addtogroup PCD |
jhon309 | 0:666850d06c9f | 56 | * @{ |
jhon309 | 0:666850d06c9f | 57 | */ |
jhon309 | 0:666850d06c9f | 58 | |
jhon309 | 0:666850d06c9f | 59 | /* Exported types ------------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 60 | /** @defgroup PCD_Exported_Types PCD Exported Types |
jhon309 | 0:666850d06c9f | 61 | * @{ |
jhon309 | 0:666850d06c9f | 62 | */ |
jhon309 | 0:666850d06c9f | 63 | |
jhon309 | 0:666850d06c9f | 64 | /** |
jhon309 | 0:666850d06c9f | 65 | * @brief PCD State structures definition |
jhon309 | 0:666850d06c9f | 66 | */ |
jhon309 | 0:666850d06c9f | 67 | typedef enum |
jhon309 | 0:666850d06c9f | 68 | { |
jhon309 | 0:666850d06c9f | 69 | PCD_READY = 0x00, |
jhon309 | 0:666850d06c9f | 70 | PCD_ERROR = 0x01, |
jhon309 | 0:666850d06c9f | 71 | PCD_BUSY = 0x02, |
jhon309 | 0:666850d06c9f | 72 | PCD_TIMEOUT = 0x03 |
jhon309 | 0:666850d06c9f | 73 | } PCD_StateTypeDef; |
jhon309 | 0:666850d06c9f | 74 | |
jhon309 | 0:666850d06c9f | 75 | typedef enum |
jhon309 | 0:666850d06c9f | 76 | { |
jhon309 | 0:666850d06c9f | 77 | /* double buffered endpoint direction */ |
jhon309 | 0:666850d06c9f | 78 | PCD_EP_DBUF_OUT, |
jhon309 | 0:666850d06c9f | 79 | PCD_EP_DBUF_IN, |
jhon309 | 0:666850d06c9f | 80 | PCD_EP_DBUF_ERR, |
jhon309 | 0:666850d06c9f | 81 | }PCD_EP_DBUF_DIR; |
jhon309 | 0:666850d06c9f | 82 | |
jhon309 | 0:666850d06c9f | 83 | /* endpoint buffer number */ |
jhon309 | 0:666850d06c9f | 84 | typedef enum |
jhon309 | 0:666850d06c9f | 85 | { |
jhon309 | 0:666850d06c9f | 86 | PCD_EP_NOBUF, |
jhon309 | 0:666850d06c9f | 87 | PCD_EP_BUF0, |
jhon309 | 0:666850d06c9f | 88 | PCD_EP_BUF1 |
jhon309 | 0:666850d06c9f | 89 | }PCD_EP_BUF_NUM; |
jhon309 | 0:666850d06c9f | 90 | |
jhon309 | 0:666850d06c9f | 91 | /** |
jhon309 | 0:666850d06c9f | 92 | * @brief PCD Initialization Structure definition |
jhon309 | 0:666850d06c9f | 93 | */ |
jhon309 | 0:666850d06c9f | 94 | typedef struct |
jhon309 | 0:666850d06c9f | 95 | { |
jhon309 | 0:666850d06c9f | 96 | uint32_t dev_endpoints; /*!< Device Endpoints number. |
jhon309 | 0:666850d06c9f | 97 | This parameter depends on the used USB core. |
jhon309 | 0:666850d06c9f | 98 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
jhon309 | 0:666850d06c9f | 99 | |
jhon309 | 0:666850d06c9f | 100 | uint32_t speed; /*!< USB Core speed. |
jhon309 | 0:666850d06c9f | 101 | This parameter can be any value of @ref PCD_Core_Speed */ |
jhon309 | 0:666850d06c9f | 102 | |
jhon309 | 0:666850d06c9f | 103 | uint32_t ep0_mps; /*!< Set the Endpoint 0 Max Packet size. |
jhon309 | 0:666850d06c9f | 104 | This parameter can be any value of @ref PCD_EP0_MPS */ |
jhon309 | 0:666850d06c9f | 105 | |
jhon309 | 0:666850d06c9f | 106 | uint32_t phy_itface; /*!< Select the used PHY interface. |
jhon309 | 0:666850d06c9f | 107 | This parameter can be any value of @ref PCD_Core_PHY */ |
jhon309 | 0:666850d06c9f | 108 | |
jhon309 | 0:666850d06c9f | 109 | uint32_t Sof_enable; /*!< Enable or disable the output of the SOF signal. |
jhon309 | 0:666850d06c9f | 110 | This parameter can be set to ENABLE or DISABLE */ |
jhon309 | 0:666850d06c9f | 111 | |
jhon309 | 0:666850d06c9f | 112 | uint32_t low_power_enable; /*!< Enable or disable Low Power mode |
jhon309 | 0:666850d06c9f | 113 | This parameter can be set to ENABLE or DISABLE */ |
jhon309 | 0:666850d06c9f | 114 | |
jhon309 | 0:666850d06c9f | 115 | uint32_t lpm_enable; /*!< Enable or disable the Link Power Management . |
jhon309 | 0:666850d06c9f | 116 | This parameter can be set to ENABLE or DISABLE */ |
jhon309 | 0:666850d06c9f | 117 | |
jhon309 | 0:666850d06c9f | 118 | uint32_t battery_charging_enable; /*!< Enable or disable Battery charging. |
jhon309 | 0:666850d06c9f | 119 | This parameter can be set to ENABLE or DISABLE */ |
jhon309 | 0:666850d06c9f | 120 | |
jhon309 | 0:666850d06c9f | 121 | }PCD_InitTypeDef; |
jhon309 | 0:666850d06c9f | 122 | |
jhon309 | 0:666850d06c9f | 123 | typedef struct |
jhon309 | 0:666850d06c9f | 124 | { |
jhon309 | 0:666850d06c9f | 125 | uint8_t num; /*!< Endpoint number |
jhon309 | 0:666850d06c9f | 126 | This parameter must be a number between Min_Data = 1 and Max_Data = 15 */ |
jhon309 | 0:666850d06c9f | 127 | |
jhon309 | 0:666850d06c9f | 128 | uint8_t is_in; /*!< Endpoint direction |
jhon309 | 0:666850d06c9f | 129 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
jhon309 | 0:666850d06c9f | 130 | |
jhon309 | 0:666850d06c9f | 131 | uint8_t is_stall; /*!< Endpoint stall condition |
jhon309 | 0:666850d06c9f | 132 | This parameter must be a number between Min_Data = 0 and Max_Data = 1 */ |
jhon309 | 0:666850d06c9f | 133 | |
jhon309 | 0:666850d06c9f | 134 | uint8_t type; /*!< Endpoint type |
jhon309 | 0:666850d06c9f | 135 | This parameter can be any value of @ref PCD_EP_Type */ |
jhon309 | 0:666850d06c9f | 136 | |
jhon309 | 0:666850d06c9f | 137 | uint16_t pmaadress; /*!< PMA Address |
jhon309 | 0:666850d06c9f | 138 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
jhon309 | 0:666850d06c9f | 139 | |
jhon309 | 0:666850d06c9f | 140 | |
jhon309 | 0:666850d06c9f | 141 | uint16_t pmaaddr0; /*!< PMA Address0 |
jhon309 | 0:666850d06c9f | 142 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
jhon309 | 0:666850d06c9f | 143 | |
jhon309 | 0:666850d06c9f | 144 | |
jhon309 | 0:666850d06c9f | 145 | uint16_t pmaaddr1; /*!< PMA Address1 |
jhon309 | 0:666850d06c9f | 146 | This parameter can be any value between Min_addr = 0 and Max_addr = 1K */ |
jhon309 | 0:666850d06c9f | 147 | |
jhon309 | 0:666850d06c9f | 148 | |
jhon309 | 0:666850d06c9f | 149 | uint8_t doublebuffer; /*!< Double buffer enable |
jhon309 | 0:666850d06c9f | 150 | This parameter can be 0 or 1 */ |
jhon309 | 0:666850d06c9f | 151 | |
jhon309 | 0:666850d06c9f | 152 | uint32_t maxpacket; /*!< Endpoint Max packet size |
jhon309 | 0:666850d06c9f | 153 | This parameter must be a number between Min_Data = 0 and Max_Data = 64KB */ |
jhon309 | 0:666850d06c9f | 154 | |
jhon309 | 0:666850d06c9f | 155 | uint8_t *xfer_buff; /*!< Pointer to transfer buffer */ |
jhon309 | 0:666850d06c9f | 156 | |
jhon309 | 0:666850d06c9f | 157 | |
jhon309 | 0:666850d06c9f | 158 | uint32_t xfer_len; /*!< Current transfer length */ |
jhon309 | 0:666850d06c9f | 159 | |
jhon309 | 0:666850d06c9f | 160 | uint32_t xfer_count; /*!< Partial transfer length in case of multi packet transfer */ |
jhon309 | 0:666850d06c9f | 161 | |
jhon309 | 0:666850d06c9f | 162 | }PCD_EPTypeDef; |
jhon309 | 0:666850d06c9f | 163 | |
jhon309 | 0:666850d06c9f | 164 | typedef USB_TypeDef PCD_TypeDef; |
jhon309 | 0:666850d06c9f | 165 | |
jhon309 | 0:666850d06c9f | 166 | /** |
jhon309 | 0:666850d06c9f | 167 | * @brief PCD Handle Structure definition |
jhon309 | 0:666850d06c9f | 168 | */ |
jhon309 | 0:666850d06c9f | 169 | typedef struct |
jhon309 | 0:666850d06c9f | 170 | { |
jhon309 | 0:666850d06c9f | 171 | PCD_TypeDef *Instance; /*!< Register base address */ |
jhon309 | 0:666850d06c9f | 172 | PCD_InitTypeDef Init; /*!< PCD required parameters */ |
jhon309 | 0:666850d06c9f | 173 | __IO uint8_t USB_Address; /*!< USB Address */ |
jhon309 | 0:666850d06c9f | 174 | PCD_EPTypeDef IN_ep[8]; /*!< IN endpoint parameters */ |
jhon309 | 0:666850d06c9f | 175 | PCD_EPTypeDef OUT_ep[8]; /*!< OUT endpoint parameters */ |
jhon309 | 0:666850d06c9f | 176 | HAL_LockTypeDef Lock; /*!< PCD peripheral status */ |
jhon309 | 0:666850d06c9f | 177 | __IO PCD_StateTypeDef State; /*!< PCD communication state */ |
jhon309 | 0:666850d06c9f | 178 | uint32_t Setup[12]; /*!< Setup packet buffer */ |
jhon309 | 0:666850d06c9f | 179 | void *pData; /*!< Pointer to upper stack Handler */ |
jhon309 | 0:666850d06c9f | 180 | |
jhon309 | 0:666850d06c9f | 181 | } PCD_HandleTypeDef; |
jhon309 | 0:666850d06c9f | 182 | |
jhon309 | 0:666850d06c9f | 183 | /** |
jhon309 | 0:666850d06c9f | 184 | * @} |
jhon309 | 0:666850d06c9f | 185 | */ |
jhon309 | 0:666850d06c9f | 186 | |
jhon309 | 0:666850d06c9f | 187 | #include "stm32f0xx_hal_pcd_ex.h" |
jhon309 | 0:666850d06c9f | 188 | /* Exported constants --------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 189 | /** @defgroup PCD_Exported_Constants PCD Exported Constants |
jhon309 | 0:666850d06c9f | 190 | * @{ |
jhon309 | 0:666850d06c9f | 191 | */ |
jhon309 | 0:666850d06c9f | 192 | |
jhon309 | 0:666850d06c9f | 193 | /** @defgroup PCD_Core_Speed PCD Core Speed |
jhon309 | 0:666850d06c9f | 194 | * @{ |
jhon309 | 0:666850d06c9f | 195 | */ |
jhon309 | 0:666850d06c9f | 196 | #define PCD_SPEED_HIGH 0 /* Not Supported */ |
jhon309 | 0:666850d06c9f | 197 | #define PCD_SPEED_FULL 2 |
jhon309 | 0:666850d06c9f | 198 | /** |
jhon309 | 0:666850d06c9f | 199 | * @} |
jhon309 | 0:666850d06c9f | 200 | */ |
jhon309 | 0:666850d06c9f | 201 | |
jhon309 | 0:666850d06c9f | 202 | /** @defgroup PCD_Core_PHY PCD Core PHY |
jhon309 | 0:666850d06c9f | 203 | * @{ |
jhon309 | 0:666850d06c9f | 204 | */ |
jhon309 | 0:666850d06c9f | 205 | #define PCD_PHY_EMBEDDED 2 |
jhon309 | 0:666850d06c9f | 206 | /** |
jhon309 | 0:666850d06c9f | 207 | * @} |
jhon309 | 0:666850d06c9f | 208 | */ |
jhon309 | 0:666850d06c9f | 209 | |
jhon309 | 0:666850d06c9f | 210 | /** @defgroup PCD_EP0_MPS PCD EP0 MPS |
jhon309 | 0:666850d06c9f | 211 | * @{ |
jhon309 | 0:666850d06c9f | 212 | */ |
jhon309 | 0:666850d06c9f | 213 | #define DEP0CTL_MPS_64 0 |
jhon309 | 0:666850d06c9f | 214 | #define DEP0CTL_MPS_32 1 |
jhon309 | 0:666850d06c9f | 215 | #define DEP0CTL_MPS_16 2 |
jhon309 | 0:666850d06c9f | 216 | #define DEP0CTL_MPS_8 3 |
jhon309 | 0:666850d06c9f | 217 | |
jhon309 | 0:666850d06c9f | 218 | #define PCD_EP0MPS_64 DEP0CTL_MPS_64 |
jhon309 | 0:666850d06c9f | 219 | #define PCD_EP0MPS_32 DEP0CTL_MPS_32 |
jhon309 | 0:666850d06c9f | 220 | #define PCD_EP0MPS_16 DEP0CTL_MPS_16 |
jhon309 | 0:666850d06c9f | 221 | #define PCD_EP0MPS_08 DEP0CTL_MPS_8 |
jhon309 | 0:666850d06c9f | 222 | /** |
jhon309 | 0:666850d06c9f | 223 | * @} |
jhon309 | 0:666850d06c9f | 224 | */ |
jhon309 | 0:666850d06c9f | 225 | |
jhon309 | 0:666850d06c9f | 226 | /** @defgroup PCD_EP_Type PCD EP Type |
jhon309 | 0:666850d06c9f | 227 | * @{ |
jhon309 | 0:666850d06c9f | 228 | */ |
jhon309 | 0:666850d06c9f | 229 | #define PCD_EP_TYPE_CTRL 0 |
jhon309 | 0:666850d06c9f | 230 | #define PCD_EP_TYPE_ISOC 1 |
jhon309 | 0:666850d06c9f | 231 | #define PCD_EP_TYPE_BULK 2 |
jhon309 | 0:666850d06c9f | 232 | #define PCD_EP_TYPE_INTR 3 |
jhon309 | 0:666850d06c9f | 233 | /** |
jhon309 | 0:666850d06c9f | 234 | * @} |
jhon309 | 0:666850d06c9f | 235 | */ |
jhon309 | 0:666850d06c9f | 236 | |
jhon309 | 0:666850d06c9f | 237 | /** @defgroup PCD_ENDP_Type PCD_ENDP_Type |
jhon309 | 0:666850d06c9f | 238 | * @{ |
jhon309 | 0:666850d06c9f | 239 | */ |
jhon309 | 0:666850d06c9f | 240 | |
jhon309 | 0:666850d06c9f | 241 | #define PCD_ENDP0 ((uint8_t)0) |
jhon309 | 0:666850d06c9f | 242 | #define PCD_ENDP1 ((uint8_t)1) |
jhon309 | 0:666850d06c9f | 243 | #define PCD_ENDP2 ((uint8_t)2) |
jhon309 | 0:666850d06c9f | 244 | #define PCD_ENDP3 ((uint8_t)3) |
jhon309 | 0:666850d06c9f | 245 | #define PCD_ENDP4 ((uint8_t)4) |
jhon309 | 0:666850d06c9f | 246 | #define PCD_ENDP5 ((uint8_t)5) |
jhon309 | 0:666850d06c9f | 247 | #define PCD_ENDP6 ((uint8_t)6) |
jhon309 | 0:666850d06c9f | 248 | #define PCD_ENDP7 ((uint8_t)7) |
jhon309 | 0:666850d06c9f | 249 | |
jhon309 | 0:666850d06c9f | 250 | /* Endpoint Kind */ |
jhon309 | 0:666850d06c9f | 251 | #define PCD_SNG_BUF 0 |
jhon309 | 0:666850d06c9f | 252 | #define PCD_DBL_BUF 1 |
jhon309 | 0:666850d06c9f | 253 | |
jhon309 | 0:666850d06c9f | 254 | #define IS_PCD_ALL_INSTANCE IS_USB_ALL_INSTANCE |
jhon309 | 0:666850d06c9f | 255 | /** |
jhon309 | 0:666850d06c9f | 256 | * @} |
jhon309 | 0:666850d06c9f | 257 | */ |
jhon309 | 0:666850d06c9f | 258 | |
jhon309 | 0:666850d06c9f | 259 | /** |
jhon309 | 0:666850d06c9f | 260 | * @} |
jhon309 | 0:666850d06c9f | 261 | */ |
jhon309 | 0:666850d06c9f | 262 | |
jhon309 | 0:666850d06c9f | 263 | /* Exported macros -----------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 264 | |
jhon309 | 0:666850d06c9f | 265 | /** @defgroup PCD_Exported_Macros PCD Exported Macros |
jhon309 | 0:666850d06c9f | 266 | * @brief macros to handle interrupts and specific clock configurations |
jhon309 | 0:666850d06c9f | 267 | * @{ |
jhon309 | 0:666850d06c9f | 268 | */ |
jhon309 | 0:666850d06c9f | 269 | #define __HAL_PCD_GET_FLAG(__HANDLE__, __INTERRUPT__) ((((__HANDLE__)->Instance->ISTR) & (__INTERRUPT__)) == (__INTERRUPT__)) |
jhon309 | 0:666850d06c9f | 270 | #define __HAL_PCD_CLEAR_FLAG(__HANDLE__, __INTERRUPT__) (((__HANDLE__)->Instance->ISTR) &= ~(__INTERRUPT__)) |
jhon309 | 0:666850d06c9f | 271 | |
jhon309 | 0:666850d06c9f | 272 | #define USB_EXTI_LINE_WAKEUP ((uint32_t)0x00040000) /*!< External interrupt line 18 Connected to the USB FS EXTI Line */ |
jhon309 | 0:666850d06c9f | 273 | |
jhon309 | 0:666850d06c9f | 274 | #define __HAL_USB_EXTI_ENABLE_IT() EXTI->IMR |= USB_EXTI_LINE_WAKEUP |
jhon309 | 0:666850d06c9f | 275 | #define __HAL_USB_EXTI_DISABLE_IT() EXTI->IMR &= ~(USB_EXTI_LINE_WAKEUP) |
jhon309 | 0:666850d06c9f | 276 | #define __HAL_USB_EXTI_GENERATE_SWIT(__EXTILINE__) (EXTI->SWIER |= (__EXTILINE__)) |
jhon309 | 0:666850d06c9f | 277 | |
jhon309 | 0:666850d06c9f | 278 | /** |
jhon309 | 0:666850d06c9f | 279 | * @} |
jhon309 | 0:666850d06c9f | 280 | */ |
jhon309 | 0:666850d06c9f | 281 | |
jhon309 | 0:666850d06c9f | 282 | /* Internal macros -----------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 283 | |
jhon309 | 0:666850d06c9f | 284 | /** @defgroup PCD_Private_Macros PCD Private Macros |
jhon309 | 0:666850d06c9f | 285 | * @brief macros to handle interrupts and specific clock configurations |
jhon309 | 0:666850d06c9f | 286 | * @{ |
jhon309 | 0:666850d06c9f | 287 | */ |
jhon309 | 0:666850d06c9f | 288 | |
jhon309 | 0:666850d06c9f | 289 | /* SetENDPOINT */ |
jhon309 | 0:666850d06c9f | 290 | #define PCD_SET_ENDPOINT(USBx, bEpNum,wRegValue) (*(&(USBx)->EP0R + (bEpNum) * 2)= (uint16_t)(wRegValue)) |
jhon309 | 0:666850d06c9f | 291 | |
jhon309 | 0:666850d06c9f | 292 | /* GetENDPOINT */ |
jhon309 | 0:666850d06c9f | 293 | #define PCD_GET_ENDPOINT(USBx, bEpNum) (*(&(USBx)->EP0R + (bEpNum) * 2)) |
jhon309 | 0:666850d06c9f | 294 | |
jhon309 | 0:666850d06c9f | 295 | |
jhon309 | 0:666850d06c9f | 296 | |
jhon309 | 0:666850d06c9f | 297 | /** |
jhon309 | 0:666850d06c9f | 298 | * @brief sets the type in the endpoint register(bits EP_TYPE[1:0]) |
jhon309 | 0:666850d06c9f | 299 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 300 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 301 | * @param wType: Endpoint Type. |
jhon309 | 0:666850d06c9f | 302 | * @retval None |
jhon309 | 0:666850d06c9f | 303 | */ |
jhon309 | 0:666850d06c9f | 304 | #define PCD_SET_EPTYPE(USBx, bEpNum,wType) (PCD_SET_ENDPOINT((USBx), (bEpNum),\ |
jhon309 | 0:666850d06c9f | 305 | ((PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_MASK) | (wType) ))) |
jhon309 | 0:666850d06c9f | 306 | |
jhon309 | 0:666850d06c9f | 307 | /** |
jhon309 | 0:666850d06c9f | 308 | * @brief gets the type in the endpoint register(bits EP_TYPE[1:0]) |
jhon309 | 0:666850d06c9f | 309 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 310 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 311 | * @retval Endpoint Type |
jhon309 | 0:666850d06c9f | 312 | */ |
jhon309 | 0:666850d06c9f | 313 | #define PCD_GET_EPTYPE(USBx, bEpNum) (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_T_FIELD) |
jhon309 | 0:666850d06c9f | 314 | |
jhon309 | 0:666850d06c9f | 315 | |
jhon309 | 0:666850d06c9f | 316 | /** |
jhon309 | 0:666850d06c9f | 317 | * @brief free buffer used from the application realizing it to the line |
jhon309 | 0:666850d06c9f | 318 | toggles bit SW_BUF in the double buffered endpoint register |
jhon309 | 0:666850d06c9f | 319 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 320 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 321 | * @param bDir: Direction |
jhon309 | 0:666850d06c9f | 322 | * @retval None |
jhon309 | 0:666850d06c9f | 323 | */ |
jhon309 | 0:666850d06c9f | 324 | #define PCD_FreeUserBuffer(USBx, bEpNum, bDir)\ |
jhon309 | 0:666850d06c9f | 325 | {\ |
jhon309 | 0:666850d06c9f | 326 | if ((bDir) == PCD_EP_DBUF_OUT)\ |
jhon309 | 0:666850d06c9f | 327 | { /* OUT double buffered endpoint */\ |
jhon309 | 0:666850d06c9f | 328 | PCD_TX_DTOG((USBx), (bEpNum));\ |
jhon309 | 0:666850d06c9f | 329 | }\ |
jhon309 | 0:666850d06c9f | 330 | else if ((bDir) == PCD_EP_DBUF_IN)\ |
jhon309 | 0:666850d06c9f | 331 | { /* IN double buffered endpoint */\ |
jhon309 | 0:666850d06c9f | 332 | PCD_RX_DTOG((USBx), (bEpNum));\ |
jhon309 | 0:666850d06c9f | 333 | }\ |
jhon309 | 0:666850d06c9f | 334 | } |
jhon309 | 0:666850d06c9f | 335 | |
jhon309 | 0:666850d06c9f | 336 | /** |
jhon309 | 0:666850d06c9f | 337 | * @brief gets direction of the double buffered endpoint |
jhon309 | 0:666850d06c9f | 338 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 339 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 340 | * @retval EP_DBUF_OUT, EP_DBUF_IN, |
jhon309 | 0:666850d06c9f | 341 | * EP_DBUF_ERR if the endpoint counter not yet programmed. |
jhon309 | 0:666850d06c9f | 342 | */ |
jhon309 | 0:666850d06c9f | 343 | #define PCD_GET_DB_DIR(USBx, bEpNum)\ |
jhon309 | 0:666850d06c9f | 344 | {\ |
jhon309 | 0:666850d06c9f | 345 | if ((uint16_t)(*PCD_EP_RX_CNT((USBx), (bEpNum)) & 0xFC00) != 0)\ |
jhon309 | 0:666850d06c9f | 346 | return(PCD_EP_DBUF_OUT);\ |
jhon309 | 0:666850d06c9f | 347 | else if (((uint16_t)(*PCD_EP_TX_CNT((USBx), (bEpNum))) & 0x03FF) != 0)\ |
jhon309 | 0:666850d06c9f | 348 | return(PCD_EP_DBUF_IN);\ |
jhon309 | 0:666850d06c9f | 349 | else\ |
jhon309 | 0:666850d06c9f | 350 | return(PCD_EP_DBUF_ERR);\ |
jhon309 | 0:666850d06c9f | 351 | } |
jhon309 | 0:666850d06c9f | 352 | |
jhon309 | 0:666850d06c9f | 353 | /** |
jhon309 | 0:666850d06c9f | 354 | * @brief sets the status for tx transfer (bits STAT_TX[1:0]). |
jhon309 | 0:666850d06c9f | 355 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 356 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 357 | * @param wState: new state |
jhon309 | 0:666850d06c9f | 358 | * @retval None |
jhon309 | 0:666850d06c9f | 359 | */ |
jhon309 | 0:666850d06c9f | 360 | #define PCD_SET_EP_TX_STATUS(USBx, bEpNum, wState) {\ |
jhon309 | 0:666850d06c9f | 361 | register uint16_t _wRegVal; \ |
jhon309 | 0:666850d06c9f | 362 | \ |
jhon309 | 0:666850d06c9f | 363 | _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_DTOGMASK;\ |
jhon309 | 0:666850d06c9f | 364 | /* toggle first bit ? */ \ |
jhon309 | 0:666850d06c9f | 365 | if((USB_EPTX_DTOG1 & (wState))!= 0) \ |
jhon309 | 0:666850d06c9f | 366 | _wRegVal ^= USB_EPTX_DTOG1; \ |
jhon309 | 0:666850d06c9f | 367 | /* toggle second bit ? */ \ |
jhon309 | 0:666850d06c9f | 368 | if((USB_EPTX_DTOG2 & (wState))!= 0) \ |
jhon309 | 0:666850d06c9f | 369 | _wRegVal ^= USB_EPTX_DTOG2; \ |
jhon309 | 0:666850d06c9f | 370 | PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX|USB_EP_CTR_TX)); \ |
jhon309 | 0:666850d06c9f | 371 | } /* PCD_SET_EP_TX_STATUS */ |
jhon309 | 0:666850d06c9f | 372 | |
jhon309 | 0:666850d06c9f | 373 | /** |
jhon309 | 0:666850d06c9f | 374 | * @brief sets the status for rx transfer (bits STAT_TX[1:0]) |
jhon309 | 0:666850d06c9f | 375 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 376 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 377 | * @param wState: new state |
jhon309 | 0:666850d06c9f | 378 | * @retval None |
jhon309 | 0:666850d06c9f | 379 | */ |
jhon309 | 0:666850d06c9f | 380 | #define PCD_SET_EP_RX_STATUS(USBx, bEpNum,wState) {\ |
jhon309 | 0:666850d06c9f | 381 | register uint16_t _wRegVal; \ |
jhon309 | 0:666850d06c9f | 382 | \ |
jhon309 | 0:666850d06c9f | 383 | _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_DTOGMASK;\ |
jhon309 | 0:666850d06c9f | 384 | /* toggle first bit ? */ \ |
jhon309 | 0:666850d06c9f | 385 | if((USB_EPRX_DTOG1 & (wState))!= 0) \ |
jhon309 | 0:666850d06c9f | 386 | _wRegVal ^= USB_EPRX_DTOG1; \ |
jhon309 | 0:666850d06c9f | 387 | /* toggle second bit ? */ \ |
jhon309 | 0:666850d06c9f | 388 | if((USB_EPRX_DTOG2 & (wState))!= 0) \ |
jhon309 | 0:666850d06c9f | 389 | _wRegVal ^= USB_EPRX_DTOG2; \ |
jhon309 | 0:666850d06c9f | 390 | PCD_SET_ENDPOINT((USBx), (bEpNum), (_wRegVal | USB_EP_CTR_RX|USB_EP_CTR_TX)); \ |
jhon309 | 0:666850d06c9f | 391 | } /* PCD_SET_EP_RX_STATUS */ |
jhon309 | 0:666850d06c9f | 392 | |
jhon309 | 0:666850d06c9f | 393 | /** |
jhon309 | 0:666850d06c9f | 394 | * @brief sets the status for rx & tx (bits STAT_TX[1:0] & STAT_RX[1:0]) |
jhon309 | 0:666850d06c9f | 395 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 396 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 397 | * @param wStaterx: new state. |
jhon309 | 0:666850d06c9f | 398 | * @param wStatetx: new state. |
jhon309 | 0:666850d06c9f | 399 | * @retval None |
jhon309 | 0:666850d06c9f | 400 | */ |
jhon309 | 0:666850d06c9f | 401 | #define PCD_SET_EP_TXRX_STATUS(USBx,bEpNum,wStaterx,wStatetx) {\ |
jhon309 | 0:666850d06c9f | 402 | register uint32_t _wRegVal; \ |
jhon309 | 0:666850d06c9f | 403 | \ |
jhon309 | 0:666850d06c9f | 404 | _wRegVal = PCD_GET_ENDPOINT((USBx), (bEpNum)) & (USB_EPRX_DTOGMASK |USB_EPTX_STAT) ;\ |
jhon309 | 0:666850d06c9f | 405 | /* toggle first bit ? */ \ |
jhon309 | 0:666850d06c9f | 406 | if((USB_EPRX_DTOG1 & ((wStaterx)))!= 0) \ |
jhon309 | 0:666850d06c9f | 407 | _wRegVal ^= USB_EPRX_DTOG1; \ |
jhon309 | 0:666850d06c9f | 408 | /* toggle second bit ? */ \ |
jhon309 | 0:666850d06c9f | 409 | if((USB_EPRX_DTOG2 & (wStaterx))!= 0) \ |
jhon309 | 0:666850d06c9f | 410 | _wRegVal ^= USB_EPRX_DTOG2; \ |
jhon309 | 0:666850d06c9f | 411 | /* toggle first bit ? */ \ |
jhon309 | 0:666850d06c9f | 412 | if((USB_EPTX_DTOG1 & (wStatetx))!= 0) \ |
jhon309 | 0:666850d06c9f | 413 | _wRegVal ^= USB_EPTX_DTOG1; \ |
jhon309 | 0:666850d06c9f | 414 | /* toggle second bit ? */ \ |
jhon309 | 0:666850d06c9f | 415 | if((USB_EPTX_DTOG2 & (wStatetx))!= 0) \ |
jhon309 | 0:666850d06c9f | 416 | _wRegVal ^= USB_EPTX_DTOG2; \ |
jhon309 | 0:666850d06c9f | 417 | PCD_SET_ENDPOINT((USBx), (bEpNum), _wRegVal | USB_EP_CTR_RX|USB_EP_CTR_TX); \ |
jhon309 | 0:666850d06c9f | 418 | } /* PCD_SET_EP_TXRX_STATUS */ |
jhon309 | 0:666850d06c9f | 419 | |
jhon309 | 0:666850d06c9f | 420 | /** |
jhon309 | 0:666850d06c9f | 421 | * @brief gets the status for tx/rx transfer (bits STAT_TX[1:0] |
jhon309 | 0:666850d06c9f | 422 | * /STAT_RX[1:0]) |
jhon309 | 0:666850d06c9f | 423 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 424 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 425 | * @retval status |
jhon309 | 0:666850d06c9f | 426 | */ |
jhon309 | 0:666850d06c9f | 427 | #define PCD_GET_EP_TX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPTX_STAT) |
jhon309 | 0:666850d06c9f | 428 | |
jhon309 | 0:666850d06c9f | 429 | #define PCD_GET_EP_RX_STATUS(USBx, bEpNum) ((uint16_t)PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPRX_STAT) |
jhon309 | 0:666850d06c9f | 430 | |
jhon309 | 0:666850d06c9f | 431 | /** |
jhon309 | 0:666850d06c9f | 432 | * @brief sets directly the VALID tx/rx-status into the endpoint register |
jhon309 | 0:666850d06c9f | 433 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 434 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 435 | * @retval None |
jhon309 | 0:666850d06c9f | 436 | */ |
jhon309 | 0:666850d06c9f | 437 | #define PCD_SET_EP_TX_VALID(USBx, bEpNum) (PCD_SET_EP_TX_STATUS((USBx), (bEpNum), USB_EP_TX_VALID)) |
jhon309 | 0:666850d06c9f | 438 | |
jhon309 | 0:666850d06c9f | 439 | #define PCD_SET_EP_RX_VALID(USBx, bEpNum) (PCD_SET_EP_RX_STATUS((USBx), (bEpNum), USB_EP_RX_VALID)) |
jhon309 | 0:666850d06c9f | 440 | |
jhon309 | 0:666850d06c9f | 441 | /** |
jhon309 | 0:666850d06c9f | 442 | * @brief checks stall condition in an endpoint. |
jhon309 | 0:666850d06c9f | 443 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 444 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 445 | * @retval TRUE = endpoint in stall condition. |
jhon309 | 0:666850d06c9f | 446 | */ |
jhon309 | 0:666850d06c9f | 447 | #define PCD_GET_EP_TX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_TX_STATUS((USBx), (bEpNum)) \ |
jhon309 | 0:666850d06c9f | 448 | == USB_EP_TX_STALL) |
jhon309 | 0:666850d06c9f | 449 | #define PCD_GET_EP_RX_STALL_STATUS(USBx, bEpNum) (PCD_GET_EP_RX_STATUS((USBx), (bEpNum)) \ |
jhon309 | 0:666850d06c9f | 450 | == USB_EP_RX_STALL) |
jhon309 | 0:666850d06c9f | 451 | |
jhon309 | 0:666850d06c9f | 452 | /** |
jhon309 | 0:666850d06c9f | 453 | * @brief set & clear EP_KIND bit. |
jhon309 | 0:666850d06c9f | 454 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 455 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 456 | * @retval None |
jhon309 | 0:666850d06c9f | 457 | */ |
jhon309 | 0:666850d06c9f | 458 | #define PCD_SET_EP_KIND(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \ |
jhon309 | 0:666850d06c9f | 459 | (USB_EP_CTR_RX|USB_EP_CTR_TX|((PCD_GET_ENDPOINT((USBx), (bEpNum)) | USB_EP_KIND) & USB_EPREG_MASK)))) |
jhon309 | 0:666850d06c9f | 460 | #define PCD_CLEAR_EP_KIND(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \ |
jhon309 | 0:666850d06c9f | 461 | (USB_EP_CTR_RX|USB_EP_CTR_TX|(PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPKIND_MASK)))) |
jhon309 | 0:666850d06c9f | 462 | |
jhon309 | 0:666850d06c9f | 463 | /** |
jhon309 | 0:666850d06c9f | 464 | * @brief Sets/clears directly STATUS_OUT bit in the endpoint register. |
jhon309 | 0:666850d06c9f | 465 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 466 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 467 | * @retval None |
jhon309 | 0:666850d06c9f | 468 | */ |
jhon309 | 0:666850d06c9f | 469 | #define PCD_SET_OUT_STATUS(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 470 | #define PCD_CLEAR_OUT_STATUS(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 471 | |
jhon309 | 0:666850d06c9f | 472 | /** |
jhon309 | 0:666850d06c9f | 473 | * @brief Sets/clears directly EP_KIND bit in the endpoint register. |
jhon309 | 0:666850d06c9f | 474 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 475 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 476 | * @retval None |
jhon309 | 0:666850d06c9f | 477 | */ |
jhon309 | 0:666850d06c9f | 478 | #define PCD_SET_EP_DBUF(USBx, bEpNum) PCD_SET_EP_KIND((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 479 | #define PCD_CLEAR_EP_DBUF(USBx, bEpNum) PCD_CLEAR_EP_KIND((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 480 | |
jhon309 | 0:666850d06c9f | 481 | /** |
jhon309 | 0:666850d06c9f | 482 | * @brief Clears bit CTR_RX / CTR_TX in the endpoint register. |
jhon309 | 0:666850d06c9f | 483 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 484 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 485 | * @retval None |
jhon309 | 0:666850d06c9f | 486 | */ |
jhon309 | 0:666850d06c9f | 487 | #define PCD_CLEAR_RX_EP_CTR(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum),\ |
jhon309 | 0:666850d06c9f | 488 | PCD_GET_ENDPOINT((USBx), (bEpNum)) & 0x7FFF & USB_EPREG_MASK)) |
jhon309 | 0:666850d06c9f | 489 | #define PCD_CLEAR_TX_EP_CTR(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum),\ |
jhon309 | 0:666850d06c9f | 490 | PCD_GET_ENDPOINT((USBx), (bEpNum)) & 0xFF7F & USB_EPREG_MASK)) |
jhon309 | 0:666850d06c9f | 491 | |
jhon309 | 0:666850d06c9f | 492 | /** |
jhon309 | 0:666850d06c9f | 493 | * @brief Toggles DTOG_RX / DTOG_TX bit in the endpoint register. |
jhon309 | 0:666850d06c9f | 494 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 495 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 496 | * @retval None |
jhon309 | 0:666850d06c9f | 497 | */ |
jhon309 | 0:666850d06c9f | 498 | #define PCD_RX_DTOG(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \ |
jhon309 | 0:666850d06c9f | 499 | USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_RX | (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK))) |
jhon309 | 0:666850d06c9f | 500 | #define PCD_TX_DTOG(USBx, bEpNum) (PCD_SET_ENDPOINT((USBx), (bEpNum), \ |
jhon309 | 0:666850d06c9f | 501 | USB_EP_CTR_RX|USB_EP_CTR_TX|USB_EP_DTOG_TX | (PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK))) |
jhon309 | 0:666850d06c9f | 502 | |
jhon309 | 0:666850d06c9f | 503 | /** |
jhon309 | 0:666850d06c9f | 504 | * @brief Clears DTOG_RX / DTOG_TX bit in the endpoint register. |
jhon309 | 0:666850d06c9f | 505 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 506 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 507 | * @retval None |
jhon309 | 0:666850d06c9f | 508 | */ |
jhon309 | 0:666850d06c9f | 509 | #define PCD_CLEAR_RX_DTOG(USBx, bEpNum) if((PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_DTOG_RX) != 0)\ |
jhon309 | 0:666850d06c9f | 510 | PCD_RX_DTOG((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 511 | #define PCD_CLEAR_TX_DTOG(USBx, bEpNum) if((PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EP_DTOG_TX) != 0)\ |
jhon309 | 0:666850d06c9f | 512 | PCD_TX_DTOG((USBx), (bEpNum)) |
jhon309 | 0:666850d06c9f | 513 | |
jhon309 | 0:666850d06c9f | 514 | /** |
jhon309 | 0:666850d06c9f | 515 | * @brief Sets address in an endpoint register. |
jhon309 | 0:666850d06c9f | 516 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 517 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 518 | * @param bAddr: Address. |
jhon309 | 0:666850d06c9f | 519 | * @retval None |
jhon309 | 0:666850d06c9f | 520 | */ |
jhon309 | 0:666850d06c9f | 521 | #define PCD_SET_EP_ADDRESS(USBx, bEpNum,bAddr) PCD_SET_ENDPOINT((USBx), (bEpNum),\ |
jhon309 | 0:666850d06c9f | 522 | USB_EP_CTR_RX|USB_EP_CTR_TX|(PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPREG_MASK) | (bAddr)) |
jhon309 | 0:666850d06c9f | 523 | |
jhon309 | 0:666850d06c9f | 524 | /** |
jhon309 | 0:666850d06c9f | 525 | * @brief Gets address in an endpoint register. |
jhon309 | 0:666850d06c9f | 526 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 527 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 528 | * @retval None |
jhon309 | 0:666850d06c9f | 529 | */ |
jhon309 | 0:666850d06c9f | 530 | #define PCD_GET_EP_ADDRESS(USBx, bEpNum) ((uint8_t)(PCD_GET_ENDPOINT((USBx), (bEpNum)) & USB_EPADDR_FIELD)) |
jhon309 | 0:666850d06c9f | 531 | |
jhon309 | 0:666850d06c9f | 532 | #define PCD_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t *)(((USBx)->BTABLE+(bEpNum)*8)+ ((uint32_t)(USBx) + 0x400))) |
jhon309 | 0:666850d06c9f | 533 | #define PCD_EP_TX_CNT(USBx, bEpNum) ((uint16_t *)(((USBx)->BTABLE+(bEpNum)*8+2)+ ((uint32_t)(USBx) + 0x400))) |
jhon309 | 0:666850d06c9f | 534 | #define PCD_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t *)(((USBx)->BTABLE+(bEpNum)*8+4)+ ((uint32_t)(USBx) + 0x400))) |
jhon309 | 0:666850d06c9f | 535 | #define PCD_EP_RX_CNT(USBx, bEpNum) ((uint16_t *)(((USBx)->BTABLE+(bEpNum)*8+6)+ ((uint32_t)(USBx) + 0x400))) |
jhon309 | 0:666850d06c9f | 536 | |
jhon309 | 0:666850d06c9f | 537 | /** |
jhon309 | 0:666850d06c9f | 538 | * @brief sets address of the tx/rx buffer. |
jhon309 | 0:666850d06c9f | 539 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 540 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 541 | * @param wAddr: address to be set (must be word aligned). |
jhon309 | 0:666850d06c9f | 542 | * @retval None |
jhon309 | 0:666850d06c9f | 543 | */ |
jhon309 | 0:666850d06c9f | 544 | #define PCD_SET_EP_TX_ADDRESS(USBx, bEpNum,wAddr) (*PCD_EP_TX_ADDRESS((USBx), (bEpNum)) = (((wAddr) >> 1) << 1)) |
jhon309 | 0:666850d06c9f | 545 | #define PCD_SET_EP_RX_ADDRESS(USBx, bEpNum,wAddr) (*PCD_EP_RX_ADDRESS((USBx), (bEpNum)) = (((wAddr) >> 1) << 1)) |
jhon309 | 0:666850d06c9f | 546 | |
jhon309 | 0:666850d06c9f | 547 | /** |
jhon309 | 0:666850d06c9f | 548 | * @brief Gets address of the tx/rx buffer. |
jhon309 | 0:666850d06c9f | 549 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 550 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 551 | * @retval address of the buffer. |
jhon309 | 0:666850d06c9f | 552 | */ |
jhon309 | 0:666850d06c9f | 553 | #define PCD_GET_EP_TX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_TX_ADDRESS((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 554 | #define PCD_GET_EP_RX_ADDRESS(USBx, bEpNum) ((uint16_t)*PCD_EP_RX_ADDRESS((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 555 | |
jhon309 | 0:666850d06c9f | 556 | /** |
jhon309 | 0:666850d06c9f | 557 | * @brief Sets counter of rx buffer with no. of blocks. |
jhon309 | 0:666850d06c9f | 558 | * @param dwReg: Register |
jhon309 | 0:666850d06c9f | 559 | * @param wCount: Counter. |
jhon309 | 0:666850d06c9f | 560 | * @param wNBlocks: no. of Blocks. |
jhon309 | 0:666850d06c9f | 561 | * @retval None |
jhon309 | 0:666850d06c9f | 562 | */ |
jhon309 | 0:666850d06c9f | 563 | #define PCD_CALC_BLK32(dwReg,wCount,wNBlocks) {\ |
jhon309 | 0:666850d06c9f | 564 | (wNBlocks) = (wCount) >> 5;\ |
jhon309 | 0:666850d06c9f | 565 | if(((wCount) & 0x1f) == 0)\ |
jhon309 | 0:666850d06c9f | 566 | (wNBlocks)--;\ |
jhon309 | 0:666850d06c9f | 567 | *pdwReg = (uint16_t)(((wNBlocks) << 10) | 0x8000);\ |
jhon309 | 0:666850d06c9f | 568 | }/* PCD_CALC_BLK32 */ |
jhon309 | 0:666850d06c9f | 569 | |
jhon309 | 0:666850d06c9f | 570 | #define PCD_CALC_BLK2(dwReg,wCount,wNBlocks) {\ |
jhon309 | 0:666850d06c9f | 571 | (wNBlocks) = (wCount) >> 1;\ |
jhon309 | 0:666850d06c9f | 572 | if(((wCount) & 0x1) != 0)\ |
jhon309 | 0:666850d06c9f | 573 | (wNBlocks)++;\ |
jhon309 | 0:666850d06c9f | 574 | *pdwReg = (uint16_t)((wNBlocks) << 10);\ |
jhon309 | 0:666850d06c9f | 575 | }/* PCD_CALC_BLK2 */ |
jhon309 | 0:666850d06c9f | 576 | |
jhon309 | 0:666850d06c9f | 577 | #define PCD_SET_EP_CNT_RX_REG(dwReg,wCount) {\ |
jhon309 | 0:666850d06c9f | 578 | uint16_t wNBlocks;\ |
jhon309 | 0:666850d06c9f | 579 | if((wCount) > 62){PCD_CALC_BLK32((dwReg),(wCount),wNBlocks);}\ |
jhon309 | 0:666850d06c9f | 580 | else {PCD_CALC_BLK2((dwReg),(wCount),wNBlocks);}\ |
jhon309 | 0:666850d06c9f | 581 | }/* PCD_SET_EP_CNT_RX_REG */ |
jhon309 | 0:666850d06c9f | 582 | |
jhon309 | 0:666850d06c9f | 583 | #define PCD_SET_EP_RX_DBUF0_CNT(USBx, bEpNum,wCount) {\ |
jhon309 | 0:666850d06c9f | 584 | uint16_t *pdwReg = PCD_EP_TX_CNT((USBx), (bEpNum)); \ |
jhon309 | 0:666850d06c9f | 585 | PCD_SET_EP_CNT_RX_REG(pdwReg, (wCount));\ |
jhon309 | 0:666850d06c9f | 586 | } |
jhon309 | 0:666850d06c9f | 587 | /** |
jhon309 | 0:666850d06c9f | 588 | * @brief sets counter for the tx/rx buffer. |
jhon309 | 0:666850d06c9f | 589 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 590 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 591 | * @param wCount: Counter value. |
jhon309 | 0:666850d06c9f | 592 | * @retval None |
jhon309 | 0:666850d06c9f | 593 | */ |
jhon309 | 0:666850d06c9f | 594 | #define PCD_SET_EP_TX_CNT(USBx, bEpNum,wCount) (*PCD_EP_TX_CNT((USBx), (bEpNum)) = (wCount)) |
jhon309 | 0:666850d06c9f | 595 | #define PCD_SET_EP_RX_CNT(USBx, bEpNum,wCount) {\ |
jhon309 | 0:666850d06c9f | 596 | uint16_t *pdwReg = PCD_EP_RX_CNT(USBx, bEpNum); \ |
jhon309 | 0:666850d06c9f | 597 | PCD_SET_EP_CNT_RX_REG(pdwReg, wCount);\ |
jhon309 | 0:666850d06c9f | 598 | } |
jhon309 | 0:666850d06c9f | 599 | |
jhon309 | 0:666850d06c9f | 600 | /** |
jhon309 | 0:666850d06c9f | 601 | * @brief gets counter of the tx buffer. |
jhon309 | 0:666850d06c9f | 602 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 603 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 604 | * @retval Counter value |
jhon309 | 0:666850d06c9f | 605 | */ |
jhon309 | 0:666850d06c9f | 606 | #define PCD_GET_EP_TX_CNT(USBx, bEpNum)((uint16_t)(*PCD_EP_TX_CNT((USBx), (bEpNum))) & 0x3ff) |
jhon309 | 0:666850d06c9f | 607 | #define PCD_GET_EP_RX_CNT(USBx, bEpNum)((uint16_t)(*PCD_EP_RX_CNT((USBx), (bEpNum))) & 0x3ff) |
jhon309 | 0:666850d06c9f | 608 | |
jhon309 | 0:666850d06c9f | 609 | /** |
jhon309 | 0:666850d06c9f | 610 | * @brief Sets buffer 0/1 address in a double buffer endpoint. |
jhon309 | 0:666850d06c9f | 611 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 612 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 613 | * @param wBuf0Addr: buffer 0 address. |
jhon309 | 0:666850d06c9f | 614 | * @retval Counter value |
jhon309 | 0:666850d06c9f | 615 | */ |
jhon309 | 0:666850d06c9f | 616 | #define PCD_SET_EP_DBUF0_ADDR(USBx, bEpNum,wBuf0Addr) {PCD_SET_EP_TX_ADDRESS((USBx), (bEpNum), (wBuf0Addr));} |
jhon309 | 0:666850d06c9f | 617 | #define PCD_SET_EP_DBUF1_ADDR(USBx, bEpNum,wBuf1Addr) {PCD_SET_EP_RX_ADDRESS((USBx), (bEpNum), (wBuf1Addr));} |
jhon309 | 0:666850d06c9f | 618 | |
jhon309 | 0:666850d06c9f | 619 | /** |
jhon309 | 0:666850d06c9f | 620 | * @brief Sets addresses in a double buffer endpoint. |
jhon309 | 0:666850d06c9f | 621 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 622 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 623 | * @param wBuf0Addr: buffer 0 address. |
jhon309 | 0:666850d06c9f | 624 | * @param wBuf1Addr = buffer 1 address. |
jhon309 | 0:666850d06c9f | 625 | * @retval None |
jhon309 | 0:666850d06c9f | 626 | */ |
jhon309 | 0:666850d06c9f | 627 | #define PCD_SET_EP_DBUF_ADDR(USBx, bEpNum,wBuf0Addr,wBuf1Addr) { \ |
jhon309 | 0:666850d06c9f | 628 | PCD_SET_EP_DBUF0_ADDR((USBx), (bEpNum), (wBuf0Addr));\ |
jhon309 | 0:666850d06c9f | 629 | PCD_SET_EP_DBUF1_ADDR((USBx), (bEpNum), (wBuf1Addr));\ |
jhon309 | 0:666850d06c9f | 630 | } /* PCD_SET_EP_DBUF_ADDR */ |
jhon309 | 0:666850d06c9f | 631 | |
jhon309 | 0:666850d06c9f | 632 | /** |
jhon309 | 0:666850d06c9f | 633 | * @brief Gets buffer 0/1 address of a double buffer endpoint. |
jhon309 | 0:666850d06c9f | 634 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 635 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 636 | * @retval None |
jhon309 | 0:666850d06c9f | 637 | */ |
jhon309 | 0:666850d06c9f | 638 | #define PCD_GET_EP_DBUF0_ADDR(USBx, bEpNum) (PCD_GET_EP_TX_ADDRESS((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 639 | #define PCD_GET_EP_DBUF1_ADDR(USBx, bEpNum) (PCD_GET_EP_RX_ADDRESS((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 640 | |
jhon309 | 0:666850d06c9f | 641 | /** |
jhon309 | 0:666850d06c9f | 642 | * @brief Gets buffer 0/1 address of a double buffer endpoint. |
jhon309 | 0:666850d06c9f | 643 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 644 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 645 | * @param bDir: endpoint dir EP_DBUF_OUT = OUT |
jhon309 | 0:666850d06c9f | 646 | * EP_DBUF_IN = IN |
jhon309 | 0:666850d06c9f | 647 | * @param wCount: Counter value |
jhon309 | 0:666850d06c9f | 648 | * @retval None |
jhon309 | 0:666850d06c9f | 649 | */ |
jhon309 | 0:666850d06c9f | 650 | #define PCD_SET_EP_DBUF0_CNT(USBx, bEpNum, bDir, wCount) { \ |
jhon309 | 0:666850d06c9f | 651 | if((bDir) == PCD_EP_DBUF_OUT)\ |
jhon309 | 0:666850d06c9f | 652 | /* OUT endpoint */ \ |
jhon309 | 0:666850d06c9f | 653 | {PCD_SET_EP_RX_DBUF0_CNT((USBx), (bEpNum),(wCount));} \ |
jhon309 | 0:666850d06c9f | 654 | else if((bDir) == PCD_EP_DBUF_IN)\ |
jhon309 | 0:666850d06c9f | 655 | /* IN endpoint */ \ |
jhon309 | 0:666850d06c9f | 656 | *PCD_EP_TX_CNT((USBx), (bEpNum)) = (uint32_t)(wCount); \ |
jhon309 | 0:666850d06c9f | 657 | } /* SetEPDblBuf0Count*/ |
jhon309 | 0:666850d06c9f | 658 | |
jhon309 | 0:666850d06c9f | 659 | #define PCD_SET_EP_DBUF1_CNT(USBx, bEpNum, bDir, wCount) { \ |
jhon309 | 0:666850d06c9f | 660 | if((bDir) == PCD_EP_DBUF_OUT)\ |
jhon309 | 0:666850d06c9f | 661 | /* OUT endpoint */ \ |
jhon309 | 0:666850d06c9f | 662 | {PCD_SET_EP_RX_CNT((USBx), (bEpNum),(wCount));}\ |
jhon309 | 0:666850d06c9f | 663 | else if((bDir) == PCD_EP_DBUF_IN)\ |
jhon309 | 0:666850d06c9f | 664 | /* IN endpoint */\ |
jhon309 | 0:666850d06c9f | 665 | *PCD_EP_RX_CNT((USBx), (bEpNum)) = (uint32_t)(wCount); \ |
jhon309 | 0:666850d06c9f | 666 | } /* SetEPDblBuf1Count */ |
jhon309 | 0:666850d06c9f | 667 | |
jhon309 | 0:666850d06c9f | 668 | #define PCD_SET_EP_DBUF_CNT(USBx, bEpNum, bDir, wCount) {\ |
jhon309 | 0:666850d06c9f | 669 | PCD_SET_EP_DBUF0_CNT((USBx), (bEpNum), (bDir), (wCount)); \ |
jhon309 | 0:666850d06c9f | 670 | PCD_SET_EP_DBUF1_CNT((USBx), (bEpNum), (bDir), (wCount)); \ |
jhon309 | 0:666850d06c9f | 671 | } /* PCD_SET_EP_DBUF_CNT */ |
jhon309 | 0:666850d06c9f | 672 | |
jhon309 | 0:666850d06c9f | 673 | /** |
jhon309 | 0:666850d06c9f | 674 | * @brief Gets buffer 0/1 rx/tx counter for double buffering. |
jhon309 | 0:666850d06c9f | 675 | * @param USBx: USB peripheral instance register address. |
jhon309 | 0:666850d06c9f | 676 | * @param bEpNum: Endpoint Number. |
jhon309 | 0:666850d06c9f | 677 | * @retval None |
jhon309 | 0:666850d06c9f | 678 | */ |
jhon309 | 0:666850d06c9f | 679 | #define PCD_GET_EP_DBUF0_CNT(USBx, bEpNum) (PCD_GET_EP_TX_CNT((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 680 | #define PCD_GET_EP_DBUF1_CNT(USBx, bEpNum) (PCD_GET_EP_RX_CNT((USBx), (bEpNum))) |
jhon309 | 0:666850d06c9f | 681 | |
jhon309 | 0:666850d06c9f | 682 | |
jhon309 | 0:666850d06c9f | 683 | /** |
jhon309 | 0:666850d06c9f | 684 | * @} |
jhon309 | 0:666850d06c9f | 685 | */ |
jhon309 | 0:666850d06c9f | 686 | |
jhon309 | 0:666850d06c9f | 687 | /* Exported functions --------------------------------------------------------*/ |
jhon309 | 0:666850d06c9f | 688 | |
jhon309 | 0:666850d06c9f | 689 | /** @addtogroup PCD_Exported_Functions |
jhon309 | 0:666850d06c9f | 690 | * @{ |
jhon309 | 0:666850d06c9f | 691 | */ |
jhon309 | 0:666850d06c9f | 692 | |
jhon309 | 0:666850d06c9f | 693 | /** @addtogroup PCD_Exported_Functions_Group1 |
jhon309 | 0:666850d06c9f | 694 | * @{ |
jhon309 | 0:666850d06c9f | 695 | */ |
jhon309 | 0:666850d06c9f | 696 | /* Initialization and de-initialization functions **********************************/ |
jhon309 | 0:666850d06c9f | 697 | HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 698 | HAL_StatusTypeDef HAL_PCD_DeInit (PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 699 | void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 700 | void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 701 | |
jhon309 | 0:666850d06c9f | 702 | /** |
jhon309 | 0:666850d06c9f | 703 | * @} |
jhon309 | 0:666850d06c9f | 704 | */ |
jhon309 | 0:666850d06c9f | 705 | |
jhon309 | 0:666850d06c9f | 706 | /** @addtogroup PCD_Exported_Functions_Group2 |
jhon309 | 0:666850d06c9f | 707 | * @{ |
jhon309 | 0:666850d06c9f | 708 | */ |
jhon309 | 0:666850d06c9f | 709 | /* IO operation functions *****************************************************/ |
jhon309 | 0:666850d06c9f | 710 | /* Non Blocking mode: Interrupt */ |
jhon309 | 0:666850d06c9f | 711 | HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 712 | HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 713 | void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 714 | |
jhon309 | 0:666850d06c9f | 715 | void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); |
jhon309 | 0:666850d06c9f | 716 | void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); |
jhon309 | 0:666850d06c9f | 717 | void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 718 | void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 719 | void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 720 | void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 721 | void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 722 | void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); |
jhon309 | 0:666850d06c9f | 723 | void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum); |
jhon309 | 0:666850d06c9f | 724 | void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 725 | void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 726 | |
jhon309 | 0:666850d06c9f | 727 | /** |
jhon309 | 0:666850d06c9f | 728 | * @} |
jhon309 | 0:666850d06c9f | 729 | */ |
jhon309 | 0:666850d06c9f | 730 | |
jhon309 | 0:666850d06c9f | 731 | /** @addtogroup PCD_Exported_Functions_Group3 |
jhon309 | 0:666850d06c9f | 732 | * @{ |
jhon309 | 0:666850d06c9f | 733 | */ |
jhon309 | 0:666850d06c9f | 734 | /* Peripheral Control functions ************************************************/ |
jhon309 | 0:666850d06c9f | 735 | HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 736 | HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 737 | HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address); |
jhon309 | 0:666850d06c9f | 738 | HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type); |
jhon309 | 0:666850d06c9f | 739 | HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); |
jhon309 | 0:666850d06c9f | 740 | HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); |
jhon309 | 0:666850d06c9f | 741 | HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len); |
jhon309 | 0:666850d06c9f | 742 | uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); |
jhon309 | 0:666850d06c9f | 743 | HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); |
jhon309 | 0:666850d06c9f | 744 | HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); |
jhon309 | 0:666850d06c9f | 745 | HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr); |
jhon309 | 0:666850d06c9f | 746 | HAL_StatusTypeDef HAL_PCD_ActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 747 | HAL_StatusTypeDef HAL_PCD_DeActiveRemoteWakeup(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 748 | /** |
jhon309 | 0:666850d06c9f | 749 | * @} |
jhon309 | 0:666850d06c9f | 750 | */ |
jhon309 | 0:666850d06c9f | 751 | |
jhon309 | 0:666850d06c9f | 752 | /** @addtogroup PCD_Exported_Functions_Group4 |
jhon309 | 0:666850d06c9f | 753 | * @{ |
jhon309 | 0:666850d06c9f | 754 | */ |
jhon309 | 0:666850d06c9f | 755 | /* Peripheral State functions **************************************************/ |
jhon309 | 0:666850d06c9f | 756 | PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd); |
jhon309 | 0:666850d06c9f | 757 | /** |
jhon309 | 0:666850d06c9f | 758 | * @} |
jhon309 | 0:666850d06c9f | 759 | */ |
jhon309 | 0:666850d06c9f | 760 | |
jhon309 | 0:666850d06c9f | 761 | /** |
jhon309 | 0:666850d06c9f | 762 | * @} |
jhon309 | 0:666850d06c9f | 763 | */ |
jhon309 | 0:666850d06c9f | 764 | |
jhon309 | 0:666850d06c9f | 765 | /** |
jhon309 | 0:666850d06c9f | 766 | * @} |
jhon309 | 0:666850d06c9f | 767 | */ |
jhon309 | 0:666850d06c9f | 768 | |
jhon309 | 0:666850d06c9f | 769 | /** |
jhon309 | 0:666850d06c9f | 770 | * @} |
jhon309 | 0:666850d06c9f | 771 | */ |
jhon309 | 0:666850d06c9f | 772 | |
jhon309 | 0:666850d06c9f | 773 | #endif /* STM32F042x6 || STM32F072xB || STM32F078xx || STM32F070xB || STM32F070x6 */ |
jhon309 | 0:666850d06c9f | 774 | |
jhon309 | 0:666850d06c9f | 775 | #ifdef __cplusplus |
jhon309 | 0:666850d06c9f | 776 | } |
jhon309 | 0:666850d06c9f | 777 | #endif |
jhon309 | 0:666850d06c9f | 778 | |
jhon309 | 0:666850d06c9f | 779 | |
jhon309 | 0:666850d06c9f | 780 | #endif /* __STM32F0xx_HAL_PCD_H */ |
jhon309 | 0:666850d06c9f | 781 | |
jhon309 | 0:666850d06c9f | 782 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |
jhon309 | 0:666850d06c9f | 783 |