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