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