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