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