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:
Tue Dec 20 15:36:52 2016 +0000
Revision:
132:9baf128c2fab
Parent:
128:9bcdf88f62b0
Child:
145:64910690c574
Release 132 of the mbed library

Ports for Upcoming Targets

3241: Add support for FRDM-KW41 https://github.com/ARMmbed/mbed-os/pull/3241
3291: Adding mbed enabled Maker board with NINA-B1 and EVA-M8Q https://github.com/ARMmbed/mbed-os/pull/3291

Fixes and Changes

3062: TARGET_STM :USB device FS https://github.com/ARMmbed/mbed-os/pull/3062
3213: STM32: Refactor us_ticker.c + hal_tick.c files https://github.com/ARMmbed/mbed-os/pull/3213
3288: Dev spi asynch l0l1 https://github.com/ARMmbed/mbed-os/pull/3288
3289: Bug fix of initial value of interrupt edge in "gpio_irq_init" function. https://github.com/ARMmbed/mbed-os/pull/3289
3302: STM32F4 AnalogIn - Clear VBATE and TSVREFE bits before configuring ADC channels https://github.com/ARMmbed/mbed-os/pull/3302
3320: STM32 - Add ADC_VREF label https://github.com/ARMmbed/mbed-os/pull/3320
3321: no HSE available by default for NUCLEO_L432KC https://github.com/ARMmbed/mbed-os/pull/3321
3352: ublox eva nina - fix line endings https://github.com/ARMmbed/mbed-os/pull/3352
3322: DISCO_L053C8 doesn't support LSE https://github.com/ARMmbed/mbed-os/pull/3322
3345: STM32 - Remove TIM_IT_UPDATE flag in HAL_Suspend/ResumeTick functions https://github.com/ARMmbed/mbed-os/pull/3345
3309: [NUC472/M453] Fix CI failed tests https://github.com/ARMmbed/mbed-os/pull/3309
3157: [Silicon Labs] Adding support for EFR32MG1 wireless SoC https://github.com/ARMmbed/mbed-os/pull/3157
3301: I2C - correct return values for write functions (docs) - part 1 https://github.com/ARMmbed/mbed-os/pull/3301
3303: Fix #2956 #2939 #2957 #2959 #2960: Add HAL_DeInit function in gpio_irq destructor https://github.com/ARMmbed/mbed-os/pull/3303
3304: STM32L476: no HSE is present in NUCLEO and DISCO boards https://github.com/ARMmbed/mbed-os/pull/3304
3318: Register map changes for RevG https://github.com/ARMmbed/mbed-os/pull/3318
3317: NUCLEO_F429ZI has integrated LSE https://github.com/ARMmbed/mbed-os/pull/3317
3312: K64F: SPI Asynch API implementation https://github.com/ARMmbed/mbed-os/pull/3312
3324: Dev i2c common code https://github.com/ARMmbed/mbed-os/pull/3324
3369: Add CAN2 missing pins for connector CN12 https://github.com/ARMmbed/mbed-os/pull/3369
3377: STM32 NUCLEO-L152RE Update system core clock to 32MHz https://github.com/ARMmbed/mbed-os/pull/3377
3378: K66F: Enable LWIP feature https://github.com/ARMmbed/mbed-os/pull/3378
3382: [MAX32620] Fixing serial readable function. https://github.com/ARMmbed/mbed-os/pull/3382
3399: NUCLEO_F103RB - Add SERIAL_FC feature https://github.com/ARMmbed/mbed-os/pull/3399
3409: STM32L1 : map ST HAL assert into MBED assert https://github.com/ARMmbed/mbed-os/pull/3409
3416: Renames i2c_api.c for STM32F1 targets to fix IAR exporter https://github.com/ARMmbed/mbed-os/pull/3416
3348: Fix frequency function of CAN driver. https://github.com/ARMmbed/mbed-os/pull/3348
3366: NUCLEO_F412ZG - Add new platform https://github.com/ARMmbed/mbed-os/pull/3366
3379: STM32F0 : map ST HAL assert into MBED assert https://github.com/ARMmbed/mbed-os/pull/3379
3393: ISR register never re-evaluated in HAL_DMA_PollForTransfer for STM32F4 https://github.com/ARMmbed/mbed-os/pull/3393
3408: STM32F7 : map ST HAL assert into MBED assert https://github.com/ARMmbed/mbed-os/pull/3408
3411: STM32L0 : map ST HAL assert into MBED assert https://github.com/ARMmbed/mbed-os/pull/3411
3424: STM32F4 - FIX to add the update of hdma->State variable https://github.com/ARMmbed/mbed-os/pull/3424
3427: Fix stm i2c slave https://github.com/ARMmbed/mbed-os/pull/3427
3429: Fix stm i2c fix init https://github.com/ARMmbed/mbed-os/pull/3429
3434: [NUC472/M453] Fix stuck in lp_ticker_init and other updates https://github.com/ARMmbed/mbed-os/pull/3434

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