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