Fork of the official mbed C/C SDK provides the software platform and libraries to build your applications for RenBED.

Dependents:   1-RenBuggyTimed RenBED_RGB RenBED_RGB_PWM RenBED_RGB

Fork of mbed by mbed official

Committer:
Kojto
Date:
Fri Oct 02 07:35:07 2015 +0200
Revision:
108:34e6b704fe68
Parent:
93:e188a91d3eaa
Release 108  of the mbed library

Changes:
- new platforms - ELMO_F411RE, WIZNET_7500P, ARM_MPS2_BEID
- EFM32 - bugfixes in rtc, serial
- Cortex A cmsis - update files
- STML4 - RAM fixes

Who changed what in which revision?

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