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.

Committer:
<>
Date:
Thu Oct 27 16:45:56 2016 +0100
Revision:
128:9bcdf88f62b0
Parent:
TARGET_NUCLEO_L432KC/stm32l4xx_hal_pcd.h@122:f9eeca106725
Child:
132:9baf128c2fab
Release 128 of the mbed library

Ports for Upcoming Targets


Fixes and Changes

2966: Add kw24 support https://github.com/ARMmbed/mbed-os/pull/2966
3068: MultiTech mDot - clean up PeripheralPins.c and add new pin names https://github.com/ARMmbed/mbed-os/pull/3068
3089: Kinetis HAL: Remove clock initialization code from serial and ticker https://github.com/ARMmbed/mbed-os/pull/3089
2943: [NRF5] NVIC_SetVector functionality https://github.com/ARMmbed/mbed-os/pull/2943
2938: InterruptIn changes in NCS36510 HAL. https://github.com/ARMmbed/mbed-os/pull/2938
3108: Fix sleep function for NRF52. https://github.com/ARMmbed/mbed-os/pull/3108
3076: STM32F1: Correct timer master value reading https://github.com/ARMmbed/mbed-os/pull/3076
3085: Add LOWPOWERTIMER capability for NUCLEO_F303ZE https://github.com/ARMmbed/mbed-os/pull/3085
3046: [BEETLE] Update BLE stack on Beetle board https://github.com/ARMmbed/mbed-os/pull/3046
3122: [Silicon Labs] Update of Silicon Labs HAL https://github.com/ARMmbed/mbed-os/pull/3122
3022: OnSemi RAM usage fix https://github.com/ARMmbed/mbed-os/pull/3022
3121: STM32F3: Correct UART4 and UART5 defines when using DEVICE_SERIAL_ASYNCH https://github.com/ARMmbed/mbed-os/pull/3121
3142: Targets- NUMAKER_PFM_NUC47216 remove mbed 2 https://github.com/ARMmbed/mbed-os/pull/3142

Who changed what in which revision?

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