MBED-DEV only fro Nucleo STM32F303K8T6
Fork of mbed-dev by
targets/TARGET_STM/TARGET_STM32F3/device/stm32f3xx_hal_pcd.c@151:acf04f8e7d03, 2016-11-19 (annotated)
- Committer:
- pravinautosys
- Date:
- Sat Nov 19 10:38:54 2016 +0000
- Revision:
- 151:acf04f8e7d03
- Parent:
- 149:156823d33999
MyMBED-DEVWithSTM32F303K8T6;
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f3xx_hal_pcd.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 144:ef7eb2e8f9f7 | 5 | * @version V1.3.0 |
<> | 144:ef7eb2e8f9f7 | 6 | * @date 01-July-2016 |
<> | 144:ef7eb2e8f9f7 | 7 | * @brief PCD HAL module driver. |
<> | 144:ef7eb2e8f9f7 | 8 | * This file provides firmware functions to manage the following |
<> | 144:ef7eb2e8f9f7 | 9 | * functionalities of the USB Peripheral Controller: |
<> | 144:ef7eb2e8f9f7 | 10 | * + Initialization and de-initialization functions |
<> | 144:ef7eb2e8f9f7 | 11 | * + IO operation functions |
<> | 144:ef7eb2e8f9f7 | 12 | * + Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 13 | * + Peripheral State functions |
<> | 144:ef7eb2e8f9f7 | 14 | * |
<> | 144:ef7eb2e8f9f7 | 15 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 16 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 17 | ##### How to use this driver ##### |
<> | 144:ef7eb2e8f9f7 | 18 | ============================================================================== |
<> | 144:ef7eb2e8f9f7 | 19 | [..] |
<> | 144:ef7eb2e8f9f7 | 20 | The PCD HAL driver can be used as follows: |
<> | 144:ef7eb2e8f9f7 | 21 | |
<> | 144:ef7eb2e8f9f7 | 22 | (#) Declare a PCD_HandleTypeDef handle structure, for example: |
<> | 144:ef7eb2e8f9f7 | 23 | PCD_HandleTypeDef hpcd; |
<> | 144:ef7eb2e8f9f7 | 24 | |
<> | 144:ef7eb2e8f9f7 | 25 | (#) Fill parameters of Init structure in HCD handle |
<> | 144:ef7eb2e8f9f7 | 26 | |
<> | 144:ef7eb2e8f9f7 | 27 | (#) Call HAL_PCD_Init() API to initialize the HCD peripheral (Core, Device core, ...) |
<> | 144:ef7eb2e8f9f7 | 28 | |
<> | 144:ef7eb2e8f9f7 | 29 | (#) Initialize the PCD low level resources through the HAL_PCD_MspInit() API: |
<> | 144:ef7eb2e8f9f7 | 30 | (##) Enable the PCD/USB Low Level interface clock using |
<> | 144:ef7eb2e8f9f7 | 31 | (+++) __HAL_RCC_USB_CLK_ENABLE(); |
<> | 144:ef7eb2e8f9f7 | 32 | |
<> | 144:ef7eb2e8f9f7 | 33 | (##) Initialize the related GPIO clocks |
<> | 144:ef7eb2e8f9f7 | 34 | (##) Configure PCD pin-out |
<> | 144:ef7eb2e8f9f7 | 35 | (##) Configure PCD NVIC interrupt |
<> | 144:ef7eb2e8f9f7 | 36 | |
<> | 144:ef7eb2e8f9f7 | 37 | (#)Associate the Upper USB device stack to the HAL PCD Driver: |
<> | 144:ef7eb2e8f9f7 | 38 | (##) hpcd.pData = pdev; |
<> | 144:ef7eb2e8f9f7 | 39 | |
<> | 144:ef7eb2e8f9f7 | 40 | (#)Enable HCD transmission and reception: |
<> | 144:ef7eb2e8f9f7 | 41 | (##) HAL_PCD_Start(); |
<> | 144:ef7eb2e8f9f7 | 42 | |
<> | 144:ef7eb2e8f9f7 | 43 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 44 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 45 | * @attention |
<> | 144:ef7eb2e8f9f7 | 46 | * |
<> | 144:ef7eb2e8f9f7 | 47 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 48 | * |
<> | 144:ef7eb2e8f9f7 | 49 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 50 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 51 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 52 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 53 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 54 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 55 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 56 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 57 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 58 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 59 | * |
<> | 144:ef7eb2e8f9f7 | 60 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 61 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 62 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 63 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 64 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 65 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 66 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 67 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 68 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 69 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 70 | * |
<> | 144:ef7eb2e8f9f7 | 71 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 72 | */ |
<> | 144:ef7eb2e8f9f7 | 73 | |
<> | 144:ef7eb2e8f9f7 | 74 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 75 | #include "stm32f3xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 76 | |
<> | 144:ef7eb2e8f9f7 | 77 | #ifdef HAL_PCD_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 78 | |
<> | 144:ef7eb2e8f9f7 | 79 | #if defined(STM32F302xE) || defined(STM32F303xE) || \ |
<> | 144:ef7eb2e8f9f7 | 80 | defined(STM32F302xC) || defined(STM32F303xC) || \ |
<> | 144:ef7eb2e8f9f7 | 81 | defined(STM32F302x8) || \ |
<> | 144:ef7eb2e8f9f7 | 82 | defined(STM32F373xC) |
<> | 144:ef7eb2e8f9f7 | 83 | |
<> | 144:ef7eb2e8f9f7 | 84 | /** @addtogroup STM32F3xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 85 | * @{ |
<> | 144:ef7eb2e8f9f7 | 86 | */ |
<> | 144:ef7eb2e8f9f7 | 87 | |
<> | 144:ef7eb2e8f9f7 | 88 | /** @defgroup PCD PCD |
<> | 144:ef7eb2e8f9f7 | 89 | * @brief PCD HAL module driver |
<> | 144:ef7eb2e8f9f7 | 90 | * @{ |
<> | 144:ef7eb2e8f9f7 | 91 | */ |
<> | 144:ef7eb2e8f9f7 | 92 | |
<> | 144:ef7eb2e8f9f7 | 93 | /* Private typedef -----------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 94 | /* Private define ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 95 | |
<> | 144:ef7eb2e8f9f7 | 96 | /** @defgroup PCD_Private_Define PCD Private Define |
<> | 144:ef7eb2e8f9f7 | 97 | * @{ |
<> | 144:ef7eb2e8f9f7 | 98 | */ |
<> | 144:ef7eb2e8f9f7 | 99 | #define BTABLE_ADDRESS (0x000) |
<> | 144:ef7eb2e8f9f7 | 100 | /** |
<> | 144:ef7eb2e8f9f7 | 101 | * @} |
<> | 144:ef7eb2e8f9f7 | 102 | */ |
<> | 144:ef7eb2e8f9f7 | 103 | |
<> | 144:ef7eb2e8f9f7 | 104 | /* Private macro -------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 105 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 106 | /* Private function prototypes -----------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 107 | /** @defgroup PCD_Private_Functions PCD Private Functions |
<> | 144:ef7eb2e8f9f7 | 108 | * @{ |
<> | 144:ef7eb2e8f9f7 | 109 | */ |
<> | 144:ef7eb2e8f9f7 | 110 | static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd); |
<> | 144:ef7eb2e8f9f7 | 111 | /** |
<> | 144:ef7eb2e8f9f7 | 112 | * @} |
<> | 144:ef7eb2e8f9f7 | 113 | */ |
<> | 144:ef7eb2e8f9f7 | 114 | |
<> | 144:ef7eb2e8f9f7 | 115 | /* Exported functions ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 116 | |
<> | 144:ef7eb2e8f9f7 | 117 | /** @defgroup PCD_Exported_Functions PCD Exported Functions |
<> | 144:ef7eb2e8f9f7 | 118 | * @{ |
<> | 144:ef7eb2e8f9f7 | 119 | */ |
<> | 144:ef7eb2e8f9f7 | 120 | |
<> | 144:ef7eb2e8f9f7 | 121 | /** @defgroup PCD_Exported_Functions_Group1 Initialization and de-initialization functions |
<> | 144:ef7eb2e8f9f7 | 122 | * @brief Initialization and Configuration functions |
<> | 144:ef7eb2e8f9f7 | 123 | * |
<> | 144:ef7eb2e8f9f7 | 124 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 125 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 126 | ##### Initialization and de-initialization functions ##### |
<> | 144:ef7eb2e8f9f7 | 127 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 128 | [..] This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 129 | |
<> | 144:ef7eb2e8f9f7 | 130 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 131 | * @{ |
<> | 144:ef7eb2e8f9f7 | 132 | */ |
<> | 144:ef7eb2e8f9f7 | 133 | |
<> | 144:ef7eb2e8f9f7 | 134 | /** |
<> | 144:ef7eb2e8f9f7 | 135 | * @brief Initializes the PCD according to the specified |
<> | 144:ef7eb2e8f9f7 | 136 | * parameters in the PCD_InitTypeDef and create the associated handle. |
<> | 144:ef7eb2e8f9f7 | 137 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 138 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 139 | */ |
<> | 144:ef7eb2e8f9f7 | 140 | HAL_StatusTypeDef HAL_PCD_Init(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 141 | { |
<> | 144:ef7eb2e8f9f7 | 142 | uint32_t i = 0; |
<> | 144:ef7eb2e8f9f7 | 143 | |
<> | 144:ef7eb2e8f9f7 | 144 | uint32_t wInterrupt_Mask = 0; |
<> | 144:ef7eb2e8f9f7 | 145 | |
<> | 144:ef7eb2e8f9f7 | 146 | /* Check the PCD handle allocation */ |
<> | 144:ef7eb2e8f9f7 | 147 | if(hpcd == NULL) |
<> | 144:ef7eb2e8f9f7 | 148 | { |
<> | 144:ef7eb2e8f9f7 | 149 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 150 | } |
<> | 144:ef7eb2e8f9f7 | 151 | |
<> | 144:ef7eb2e8f9f7 | 152 | /* Check the parameters */ |
<> | 144:ef7eb2e8f9f7 | 153 | assert_param(IS_PCD_ALL_INSTANCE(hpcd->Instance)); |
<> | 144:ef7eb2e8f9f7 | 154 | |
<> | 144:ef7eb2e8f9f7 | 155 | if(hpcd->State == HAL_PCD_STATE_RESET) |
<> | 144:ef7eb2e8f9f7 | 156 | { |
<> | 144:ef7eb2e8f9f7 | 157 | /* Allocate lock resource and initialize it */ |
<> | 144:ef7eb2e8f9f7 | 158 | hpcd->Lock = HAL_UNLOCKED; |
<> | 144:ef7eb2e8f9f7 | 159 | |
<> | 144:ef7eb2e8f9f7 | 160 | /* Init the low level hardware : GPIO, CLOCK, NVIC... */ |
<> | 144:ef7eb2e8f9f7 | 161 | HAL_PCD_MspInit(hpcd); |
<> | 144:ef7eb2e8f9f7 | 162 | } |
<> | 144:ef7eb2e8f9f7 | 163 | |
<> | 144:ef7eb2e8f9f7 | 164 | hpcd->State = HAL_PCD_STATE_BUSY; |
<> | 144:ef7eb2e8f9f7 | 165 | |
<> | 144:ef7eb2e8f9f7 | 166 | /* Init endpoints structures */ |
<> | 144:ef7eb2e8f9f7 | 167 | for (i = 0; i < hpcd->Init.dev_endpoints ; i++) |
<> | 144:ef7eb2e8f9f7 | 168 | { |
<> | 144:ef7eb2e8f9f7 | 169 | /* Init ep structure */ |
<> | 144:ef7eb2e8f9f7 | 170 | hpcd->IN_ep[i].is_in = 1; |
<> | 144:ef7eb2e8f9f7 | 171 | hpcd->IN_ep[i].num = i; |
<> | 144:ef7eb2e8f9f7 | 172 | /* Control until ep is actvated */ |
<> | 144:ef7eb2e8f9f7 | 173 | hpcd->IN_ep[i].type = PCD_EP_TYPE_CTRL; |
<> | 144:ef7eb2e8f9f7 | 174 | hpcd->IN_ep[i].maxpacket = 0; |
<> | 144:ef7eb2e8f9f7 | 175 | hpcd->IN_ep[i].xfer_buff = 0; |
<> | 144:ef7eb2e8f9f7 | 176 | hpcd->IN_ep[i].xfer_len = 0; |
<> | 144:ef7eb2e8f9f7 | 177 | } |
<> | 144:ef7eb2e8f9f7 | 178 | |
<> | 144:ef7eb2e8f9f7 | 179 | for (i = 0; i < hpcd->Init.dev_endpoints ; i++) |
<> | 144:ef7eb2e8f9f7 | 180 | { |
<> | 144:ef7eb2e8f9f7 | 181 | hpcd->OUT_ep[i].is_in = 0; |
<> | 144:ef7eb2e8f9f7 | 182 | hpcd->OUT_ep[i].num = i; |
<> | 144:ef7eb2e8f9f7 | 183 | /* Control until ep is activated */ |
<> | 144:ef7eb2e8f9f7 | 184 | hpcd->OUT_ep[i].type = PCD_EP_TYPE_CTRL; |
<> | 144:ef7eb2e8f9f7 | 185 | hpcd->OUT_ep[i].maxpacket = 0; |
<> | 144:ef7eb2e8f9f7 | 186 | hpcd->OUT_ep[i].xfer_buff = 0; |
<> | 144:ef7eb2e8f9f7 | 187 | hpcd->OUT_ep[i].xfer_len = 0; |
<> | 144:ef7eb2e8f9f7 | 188 | } |
<> | 144:ef7eb2e8f9f7 | 189 | |
<> | 144:ef7eb2e8f9f7 | 190 | /* Init Device */ |
<> | 144:ef7eb2e8f9f7 | 191 | /*CNTR_FRES = 1*/ |
<> | 144:ef7eb2e8f9f7 | 192 | hpcd->Instance->CNTR = USB_CNTR_FRES; |
<> | 144:ef7eb2e8f9f7 | 193 | |
<> | 144:ef7eb2e8f9f7 | 194 | /*CNTR_FRES = 0*/ |
<> | 144:ef7eb2e8f9f7 | 195 | hpcd->Instance->CNTR = 0; |
<> | 144:ef7eb2e8f9f7 | 196 | |
<> | 144:ef7eb2e8f9f7 | 197 | /*Clear pending interrupts*/ |
<> | 144:ef7eb2e8f9f7 | 198 | hpcd->Instance->ISTR = 0; |
<> | 144:ef7eb2e8f9f7 | 199 | |
<> | 144:ef7eb2e8f9f7 | 200 | /*Set Btable Adress*/ |
<> | 144:ef7eb2e8f9f7 | 201 | hpcd->Instance->BTABLE = BTABLE_ADDRESS; |
<> | 144:ef7eb2e8f9f7 | 202 | |
<> | 144:ef7eb2e8f9f7 | 203 | /*set wInterrupt_Mask global variable*/ |
<> | 144:ef7eb2e8f9f7 | 204 | wInterrupt_Mask = USB_CNTR_CTRM | USB_CNTR_WKUPM | USB_CNTR_SUSPM | USB_CNTR_ERRM \ |
<> | 144:ef7eb2e8f9f7 | 205 | | USB_CNTR_ESOFM | USB_CNTR_RESETM; |
<> | 144:ef7eb2e8f9f7 | 206 | |
<> | 144:ef7eb2e8f9f7 | 207 | /*Set interrupt mask*/ |
<> | 144:ef7eb2e8f9f7 | 208 | hpcd->Instance->CNTR = wInterrupt_Mask; |
<> | 144:ef7eb2e8f9f7 | 209 | |
<> | 144:ef7eb2e8f9f7 | 210 | hpcd->USB_Address = 0; |
<> | 144:ef7eb2e8f9f7 | 211 | hpcd->State= HAL_PCD_STATE_READY; |
<> | 144:ef7eb2e8f9f7 | 212 | |
<> | 144:ef7eb2e8f9f7 | 213 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 214 | } |
<> | 144:ef7eb2e8f9f7 | 215 | |
<> | 144:ef7eb2e8f9f7 | 216 | /** |
<> | 144:ef7eb2e8f9f7 | 217 | * @brief DeInitializes the PCD peripheral |
<> | 144:ef7eb2e8f9f7 | 218 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 219 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 220 | */ |
<> | 144:ef7eb2e8f9f7 | 221 | HAL_StatusTypeDef HAL_PCD_DeInit(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 222 | { |
<> | 144:ef7eb2e8f9f7 | 223 | /* Check the PCD handle allocation */ |
<> | 144:ef7eb2e8f9f7 | 224 | if(hpcd == NULL) |
<> | 144:ef7eb2e8f9f7 | 225 | { |
<> | 144:ef7eb2e8f9f7 | 226 | return HAL_ERROR; |
<> | 144:ef7eb2e8f9f7 | 227 | } |
<> | 144:ef7eb2e8f9f7 | 228 | |
<> | 144:ef7eb2e8f9f7 | 229 | hpcd->State = HAL_PCD_STATE_BUSY; |
<> | 144:ef7eb2e8f9f7 | 230 | |
<> | 144:ef7eb2e8f9f7 | 231 | /* Stop Device */ |
<> | 144:ef7eb2e8f9f7 | 232 | HAL_PCD_Stop(hpcd); |
<> | 144:ef7eb2e8f9f7 | 233 | |
<> | 144:ef7eb2e8f9f7 | 234 | /* DeInit the low level hardware */ |
<> | 144:ef7eb2e8f9f7 | 235 | HAL_PCD_MspDeInit(hpcd); |
<> | 144:ef7eb2e8f9f7 | 236 | |
<> | 144:ef7eb2e8f9f7 | 237 | hpcd->State = HAL_PCD_STATE_RESET; |
<> | 144:ef7eb2e8f9f7 | 238 | |
<> | 144:ef7eb2e8f9f7 | 239 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 240 | } |
<> | 144:ef7eb2e8f9f7 | 241 | |
<> | 144:ef7eb2e8f9f7 | 242 | /** |
<> | 144:ef7eb2e8f9f7 | 243 | * @brief Initializes the PCD MSP. |
<> | 144:ef7eb2e8f9f7 | 244 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 245 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 246 | */ |
<> | 144:ef7eb2e8f9f7 | 247 | __weak void HAL_PCD_MspInit(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 248 | { |
<> | 144:ef7eb2e8f9f7 | 249 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 250 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 251 | |
<> | 144:ef7eb2e8f9f7 | 252 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 253 | the HAL_PCD_MspInit could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 254 | */ |
<> | 144:ef7eb2e8f9f7 | 255 | } |
<> | 144:ef7eb2e8f9f7 | 256 | |
<> | 144:ef7eb2e8f9f7 | 257 | /** |
<> | 144:ef7eb2e8f9f7 | 258 | * @brief DeInitializes PCD MSP. |
<> | 144:ef7eb2e8f9f7 | 259 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 260 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 261 | */ |
<> | 144:ef7eb2e8f9f7 | 262 | __weak void HAL_PCD_MspDeInit(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 263 | { |
<> | 144:ef7eb2e8f9f7 | 264 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 265 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 266 | |
<> | 144:ef7eb2e8f9f7 | 267 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 268 | the HAL_PCD_MspDeInit could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 269 | */ |
<> | 144:ef7eb2e8f9f7 | 270 | } |
<> | 144:ef7eb2e8f9f7 | 271 | |
<> | 144:ef7eb2e8f9f7 | 272 | /** |
<> | 144:ef7eb2e8f9f7 | 273 | * @} |
<> | 144:ef7eb2e8f9f7 | 274 | */ |
<> | 144:ef7eb2e8f9f7 | 275 | |
<> | 144:ef7eb2e8f9f7 | 276 | /** @defgroup PCD_Exported_Functions_Group2 IO operation functions |
<> | 144:ef7eb2e8f9f7 | 277 | * @brief Data transfers functions |
<> | 144:ef7eb2e8f9f7 | 278 | * |
<> | 144:ef7eb2e8f9f7 | 279 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 280 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 281 | ##### IO operation functions ##### |
<> | 144:ef7eb2e8f9f7 | 282 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 283 | [..] |
<> | 144:ef7eb2e8f9f7 | 284 | This subsection provides a set of functions allowing to manage the PCD data |
<> | 144:ef7eb2e8f9f7 | 285 | transfers. |
<> | 144:ef7eb2e8f9f7 | 286 | |
<> | 144:ef7eb2e8f9f7 | 287 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 288 | * @{ |
<> | 144:ef7eb2e8f9f7 | 289 | */ |
<> | 144:ef7eb2e8f9f7 | 290 | |
<> | 144:ef7eb2e8f9f7 | 291 | /** |
<> | 144:ef7eb2e8f9f7 | 292 | * @brief Start the USB device. |
<> | 144:ef7eb2e8f9f7 | 293 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 294 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 295 | */ |
<> | 144:ef7eb2e8f9f7 | 296 | HAL_StatusTypeDef HAL_PCD_Start(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 297 | { |
<> | 144:ef7eb2e8f9f7 | 298 | /* DP Pull-Down is external */ |
<> | 144:ef7eb2e8f9f7 | 299 | HAL_PCDEx_SetConnectionState (hpcd, 1); |
<> | 144:ef7eb2e8f9f7 | 300 | |
<> | 144:ef7eb2e8f9f7 | 301 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 302 | } |
<> | 144:ef7eb2e8f9f7 | 303 | |
<> | 144:ef7eb2e8f9f7 | 304 | /** |
<> | 144:ef7eb2e8f9f7 | 305 | * @brief Stop the USB device. |
<> | 144:ef7eb2e8f9f7 | 306 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 307 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 308 | */ |
<> | 144:ef7eb2e8f9f7 | 309 | HAL_StatusTypeDef HAL_PCD_Stop(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 310 | { |
<> | 144:ef7eb2e8f9f7 | 311 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 312 | |
<> | 144:ef7eb2e8f9f7 | 313 | /* disable all interrupts and force USB reset */ |
<> | 144:ef7eb2e8f9f7 | 314 | hpcd->Instance->CNTR = USB_CNTR_FRES; |
<> | 144:ef7eb2e8f9f7 | 315 | |
<> | 144:ef7eb2e8f9f7 | 316 | /* clear interrupt status register */ |
<> | 144:ef7eb2e8f9f7 | 317 | hpcd->Instance->ISTR = 0; |
<> | 144:ef7eb2e8f9f7 | 318 | |
<> | 144:ef7eb2e8f9f7 | 319 | /* switch-off device */ |
<> | 144:ef7eb2e8f9f7 | 320 | hpcd->Instance->CNTR = (USB_CNTR_FRES | USB_CNTR_PDWN); |
<> | 144:ef7eb2e8f9f7 | 321 | |
<> | 144:ef7eb2e8f9f7 | 322 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 323 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 324 | } |
<> | 144:ef7eb2e8f9f7 | 325 | /** |
<> | 144:ef7eb2e8f9f7 | 326 | * @} |
<> | 144:ef7eb2e8f9f7 | 327 | */ |
<> | 144:ef7eb2e8f9f7 | 328 | |
<> | 144:ef7eb2e8f9f7 | 329 | /** |
<> | 144:ef7eb2e8f9f7 | 330 | * @} |
<> | 144:ef7eb2e8f9f7 | 331 | */ |
<> | 144:ef7eb2e8f9f7 | 332 | |
<> | 144:ef7eb2e8f9f7 | 333 | /** @addtogroup PCD_Private_Functions PCD Private Functions |
<> | 144:ef7eb2e8f9f7 | 334 | * @{ |
<> | 144:ef7eb2e8f9f7 | 335 | */ |
<> | 144:ef7eb2e8f9f7 | 336 | /** |
<> | 144:ef7eb2e8f9f7 | 337 | * @brief This function handles PCD Endpoint interrupt request. |
<> | 144:ef7eb2e8f9f7 | 338 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 339 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 340 | */ |
<> | 144:ef7eb2e8f9f7 | 341 | static HAL_StatusTypeDef PCD_EP_ISR_Handler(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 342 | { |
<> | 144:ef7eb2e8f9f7 | 343 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 344 | uint16_t count=0; |
<> | 144:ef7eb2e8f9f7 | 345 | uint8_t EPindex; |
<> | 144:ef7eb2e8f9f7 | 346 | __IO uint16_t wIstr; |
<> | 144:ef7eb2e8f9f7 | 347 | __IO uint16_t wEPVal = 0; |
<> | 144:ef7eb2e8f9f7 | 348 | |
<> | 144:ef7eb2e8f9f7 | 349 | /* stay in loop while pending interrupts */ |
<> | 144:ef7eb2e8f9f7 | 350 | while (((wIstr = hpcd->Instance->ISTR) & USB_ISTR_CTR) != 0) |
<> | 144:ef7eb2e8f9f7 | 351 | { |
<> | 144:ef7eb2e8f9f7 | 352 | /* extract highest priority endpoint number */ |
<> | 144:ef7eb2e8f9f7 | 353 | EPindex = (uint8_t)(wIstr & USB_ISTR_EP_ID); |
<> | 144:ef7eb2e8f9f7 | 354 | |
<> | 144:ef7eb2e8f9f7 | 355 | if (EPindex == 0) |
<> | 144:ef7eb2e8f9f7 | 356 | { |
<> | 144:ef7eb2e8f9f7 | 357 | /* Decode and service control endpoint interrupt */ |
<> | 144:ef7eb2e8f9f7 | 358 | |
<> | 144:ef7eb2e8f9f7 | 359 | /* DIR bit = origin of the interrupt */ |
<> | 144:ef7eb2e8f9f7 | 360 | if ((wIstr & USB_ISTR_DIR) == 0) |
<> | 144:ef7eb2e8f9f7 | 361 | { |
<> | 144:ef7eb2e8f9f7 | 362 | /* DIR = 0 */ |
<> | 144:ef7eb2e8f9f7 | 363 | |
<> | 144:ef7eb2e8f9f7 | 364 | /* DIR = 0 => IN int */ |
<> | 144:ef7eb2e8f9f7 | 365 | /* DIR = 0 implies that (EP_CTR_TX = 1) always */ |
<> | 144:ef7eb2e8f9f7 | 366 | PCD_CLEAR_TX_EP_CTR(hpcd->Instance, PCD_ENDP0); |
<> | 144:ef7eb2e8f9f7 | 367 | ep = &hpcd->IN_ep[0]; |
<> | 144:ef7eb2e8f9f7 | 368 | |
<> | 144:ef7eb2e8f9f7 | 369 | ep->xfer_count = PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 370 | ep->xfer_buff += ep->xfer_count; |
<> | 144:ef7eb2e8f9f7 | 371 | |
<> | 144:ef7eb2e8f9f7 | 372 | /* TX COMPLETE */ |
<> | 144:ef7eb2e8f9f7 | 373 | HAL_PCD_DataInStageCallback(hpcd, 0); |
<> | 144:ef7eb2e8f9f7 | 374 | |
<> | 144:ef7eb2e8f9f7 | 375 | |
<> | 144:ef7eb2e8f9f7 | 376 | if((hpcd->USB_Address > 0)&& ( ep->xfer_len == 0)) |
<> | 144:ef7eb2e8f9f7 | 377 | { |
<> | 144:ef7eb2e8f9f7 | 378 | hpcd->Instance->DADDR = (hpcd->USB_Address | USB_DADDR_EF); |
<> | 144:ef7eb2e8f9f7 | 379 | hpcd->USB_Address = 0; |
<> | 144:ef7eb2e8f9f7 | 380 | } |
<> | 144:ef7eb2e8f9f7 | 381 | |
<> | 144:ef7eb2e8f9f7 | 382 | } |
<> | 144:ef7eb2e8f9f7 | 383 | else |
<> | 144:ef7eb2e8f9f7 | 384 | { |
<> | 144:ef7eb2e8f9f7 | 385 | /* DIR = 1 */ |
<> | 144:ef7eb2e8f9f7 | 386 | |
<> | 144:ef7eb2e8f9f7 | 387 | /* DIR = 1 & CTR_RX => SETUP or OUT int */ |
<> | 144:ef7eb2e8f9f7 | 388 | /* DIR = 1 & (CTR_TX | CTR_RX) => 2 int pending */ |
<> | 144:ef7eb2e8f9f7 | 389 | ep = &hpcd->OUT_ep[0]; |
<> | 144:ef7eb2e8f9f7 | 390 | wEPVal = PCD_GET_ENDPOINT(hpcd->Instance, PCD_ENDP0); |
<> | 144:ef7eb2e8f9f7 | 391 | |
<> | 144:ef7eb2e8f9f7 | 392 | if ((wEPVal & USB_EP_SETUP) != 0) |
<> | 144:ef7eb2e8f9f7 | 393 | { |
<> | 144:ef7eb2e8f9f7 | 394 | /* Get SETUP Packet*/ |
<> | 144:ef7eb2e8f9f7 | 395 | ep->xfer_count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 396 | PCD_ReadPMA(hpcd->Instance, (uint8_t*)hpcd->Setup ,ep->pmaadress , ep->xfer_count); |
<> | 144:ef7eb2e8f9f7 | 397 | /* SETUP bit kept frozen while CTR_RX = 1*/ |
<> | 144:ef7eb2e8f9f7 | 398 | PCD_CLEAR_RX_EP_CTR(hpcd->Instance, PCD_ENDP0); |
<> | 144:ef7eb2e8f9f7 | 399 | |
<> | 144:ef7eb2e8f9f7 | 400 | /* Process SETUP Packet*/ |
<> | 144:ef7eb2e8f9f7 | 401 | HAL_PCD_SetupStageCallback(hpcd); |
<> | 144:ef7eb2e8f9f7 | 402 | } |
<> | 144:ef7eb2e8f9f7 | 403 | |
<> | 144:ef7eb2e8f9f7 | 404 | else if ((wEPVal & USB_EP_CTR_RX) != 0) |
<> | 144:ef7eb2e8f9f7 | 405 | { |
<> | 144:ef7eb2e8f9f7 | 406 | PCD_CLEAR_RX_EP_CTR(hpcd->Instance, PCD_ENDP0); |
<> | 144:ef7eb2e8f9f7 | 407 | /* Get Control Data OUT Packet*/ |
<> | 144:ef7eb2e8f9f7 | 408 | ep->xfer_count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 409 | |
<> | 144:ef7eb2e8f9f7 | 410 | if (ep->xfer_count != 0) |
<> | 144:ef7eb2e8f9f7 | 411 | { |
<> | 144:ef7eb2e8f9f7 | 412 | PCD_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaadress, ep->xfer_count); |
<> | 144:ef7eb2e8f9f7 | 413 | ep->xfer_buff+=ep->xfer_count; |
<> | 144:ef7eb2e8f9f7 | 414 | } |
<> | 144:ef7eb2e8f9f7 | 415 | |
<> | 144:ef7eb2e8f9f7 | 416 | /* Process Control Data OUT Packet*/ |
<> | 144:ef7eb2e8f9f7 | 417 | HAL_PCD_DataOutStageCallback(hpcd, 0); |
<> | 144:ef7eb2e8f9f7 | 418 | |
<> | 144:ef7eb2e8f9f7 | 419 | PCD_SET_EP_RX_CNT(hpcd->Instance, PCD_ENDP0, ep->maxpacket); |
<> | 144:ef7eb2e8f9f7 | 420 | PCD_SET_EP_RX_STATUS(hpcd->Instance, PCD_ENDP0, USB_EP_RX_VALID); |
<> | 144:ef7eb2e8f9f7 | 421 | } |
<> | 144:ef7eb2e8f9f7 | 422 | } |
<> | 144:ef7eb2e8f9f7 | 423 | } |
<> | 144:ef7eb2e8f9f7 | 424 | else |
<> | 144:ef7eb2e8f9f7 | 425 | { |
<> | 144:ef7eb2e8f9f7 | 426 | |
<> | 144:ef7eb2e8f9f7 | 427 | /* Decode and service non control endpoints interrupt */ |
<> | 144:ef7eb2e8f9f7 | 428 | |
<> | 144:ef7eb2e8f9f7 | 429 | /* process related endpoint register */ |
<> | 144:ef7eb2e8f9f7 | 430 | wEPVal = PCD_GET_ENDPOINT(hpcd->Instance, EPindex); |
<> | 144:ef7eb2e8f9f7 | 431 | if ((wEPVal & USB_EP_CTR_RX) != 0) |
<> | 144:ef7eb2e8f9f7 | 432 | { |
<> | 144:ef7eb2e8f9f7 | 433 | /* clear int flag */ |
<> | 144:ef7eb2e8f9f7 | 434 | PCD_CLEAR_RX_EP_CTR(hpcd->Instance, EPindex); |
<> | 144:ef7eb2e8f9f7 | 435 | ep = &hpcd->OUT_ep[EPindex]; |
<> | 144:ef7eb2e8f9f7 | 436 | |
<> | 144:ef7eb2e8f9f7 | 437 | /* OUT double Buffering*/ |
<> | 144:ef7eb2e8f9f7 | 438 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 439 | { |
<> | 144:ef7eb2e8f9f7 | 440 | count = PCD_GET_EP_RX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 441 | if (count != 0) |
<> | 144:ef7eb2e8f9f7 | 442 | { |
<> | 144:ef7eb2e8f9f7 | 443 | PCD_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaadress, count); |
<> | 144:ef7eb2e8f9f7 | 444 | } |
<> | 144:ef7eb2e8f9f7 | 445 | } |
<> | 144:ef7eb2e8f9f7 | 446 | else |
<> | 144:ef7eb2e8f9f7 | 447 | { |
<> | 144:ef7eb2e8f9f7 | 448 | if (PCD_GET_ENDPOINT(hpcd->Instance, ep->num) & USB_EP_DTOG_RX) |
<> | 144:ef7eb2e8f9f7 | 449 | { |
<> | 144:ef7eb2e8f9f7 | 450 | /*read from endpoint BUF0Addr buffer*/ |
<> | 144:ef7eb2e8f9f7 | 451 | count = PCD_GET_EP_DBUF0_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 452 | if (count != 0) |
<> | 144:ef7eb2e8f9f7 | 453 | { |
<> | 144:ef7eb2e8f9f7 | 454 | PCD_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr0, count); |
<> | 144:ef7eb2e8f9f7 | 455 | } |
<> | 144:ef7eb2e8f9f7 | 456 | } |
<> | 144:ef7eb2e8f9f7 | 457 | else |
<> | 144:ef7eb2e8f9f7 | 458 | { |
<> | 144:ef7eb2e8f9f7 | 459 | /*read from endpoint BUF1Addr buffer*/ |
<> | 144:ef7eb2e8f9f7 | 460 | count = PCD_GET_EP_DBUF1_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 461 | if (count != 0) |
<> | 144:ef7eb2e8f9f7 | 462 | { |
<> | 144:ef7eb2e8f9f7 | 463 | PCD_ReadPMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr1, count); |
<> | 144:ef7eb2e8f9f7 | 464 | } |
<> | 144:ef7eb2e8f9f7 | 465 | } |
<> | 144:ef7eb2e8f9f7 | 466 | PCD_FreeUserBuffer(hpcd->Instance, ep->num, PCD_EP_DBUF_OUT); |
<> | 144:ef7eb2e8f9f7 | 467 | } |
<> | 144:ef7eb2e8f9f7 | 468 | /*multi-packet on the NON control OUT endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 469 | ep->xfer_count+=count; |
<> | 144:ef7eb2e8f9f7 | 470 | ep->xfer_buff+=count; |
<> | 144:ef7eb2e8f9f7 | 471 | |
<> | 144:ef7eb2e8f9f7 | 472 | if ((ep->xfer_len == 0) || (count < ep->maxpacket)) |
<> | 144:ef7eb2e8f9f7 | 473 | { |
<> | 144:ef7eb2e8f9f7 | 474 | /* RX COMPLETE */ |
<> | 144:ef7eb2e8f9f7 | 475 | HAL_PCD_DataOutStageCallback(hpcd, ep->num); |
<> | 144:ef7eb2e8f9f7 | 476 | } |
<> | 144:ef7eb2e8f9f7 | 477 | else |
<> | 144:ef7eb2e8f9f7 | 478 | { |
<> | 144:ef7eb2e8f9f7 | 479 | HAL_PCD_EP_Receive(hpcd, ep->num, ep->xfer_buff, ep->xfer_len); |
<> | 144:ef7eb2e8f9f7 | 480 | } |
<> | 144:ef7eb2e8f9f7 | 481 | |
<> | 144:ef7eb2e8f9f7 | 482 | } /* if((wEPVal & EP_CTR_RX) */ |
<> | 144:ef7eb2e8f9f7 | 483 | |
<> | 144:ef7eb2e8f9f7 | 484 | if ((wEPVal & USB_EP_CTR_TX) != 0) |
<> | 144:ef7eb2e8f9f7 | 485 | { |
<> | 144:ef7eb2e8f9f7 | 486 | ep = &hpcd->IN_ep[EPindex]; |
<> | 144:ef7eb2e8f9f7 | 487 | |
<> | 144:ef7eb2e8f9f7 | 488 | /* clear int flag */ |
<> | 144:ef7eb2e8f9f7 | 489 | PCD_CLEAR_TX_EP_CTR(hpcd->Instance, EPindex); |
<> | 144:ef7eb2e8f9f7 | 490 | |
<> | 144:ef7eb2e8f9f7 | 491 | /* IN double Buffering*/ |
<> | 144:ef7eb2e8f9f7 | 492 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 493 | { |
<> | 144:ef7eb2e8f9f7 | 494 | ep->xfer_count = PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 495 | if (ep->xfer_count != 0) |
<> | 144:ef7eb2e8f9f7 | 496 | { |
<> | 144:ef7eb2e8f9f7 | 497 | PCD_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaadress, ep->xfer_count); |
<> | 144:ef7eb2e8f9f7 | 498 | } |
<> | 144:ef7eb2e8f9f7 | 499 | } |
<> | 144:ef7eb2e8f9f7 | 500 | else |
<> | 144:ef7eb2e8f9f7 | 501 | { |
<> | 144:ef7eb2e8f9f7 | 502 | if (PCD_GET_ENDPOINT(hpcd->Instance, ep->num) & USB_EP_DTOG_TX) |
<> | 144:ef7eb2e8f9f7 | 503 | { |
<> | 144:ef7eb2e8f9f7 | 504 | /*read from endpoint BUF0Addr buffer*/ |
<> | 144:ef7eb2e8f9f7 | 505 | ep->xfer_count = PCD_GET_EP_DBUF0_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 506 | if (ep->xfer_count != 0) |
<> | 144:ef7eb2e8f9f7 | 507 | { |
<> | 144:ef7eb2e8f9f7 | 508 | PCD_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr0, ep->xfer_count); |
<> | 144:ef7eb2e8f9f7 | 509 | } |
<> | 144:ef7eb2e8f9f7 | 510 | } |
<> | 144:ef7eb2e8f9f7 | 511 | else |
<> | 144:ef7eb2e8f9f7 | 512 | { |
<> | 144:ef7eb2e8f9f7 | 513 | /*read from endpoint BUF1Addr buffer*/ |
<> | 144:ef7eb2e8f9f7 | 514 | ep->xfer_count = PCD_GET_EP_DBUF1_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 515 | if (ep->xfer_count != 0) |
<> | 144:ef7eb2e8f9f7 | 516 | { |
<> | 144:ef7eb2e8f9f7 | 517 | PCD_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaaddr1, ep->xfer_count); |
<> | 144:ef7eb2e8f9f7 | 518 | } |
<> | 144:ef7eb2e8f9f7 | 519 | } |
<> | 144:ef7eb2e8f9f7 | 520 | PCD_FreeUserBuffer(hpcd->Instance, ep->num, PCD_EP_DBUF_IN); |
<> | 144:ef7eb2e8f9f7 | 521 | } |
<> | 144:ef7eb2e8f9f7 | 522 | /*multi-packet on the NON control IN endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 523 | ep->xfer_count = PCD_GET_EP_TX_CNT(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 524 | ep->xfer_buff+=ep->xfer_count; |
<> | 144:ef7eb2e8f9f7 | 525 | |
<> | 144:ef7eb2e8f9f7 | 526 | /* Zero Length Packet? */ |
<> | 144:ef7eb2e8f9f7 | 527 | if (ep->xfer_len == 0) |
<> | 144:ef7eb2e8f9f7 | 528 | { |
<> | 144:ef7eb2e8f9f7 | 529 | /* TX COMPLETE */ |
<> | 144:ef7eb2e8f9f7 | 530 | HAL_PCD_DataInStageCallback(hpcd, ep->num); |
<> | 144:ef7eb2e8f9f7 | 531 | } |
<> | 144:ef7eb2e8f9f7 | 532 | else |
<> | 144:ef7eb2e8f9f7 | 533 | { |
<> | 144:ef7eb2e8f9f7 | 534 | HAL_PCD_EP_Transmit(hpcd, ep->num, ep->xfer_buff, ep->xfer_len); |
<> | 144:ef7eb2e8f9f7 | 535 | } |
<> | 144:ef7eb2e8f9f7 | 536 | } |
<> | 144:ef7eb2e8f9f7 | 537 | } |
<> | 144:ef7eb2e8f9f7 | 538 | } |
<> | 144:ef7eb2e8f9f7 | 539 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 540 | } |
<> | 144:ef7eb2e8f9f7 | 541 | /** |
<> | 144:ef7eb2e8f9f7 | 542 | * @} |
<> | 144:ef7eb2e8f9f7 | 543 | */ |
<> | 144:ef7eb2e8f9f7 | 544 | |
<> | 144:ef7eb2e8f9f7 | 545 | /** @addtogroup PCD_Exported_Functions |
<> | 144:ef7eb2e8f9f7 | 546 | * @{ |
<> | 144:ef7eb2e8f9f7 | 547 | */ |
<> | 144:ef7eb2e8f9f7 | 548 | |
<> | 144:ef7eb2e8f9f7 | 549 | /** @defgroup PCD_Exported_Functions_Group2 IO operation functions |
<> | 144:ef7eb2e8f9f7 | 550 | * @{ |
<> | 144:ef7eb2e8f9f7 | 551 | */ |
<> | 144:ef7eb2e8f9f7 | 552 | |
<> | 144:ef7eb2e8f9f7 | 553 | /** |
<> | 144:ef7eb2e8f9f7 | 554 | * @brief This function handles PCD interrupt request. |
<> | 144:ef7eb2e8f9f7 | 555 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 556 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 557 | */ |
<> | 144:ef7eb2e8f9f7 | 558 | void HAL_PCD_IRQHandler(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 559 | { |
<> | 144:ef7eb2e8f9f7 | 560 | uint32_t wInterrupt_Mask = 0; |
<> | 144:ef7eb2e8f9f7 | 561 | |
<> | 144:ef7eb2e8f9f7 | 562 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_CTR)) |
<> | 144:ef7eb2e8f9f7 | 563 | { |
<> | 144:ef7eb2e8f9f7 | 564 | /* servicing of the endpoint correct transfer interrupt */ |
<> | 144:ef7eb2e8f9f7 | 565 | /* clear of the CTR flag into the sub */ |
<> | 144:ef7eb2e8f9f7 | 566 | PCD_EP_ISR_Handler(hpcd); |
<> | 144:ef7eb2e8f9f7 | 567 | } |
<> | 144:ef7eb2e8f9f7 | 568 | |
<> | 144:ef7eb2e8f9f7 | 569 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_RESET)) |
<> | 144:ef7eb2e8f9f7 | 570 | { |
<> | 144:ef7eb2e8f9f7 | 571 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_RESET); |
<> | 144:ef7eb2e8f9f7 | 572 | HAL_PCD_ResetCallback(hpcd); |
<> | 144:ef7eb2e8f9f7 | 573 | HAL_PCD_SetAddress(hpcd, 0); |
<> | 144:ef7eb2e8f9f7 | 574 | } |
<> | 144:ef7eb2e8f9f7 | 575 | |
<> | 144:ef7eb2e8f9f7 | 576 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_PMAOVR)) |
<> | 144:ef7eb2e8f9f7 | 577 | { |
<> | 144:ef7eb2e8f9f7 | 578 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_PMAOVR); |
<> | 144:ef7eb2e8f9f7 | 579 | } |
<> | 144:ef7eb2e8f9f7 | 580 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_ERR)) |
<> | 144:ef7eb2e8f9f7 | 581 | { |
<> | 144:ef7eb2e8f9f7 | 582 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_ERR); |
<> | 144:ef7eb2e8f9f7 | 583 | } |
<> | 144:ef7eb2e8f9f7 | 584 | |
<> | 144:ef7eb2e8f9f7 | 585 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_WKUP)) |
<> | 144:ef7eb2e8f9f7 | 586 | { |
<> | 144:ef7eb2e8f9f7 | 587 | hpcd->Instance->CNTR &= ~(USB_CNTR_LPMODE); |
<> | 144:ef7eb2e8f9f7 | 588 | |
<> | 144:ef7eb2e8f9f7 | 589 | /*set wInterrupt_Mask global variable*/ |
<> | 144:ef7eb2e8f9f7 | 590 | wInterrupt_Mask = USB_CNTR_CTRM | USB_CNTR_WKUPM | USB_CNTR_SUSPM | USB_CNTR_ERRM \ |
<> | 144:ef7eb2e8f9f7 | 591 | | USB_CNTR_ESOFM | USB_CNTR_RESETM; |
<> | 144:ef7eb2e8f9f7 | 592 | |
<> | 144:ef7eb2e8f9f7 | 593 | /*Set interrupt mask*/ |
<> | 144:ef7eb2e8f9f7 | 594 | hpcd->Instance->CNTR = wInterrupt_Mask; |
<> | 144:ef7eb2e8f9f7 | 595 | |
<> | 144:ef7eb2e8f9f7 | 596 | HAL_PCD_ResumeCallback(hpcd); |
<> | 144:ef7eb2e8f9f7 | 597 | |
<> | 144:ef7eb2e8f9f7 | 598 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_WKUP); |
<> | 144:ef7eb2e8f9f7 | 599 | } |
<> | 144:ef7eb2e8f9f7 | 600 | |
<> | 144:ef7eb2e8f9f7 | 601 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_SUSP)) |
<> | 144:ef7eb2e8f9f7 | 602 | { |
<> | 144:ef7eb2e8f9f7 | 603 | /* clear of the ISTR bit must be done after setting of CNTR_FSUSP */ |
<> | 144:ef7eb2e8f9f7 | 604 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_SUSP); |
<> | 144:ef7eb2e8f9f7 | 605 | |
<> | 144:ef7eb2e8f9f7 | 606 | /* Force low-power mode in the macrocell */ |
<> | 144:ef7eb2e8f9f7 | 607 | hpcd->Instance->CNTR |= USB_CNTR_FSUSP; |
<> | 144:ef7eb2e8f9f7 | 608 | hpcd->Instance->CNTR |= USB_CNTR_LPMODE; |
<> | 144:ef7eb2e8f9f7 | 609 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_WKUP) == 0) |
<> | 144:ef7eb2e8f9f7 | 610 | { |
<> | 144:ef7eb2e8f9f7 | 611 | HAL_PCD_SuspendCallback(hpcd); |
<> | 144:ef7eb2e8f9f7 | 612 | } |
<> | 144:ef7eb2e8f9f7 | 613 | } |
<> | 144:ef7eb2e8f9f7 | 614 | |
<> | 144:ef7eb2e8f9f7 | 615 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_SOF)) |
<> | 144:ef7eb2e8f9f7 | 616 | { |
<> | 144:ef7eb2e8f9f7 | 617 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_SOF); |
<> | 144:ef7eb2e8f9f7 | 618 | HAL_PCD_SOFCallback(hpcd); |
<> | 144:ef7eb2e8f9f7 | 619 | } |
<> | 144:ef7eb2e8f9f7 | 620 | |
<> | 144:ef7eb2e8f9f7 | 621 | if (__HAL_PCD_GET_FLAG (hpcd, USB_ISTR_ESOF)) |
<> | 144:ef7eb2e8f9f7 | 622 | { |
<> | 144:ef7eb2e8f9f7 | 623 | /* clear ESOF flag in ISTR */ |
<> | 144:ef7eb2e8f9f7 | 624 | __HAL_PCD_CLEAR_FLAG(hpcd, USB_ISTR_ESOF); |
<> | 144:ef7eb2e8f9f7 | 625 | } |
<> | 144:ef7eb2e8f9f7 | 626 | } |
<> | 144:ef7eb2e8f9f7 | 627 | |
<> | 144:ef7eb2e8f9f7 | 628 | /** |
<> | 144:ef7eb2e8f9f7 | 629 | * @brief Data out stage callbacks |
<> | 144:ef7eb2e8f9f7 | 630 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 631 | * @param epnum: endpoint number |
<> | 144:ef7eb2e8f9f7 | 632 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 633 | */ |
<> | 144:ef7eb2e8f9f7 | 634 | __weak void HAL_PCD_DataOutStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) |
<> | 144:ef7eb2e8f9f7 | 635 | { |
<> | 144:ef7eb2e8f9f7 | 636 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 637 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 638 | UNUSED(epnum); |
<> | 144:ef7eb2e8f9f7 | 639 | |
<> | 144:ef7eb2e8f9f7 | 640 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 641 | the HAL_PCD_DataOutStageCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 642 | */ |
<> | 144:ef7eb2e8f9f7 | 643 | } |
<> | 144:ef7eb2e8f9f7 | 644 | |
<> | 144:ef7eb2e8f9f7 | 645 | /** |
<> | 144:ef7eb2e8f9f7 | 646 | * @brief Data IN stage callbacks |
<> | 144:ef7eb2e8f9f7 | 647 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 648 | * @param epnum: endpoint number |
<> | 144:ef7eb2e8f9f7 | 649 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 650 | */ |
<> | 144:ef7eb2e8f9f7 | 651 | __weak void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) |
<> | 144:ef7eb2e8f9f7 | 652 | { |
<> | 144:ef7eb2e8f9f7 | 653 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 654 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 655 | UNUSED(epnum); |
<> | 144:ef7eb2e8f9f7 | 656 | |
<> | 144:ef7eb2e8f9f7 | 657 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 658 | the HAL_PCD_DataInStageCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 659 | */ |
<> | 144:ef7eb2e8f9f7 | 660 | } |
<> | 144:ef7eb2e8f9f7 | 661 | /** |
<> | 144:ef7eb2e8f9f7 | 662 | * @brief Setup stage callback |
<> | 144:ef7eb2e8f9f7 | 663 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 664 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 665 | */ |
<> | 144:ef7eb2e8f9f7 | 666 | __weak void HAL_PCD_SetupStageCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 667 | { |
<> | 144:ef7eb2e8f9f7 | 668 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 669 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 670 | |
<> | 144:ef7eb2e8f9f7 | 671 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 672 | the HAL_PCD_SetupStageCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 673 | */ |
<> | 144:ef7eb2e8f9f7 | 674 | } |
<> | 144:ef7eb2e8f9f7 | 675 | |
<> | 144:ef7eb2e8f9f7 | 676 | /** |
<> | 144:ef7eb2e8f9f7 | 677 | * @brief USB Start Of Frame callbacks |
<> | 144:ef7eb2e8f9f7 | 678 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 679 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 680 | */ |
<> | 144:ef7eb2e8f9f7 | 681 | __weak void HAL_PCD_SOFCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 682 | { |
<> | 144:ef7eb2e8f9f7 | 683 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 684 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 685 | |
<> | 144:ef7eb2e8f9f7 | 686 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 687 | the HAL_PCD_SOFCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 688 | */ |
<> | 144:ef7eb2e8f9f7 | 689 | } |
<> | 144:ef7eb2e8f9f7 | 690 | |
<> | 144:ef7eb2e8f9f7 | 691 | /** |
<> | 144:ef7eb2e8f9f7 | 692 | * @brief USB Reset callbacks |
<> | 144:ef7eb2e8f9f7 | 693 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 694 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 695 | */ |
<> | 144:ef7eb2e8f9f7 | 696 | __weak void HAL_PCD_ResetCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 697 | { |
<> | 144:ef7eb2e8f9f7 | 698 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 699 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 700 | |
<> | 144:ef7eb2e8f9f7 | 701 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 702 | the HAL_PCD_ResetCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 703 | */ |
<> | 144:ef7eb2e8f9f7 | 704 | } |
<> | 144:ef7eb2e8f9f7 | 705 | |
<> | 144:ef7eb2e8f9f7 | 706 | /** |
<> | 144:ef7eb2e8f9f7 | 707 | * @brief Suspend event callbacks |
<> | 144:ef7eb2e8f9f7 | 708 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 709 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 710 | */ |
<> | 144:ef7eb2e8f9f7 | 711 | __weak void HAL_PCD_SuspendCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 712 | { |
<> | 144:ef7eb2e8f9f7 | 713 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 714 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 715 | |
<> | 144:ef7eb2e8f9f7 | 716 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 717 | the HAL_PCD_SuspendCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 718 | */ |
<> | 144:ef7eb2e8f9f7 | 719 | } |
<> | 144:ef7eb2e8f9f7 | 720 | |
<> | 144:ef7eb2e8f9f7 | 721 | /** |
<> | 144:ef7eb2e8f9f7 | 722 | * @brief Resume event callbacks |
<> | 144:ef7eb2e8f9f7 | 723 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 724 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 725 | */ |
<> | 144:ef7eb2e8f9f7 | 726 | __weak void HAL_PCD_ResumeCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 727 | { |
<> | 144:ef7eb2e8f9f7 | 728 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 729 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 730 | |
<> | 144:ef7eb2e8f9f7 | 731 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 732 | the HAL_PCD_ResumeCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 733 | */ |
<> | 144:ef7eb2e8f9f7 | 734 | } |
<> | 144:ef7eb2e8f9f7 | 735 | |
<> | 144:ef7eb2e8f9f7 | 736 | /** |
<> | 144:ef7eb2e8f9f7 | 737 | * @brief Incomplete ISO OUT callbacks |
<> | 144:ef7eb2e8f9f7 | 738 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 739 | * @param epnum: endpoint number |
<> | 144:ef7eb2e8f9f7 | 740 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 741 | */ |
<> | 144:ef7eb2e8f9f7 | 742 | __weak void HAL_PCD_ISOOUTIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) |
<> | 144:ef7eb2e8f9f7 | 743 | { |
<> | 144:ef7eb2e8f9f7 | 744 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 745 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 746 | UNUSED(epnum); |
<> | 144:ef7eb2e8f9f7 | 747 | |
<> | 144:ef7eb2e8f9f7 | 748 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 749 | the HAL_PCD_ISOOUTIncompleteCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 750 | */ |
<> | 144:ef7eb2e8f9f7 | 751 | } |
<> | 144:ef7eb2e8f9f7 | 752 | |
<> | 144:ef7eb2e8f9f7 | 753 | /** |
<> | 144:ef7eb2e8f9f7 | 754 | * @brief Incomplete ISO IN callbacks |
<> | 144:ef7eb2e8f9f7 | 755 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 756 | * @param epnum: endpoint number |
<> | 144:ef7eb2e8f9f7 | 757 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 758 | */ |
<> | 144:ef7eb2e8f9f7 | 759 | __weak void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum) |
<> | 144:ef7eb2e8f9f7 | 760 | { |
<> | 144:ef7eb2e8f9f7 | 761 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 762 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 763 | UNUSED(epnum); |
<> | 144:ef7eb2e8f9f7 | 764 | |
<> | 144:ef7eb2e8f9f7 | 765 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 766 | the HAL_PCD_ISOINIncompleteCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 767 | */ |
<> | 144:ef7eb2e8f9f7 | 768 | } |
<> | 144:ef7eb2e8f9f7 | 769 | |
<> | 144:ef7eb2e8f9f7 | 770 | /** |
<> | 144:ef7eb2e8f9f7 | 771 | * @brief Connection event callbacks |
<> | 144:ef7eb2e8f9f7 | 772 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 773 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 774 | */ |
<> | 144:ef7eb2e8f9f7 | 775 | __weak void HAL_PCD_ConnectCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 776 | { |
<> | 144:ef7eb2e8f9f7 | 777 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 778 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 779 | |
<> | 144:ef7eb2e8f9f7 | 780 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 781 | the HAL_PCD_ConnectCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 782 | */ |
<> | 144:ef7eb2e8f9f7 | 783 | } |
<> | 144:ef7eb2e8f9f7 | 784 | |
<> | 144:ef7eb2e8f9f7 | 785 | /** |
<> | 144:ef7eb2e8f9f7 | 786 | * @brief Disconnection event callbacks |
<> | 144:ef7eb2e8f9f7 | 787 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 788 | * @retval None |
<> | 144:ef7eb2e8f9f7 | 789 | */ |
<> | 144:ef7eb2e8f9f7 | 790 | __weak void HAL_PCD_DisconnectCallback(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 791 | { |
<> | 144:ef7eb2e8f9f7 | 792 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 793 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 794 | |
<> | 144:ef7eb2e8f9f7 | 795 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 796 | the HAL_PCD_DisconnectCallback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 797 | */ |
<> | 144:ef7eb2e8f9f7 | 798 | } |
<> | 144:ef7eb2e8f9f7 | 799 | /** |
<> | 144:ef7eb2e8f9f7 | 800 | * @} |
<> | 144:ef7eb2e8f9f7 | 801 | */ |
<> | 144:ef7eb2e8f9f7 | 802 | |
<> | 144:ef7eb2e8f9f7 | 803 | /** @defgroup PCD_Exported_Functions_Group3 Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 804 | * @brief management functions |
<> | 144:ef7eb2e8f9f7 | 805 | * |
<> | 144:ef7eb2e8f9f7 | 806 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 807 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 808 | ##### Peripheral Control functions ##### |
<> | 144:ef7eb2e8f9f7 | 809 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 810 | [..] |
<> | 144:ef7eb2e8f9f7 | 811 | This subsection provides a set of functions allowing to control the PCD data |
<> | 144:ef7eb2e8f9f7 | 812 | transfers. |
<> | 144:ef7eb2e8f9f7 | 813 | |
<> | 144:ef7eb2e8f9f7 | 814 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 815 | * @{ |
<> | 144:ef7eb2e8f9f7 | 816 | */ |
<> | 144:ef7eb2e8f9f7 | 817 | |
<> | 144:ef7eb2e8f9f7 | 818 | /** |
<> | 144:ef7eb2e8f9f7 | 819 | * @brief Connect the USB device |
<> | 144:ef7eb2e8f9f7 | 820 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 821 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 822 | */ |
<> | 144:ef7eb2e8f9f7 | 823 | HAL_StatusTypeDef HAL_PCD_DevConnect(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 824 | { |
<> | 144:ef7eb2e8f9f7 | 825 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 826 | |
<> | 144:ef7eb2e8f9f7 | 827 | /* Enabling DP Pull-Down bit to Connect internal pull-up on USB DP line */ |
<> | 144:ef7eb2e8f9f7 | 828 | HAL_PCDEx_SetConnectionState(hpcd, 1); |
<> | 144:ef7eb2e8f9f7 | 829 | |
<> | 144:ef7eb2e8f9f7 | 830 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 831 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 832 | } |
<> | 144:ef7eb2e8f9f7 | 833 | |
<> | 144:ef7eb2e8f9f7 | 834 | /** |
<> | 144:ef7eb2e8f9f7 | 835 | * @brief Disconnect the USB device |
<> | 144:ef7eb2e8f9f7 | 836 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 837 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 838 | */ |
<> | 144:ef7eb2e8f9f7 | 839 | HAL_StatusTypeDef HAL_PCD_DevDisconnect(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 840 | { |
<> | 144:ef7eb2e8f9f7 | 841 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 842 | |
<> | 144:ef7eb2e8f9f7 | 843 | /* Disable DP Pull-Down bit*/ |
<> | 144:ef7eb2e8f9f7 | 844 | HAL_PCDEx_SetConnectionState(hpcd, 0); |
<> | 144:ef7eb2e8f9f7 | 845 | |
<> | 144:ef7eb2e8f9f7 | 846 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 847 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 848 | } |
<> | 144:ef7eb2e8f9f7 | 849 | |
<> | 144:ef7eb2e8f9f7 | 850 | /** |
<> | 144:ef7eb2e8f9f7 | 851 | * @brief Set the USB Device address |
<> | 144:ef7eb2e8f9f7 | 852 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 853 | * @param address: new device address |
<> | 144:ef7eb2e8f9f7 | 854 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 855 | */ |
<> | 144:ef7eb2e8f9f7 | 856 | HAL_StatusTypeDef HAL_PCD_SetAddress(PCD_HandleTypeDef *hpcd, uint8_t address) |
<> | 144:ef7eb2e8f9f7 | 857 | { |
<> | 144:ef7eb2e8f9f7 | 858 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 859 | |
<> | 144:ef7eb2e8f9f7 | 860 | if(address == 0) |
<> | 144:ef7eb2e8f9f7 | 861 | { |
<> | 144:ef7eb2e8f9f7 | 862 | /* set device address and enable function */ |
<> | 144:ef7eb2e8f9f7 | 863 | hpcd->Instance->DADDR = USB_DADDR_EF; |
<> | 144:ef7eb2e8f9f7 | 864 | } |
<> | 144:ef7eb2e8f9f7 | 865 | else /* USB Address will be applied later */ |
<> | 144:ef7eb2e8f9f7 | 866 | { |
<> | 144:ef7eb2e8f9f7 | 867 | hpcd->USB_Address = address; |
<> | 144:ef7eb2e8f9f7 | 868 | } |
<> | 144:ef7eb2e8f9f7 | 869 | |
<> | 144:ef7eb2e8f9f7 | 870 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 871 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 872 | } |
<> | 144:ef7eb2e8f9f7 | 873 | /** |
<> | 144:ef7eb2e8f9f7 | 874 | * @brief Open and configure an endpoint |
<> | 144:ef7eb2e8f9f7 | 875 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 876 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 877 | * @param ep_mps: endpoint max packet size |
<> | 144:ef7eb2e8f9f7 | 878 | * @param ep_type: endpoint type |
<> | 144:ef7eb2e8f9f7 | 879 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 880 | */ |
<> | 144:ef7eb2e8f9f7 | 881 | HAL_StatusTypeDef HAL_PCD_EP_Open(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint16_t ep_mps, uint8_t ep_type) |
<> | 144:ef7eb2e8f9f7 | 882 | { |
<> | 144:ef7eb2e8f9f7 | 883 | HAL_StatusTypeDef ret = HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 884 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 885 | |
<> | 144:ef7eb2e8f9f7 | 886 | if ((ep_addr & 0x80) == 0x80) |
<> | 144:ef7eb2e8f9f7 | 887 | { |
<> | 144:ef7eb2e8f9f7 | 888 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 889 | } |
<> | 144:ef7eb2e8f9f7 | 890 | else |
<> | 144:ef7eb2e8f9f7 | 891 | { |
<> | 144:ef7eb2e8f9f7 | 892 | ep = &hpcd->OUT_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 893 | } |
<> | 144:ef7eb2e8f9f7 | 894 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 895 | |
<> | 144:ef7eb2e8f9f7 | 896 | ep->is_in = (0x80 & ep_addr) != 0; |
<> | 144:ef7eb2e8f9f7 | 897 | ep->maxpacket = ep_mps; |
<> | 144:ef7eb2e8f9f7 | 898 | ep->type = ep_type; |
<> | 144:ef7eb2e8f9f7 | 899 | |
<> | 144:ef7eb2e8f9f7 | 900 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 901 | |
<> | 144:ef7eb2e8f9f7 | 902 | /* initialize Endpoint */ |
<> | 144:ef7eb2e8f9f7 | 903 | switch (ep->type) |
<> | 144:ef7eb2e8f9f7 | 904 | { |
<> | 144:ef7eb2e8f9f7 | 905 | case PCD_EP_TYPE_CTRL: |
<> | 144:ef7eb2e8f9f7 | 906 | PCD_SET_EPTYPE(hpcd->Instance, ep->num, USB_EP_CONTROL); |
<> | 144:ef7eb2e8f9f7 | 907 | break; |
<> | 144:ef7eb2e8f9f7 | 908 | case PCD_EP_TYPE_BULK: |
<> | 144:ef7eb2e8f9f7 | 909 | PCD_SET_EPTYPE(hpcd->Instance, ep->num, USB_EP_BULK); |
<> | 144:ef7eb2e8f9f7 | 910 | break; |
<> | 144:ef7eb2e8f9f7 | 911 | case PCD_EP_TYPE_INTR: |
<> | 144:ef7eb2e8f9f7 | 912 | PCD_SET_EPTYPE(hpcd->Instance, ep->num, USB_EP_INTERRUPT); |
<> | 144:ef7eb2e8f9f7 | 913 | break; |
<> | 144:ef7eb2e8f9f7 | 914 | case PCD_EP_TYPE_ISOC: |
<> | 144:ef7eb2e8f9f7 | 915 | PCD_SET_EPTYPE(hpcd->Instance, ep->num, USB_EP_ISOCHRONOUS); |
<> | 144:ef7eb2e8f9f7 | 916 | break; |
<> | 144:ef7eb2e8f9f7 | 917 | } |
<> | 144:ef7eb2e8f9f7 | 918 | |
<> | 144:ef7eb2e8f9f7 | 919 | PCD_SET_EP_ADDRESS(hpcd->Instance, ep->num, ep->num); |
<> | 144:ef7eb2e8f9f7 | 920 | |
<> | 144:ef7eb2e8f9f7 | 921 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 922 | { |
<> | 144:ef7eb2e8f9f7 | 923 | if (ep->is_in) |
<> | 144:ef7eb2e8f9f7 | 924 | { |
<> | 144:ef7eb2e8f9f7 | 925 | /*Set the endpoint Transmit buffer address */ |
<> | 144:ef7eb2e8f9f7 | 926 | PCD_SET_EP_TX_ADDRESS(hpcd->Instance, ep->num, ep->pmaadress); |
<> | 144:ef7eb2e8f9f7 | 927 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 928 | /* Configure NAK status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 929 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_NAK); |
<> | 144:ef7eb2e8f9f7 | 930 | } |
<> | 144:ef7eb2e8f9f7 | 931 | else |
<> | 144:ef7eb2e8f9f7 | 932 | { |
<> | 144:ef7eb2e8f9f7 | 933 | /*Set the endpoint Receive buffer address */ |
<> | 144:ef7eb2e8f9f7 | 934 | PCD_SET_EP_RX_ADDRESS(hpcd->Instance, ep->num, ep->pmaadress); |
<> | 144:ef7eb2e8f9f7 | 935 | /*Set the endpoint Receive buffer counter*/ |
<> | 144:ef7eb2e8f9f7 | 936 | PCD_SET_EP_RX_CNT(hpcd->Instance, ep->num, ep->maxpacket); |
<> | 144:ef7eb2e8f9f7 | 937 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 938 | /* Configure VALID status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 939 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_VALID); |
<> | 144:ef7eb2e8f9f7 | 940 | } |
<> | 144:ef7eb2e8f9f7 | 941 | } |
<> | 144:ef7eb2e8f9f7 | 942 | /*Double Buffer*/ |
<> | 144:ef7eb2e8f9f7 | 943 | else |
<> | 144:ef7eb2e8f9f7 | 944 | { |
<> | 144:ef7eb2e8f9f7 | 945 | /*Set the endpoint as double buffered*/ |
<> | 144:ef7eb2e8f9f7 | 946 | PCD_SET_EP_DBUF(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 947 | /*Set buffer address for double buffered mode*/ |
<> | 144:ef7eb2e8f9f7 | 948 | PCD_SET_EP_DBUF_ADDR(hpcd->Instance, ep->num,ep->pmaaddr0, ep->pmaaddr1); |
<> | 144:ef7eb2e8f9f7 | 949 | |
<> | 144:ef7eb2e8f9f7 | 950 | if (ep->is_in==0) |
<> | 144:ef7eb2e8f9f7 | 951 | { |
<> | 144:ef7eb2e8f9f7 | 952 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
<> | 144:ef7eb2e8f9f7 | 953 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 954 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 955 | |
<> | 144:ef7eb2e8f9f7 | 956 | /* Reset value of the data toggle bits for the endpoint out*/ |
<> | 144:ef7eb2e8f9f7 | 957 | PCD_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 958 | |
<> | 144:ef7eb2e8f9f7 | 959 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_VALID); |
<> | 144:ef7eb2e8f9f7 | 960 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_DIS); |
<> | 144:ef7eb2e8f9f7 | 961 | } |
<> | 144:ef7eb2e8f9f7 | 962 | else |
<> | 144:ef7eb2e8f9f7 | 963 | { |
<> | 144:ef7eb2e8f9f7 | 964 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
<> | 144:ef7eb2e8f9f7 | 965 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 966 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 967 | PCD_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 968 | /* Configure DISABLE status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 969 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_DIS); |
<> | 144:ef7eb2e8f9f7 | 970 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_DIS); |
<> | 144:ef7eb2e8f9f7 | 971 | } |
<> | 144:ef7eb2e8f9f7 | 972 | } |
<> | 144:ef7eb2e8f9f7 | 973 | |
<> | 144:ef7eb2e8f9f7 | 974 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 975 | return ret; |
<> | 144:ef7eb2e8f9f7 | 976 | } |
<> | 144:ef7eb2e8f9f7 | 977 | |
<> | 144:ef7eb2e8f9f7 | 978 | |
<> | 144:ef7eb2e8f9f7 | 979 | /** |
<> | 144:ef7eb2e8f9f7 | 980 | * @brief Deactivate an endpoint |
<> | 144:ef7eb2e8f9f7 | 981 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 982 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 983 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 984 | */ |
<> | 144:ef7eb2e8f9f7 | 985 | HAL_StatusTypeDef HAL_PCD_EP_Close(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) |
<> | 144:ef7eb2e8f9f7 | 986 | { |
<> | 144:ef7eb2e8f9f7 | 987 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 988 | |
<> | 144:ef7eb2e8f9f7 | 989 | if ((ep_addr & 0x80) == 0x80) |
<> | 144:ef7eb2e8f9f7 | 990 | { |
<> | 144:ef7eb2e8f9f7 | 991 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 992 | } |
<> | 144:ef7eb2e8f9f7 | 993 | else |
<> | 144:ef7eb2e8f9f7 | 994 | { |
<> | 144:ef7eb2e8f9f7 | 995 | ep = &hpcd->OUT_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 996 | } |
<> | 144:ef7eb2e8f9f7 | 997 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 998 | |
<> | 144:ef7eb2e8f9f7 | 999 | ep->is_in = (0x80 & ep_addr) != 0; |
<> | 144:ef7eb2e8f9f7 | 1000 | |
<> | 144:ef7eb2e8f9f7 | 1001 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1002 | |
<> | 144:ef7eb2e8f9f7 | 1003 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 1004 | { |
<> | 144:ef7eb2e8f9f7 | 1005 | if (ep->is_in) |
<> | 144:ef7eb2e8f9f7 | 1006 | { |
<> | 144:ef7eb2e8f9f7 | 1007 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1008 | /* Configure DISABLE status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 1009 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1010 | } |
<> | 144:ef7eb2e8f9f7 | 1011 | else |
<> | 144:ef7eb2e8f9f7 | 1012 | { |
<> | 144:ef7eb2e8f9f7 | 1013 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1014 | /* Configure DISABLE status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 1015 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1016 | } |
<> | 144:ef7eb2e8f9f7 | 1017 | } |
<> | 144:ef7eb2e8f9f7 | 1018 | /*Double Buffer*/ |
<> | 144:ef7eb2e8f9f7 | 1019 | else |
<> | 144:ef7eb2e8f9f7 | 1020 | { |
<> | 144:ef7eb2e8f9f7 | 1021 | if (ep->is_in==0) |
<> | 144:ef7eb2e8f9f7 | 1022 | { |
<> | 144:ef7eb2e8f9f7 | 1023 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
<> | 144:ef7eb2e8f9f7 | 1024 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1025 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1026 | |
<> | 144:ef7eb2e8f9f7 | 1027 | /* Reset value of the data toggle bits for the endpoint out*/ |
<> | 144:ef7eb2e8f9f7 | 1028 | PCD_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1029 | |
<> | 144:ef7eb2e8f9f7 | 1030 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1031 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1032 | } |
<> | 144:ef7eb2e8f9f7 | 1033 | else |
<> | 144:ef7eb2e8f9f7 | 1034 | { |
<> | 144:ef7eb2e8f9f7 | 1035 | /* Clear the data toggle bits for the endpoint IN/OUT*/ |
<> | 144:ef7eb2e8f9f7 | 1036 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1037 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1038 | PCD_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1039 | /* Configure DISABLE status for the Endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 1040 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1041 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_DIS); |
<> | 144:ef7eb2e8f9f7 | 1042 | } |
<> | 144:ef7eb2e8f9f7 | 1043 | } |
<> | 144:ef7eb2e8f9f7 | 1044 | |
<> | 144:ef7eb2e8f9f7 | 1045 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1046 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1047 | } |
<> | 144:ef7eb2e8f9f7 | 1048 | |
<> | 144:ef7eb2e8f9f7 | 1049 | |
<> | 144:ef7eb2e8f9f7 | 1050 | /** |
<> | 144:ef7eb2e8f9f7 | 1051 | * @brief Receive an amount of data |
<> | 144:ef7eb2e8f9f7 | 1052 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1053 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1054 | * @param pBuf: pointer to the reception buffer |
<> | 144:ef7eb2e8f9f7 | 1055 | * @param len: amount of data to be received |
<> | 144:ef7eb2e8f9f7 | 1056 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1057 | */ |
<> | 144:ef7eb2e8f9f7 | 1058 | HAL_StatusTypeDef HAL_PCD_EP_Receive(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len) |
<> | 144:ef7eb2e8f9f7 | 1059 | { |
<> | 144:ef7eb2e8f9f7 | 1060 | |
<> | 144:ef7eb2e8f9f7 | 1061 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 1062 | |
<> | 144:ef7eb2e8f9f7 | 1063 | ep = &hpcd->OUT_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 1064 | |
<> | 144:ef7eb2e8f9f7 | 1065 | /*setup and start the Xfer */ |
<> | 144:ef7eb2e8f9f7 | 1066 | ep->xfer_buff = pBuf; |
<> | 144:ef7eb2e8f9f7 | 1067 | ep->xfer_len = len; |
<> | 144:ef7eb2e8f9f7 | 1068 | ep->xfer_count = 0; |
<> | 144:ef7eb2e8f9f7 | 1069 | ep->is_in = 0; |
<> | 144:ef7eb2e8f9f7 | 1070 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 1071 | |
<> | 144:ef7eb2e8f9f7 | 1072 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1073 | |
<> | 144:ef7eb2e8f9f7 | 1074 | /* Multi packet transfer*/ |
<> | 144:ef7eb2e8f9f7 | 1075 | if (ep->xfer_len > ep->maxpacket) |
<> | 144:ef7eb2e8f9f7 | 1076 | { |
<> | 144:ef7eb2e8f9f7 | 1077 | len=ep->maxpacket; |
<> | 144:ef7eb2e8f9f7 | 1078 | ep->xfer_len-=len; |
<> | 144:ef7eb2e8f9f7 | 1079 | } |
<> | 144:ef7eb2e8f9f7 | 1080 | else |
<> | 144:ef7eb2e8f9f7 | 1081 | { |
<> | 144:ef7eb2e8f9f7 | 1082 | len=ep->xfer_len; |
<> | 144:ef7eb2e8f9f7 | 1083 | ep->xfer_len =0; |
<> | 144:ef7eb2e8f9f7 | 1084 | } |
<> | 144:ef7eb2e8f9f7 | 1085 | |
<> | 144:ef7eb2e8f9f7 | 1086 | /* configure and validate Rx endpoint */ |
<> | 144:ef7eb2e8f9f7 | 1087 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 1088 | { |
<> | 144:ef7eb2e8f9f7 | 1089 | /*Set RX buffer count*/ |
<> | 144:ef7eb2e8f9f7 | 1090 | PCD_SET_EP_RX_CNT(hpcd->Instance, ep->num, len); |
<> | 144:ef7eb2e8f9f7 | 1091 | } |
<> | 144:ef7eb2e8f9f7 | 1092 | else |
<> | 144:ef7eb2e8f9f7 | 1093 | { |
<> | 144:ef7eb2e8f9f7 | 1094 | /*Set the Double buffer counter*/ |
<> | 144:ef7eb2e8f9f7 | 1095 | PCD_SET_EP_DBUF1_CNT(hpcd->Instance, ep->num, ep->is_in, len); |
<> | 144:ef7eb2e8f9f7 | 1096 | } |
<> | 144:ef7eb2e8f9f7 | 1097 | |
<> | 144:ef7eb2e8f9f7 | 1098 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_VALID); |
<> | 144:ef7eb2e8f9f7 | 1099 | |
<> | 144:ef7eb2e8f9f7 | 1100 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1101 | |
<> | 144:ef7eb2e8f9f7 | 1102 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1103 | } |
<> | 144:ef7eb2e8f9f7 | 1104 | |
<> | 144:ef7eb2e8f9f7 | 1105 | /** |
<> | 144:ef7eb2e8f9f7 | 1106 | * @brief Get Received Data Size |
<> | 144:ef7eb2e8f9f7 | 1107 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1108 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1109 | * @retval Data Size |
<> | 144:ef7eb2e8f9f7 | 1110 | */ |
<> | 144:ef7eb2e8f9f7 | 1111 | uint16_t HAL_PCD_EP_GetRxCount(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) |
<> | 144:ef7eb2e8f9f7 | 1112 | { |
<> | 144:ef7eb2e8f9f7 | 1113 | return hpcd->OUT_ep[ep_addr & 0x7F].xfer_count; |
<> | 144:ef7eb2e8f9f7 | 1114 | } |
<> | 144:ef7eb2e8f9f7 | 1115 | /** |
<> | 144:ef7eb2e8f9f7 | 1116 | * @brief Send an amount of data |
<> | 144:ef7eb2e8f9f7 | 1117 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1118 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1119 | * @param pBuf: pointer to the transmission buffer |
<> | 144:ef7eb2e8f9f7 | 1120 | * @param len: amount of data to be sent |
<> | 144:ef7eb2e8f9f7 | 1121 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1122 | */ |
<> | 144:ef7eb2e8f9f7 | 1123 | HAL_StatusTypeDef HAL_PCD_EP_Transmit(PCD_HandleTypeDef *hpcd, uint8_t ep_addr, uint8_t *pBuf, uint32_t len) |
<> | 144:ef7eb2e8f9f7 | 1124 | { |
<> | 144:ef7eb2e8f9f7 | 1125 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 1126 | uint16_t pmabuffer = 0; |
<> | 144:ef7eb2e8f9f7 | 1127 | |
<> | 144:ef7eb2e8f9f7 | 1128 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 1129 | |
<> | 144:ef7eb2e8f9f7 | 1130 | /*setup and start the Xfer */ |
<> | 144:ef7eb2e8f9f7 | 1131 | ep->xfer_buff = pBuf; |
<> | 144:ef7eb2e8f9f7 | 1132 | ep->xfer_len = len; |
<> | 144:ef7eb2e8f9f7 | 1133 | ep->xfer_count = 0; |
<> | 144:ef7eb2e8f9f7 | 1134 | ep->is_in = 1; |
<> | 144:ef7eb2e8f9f7 | 1135 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 1136 | |
<> | 144:ef7eb2e8f9f7 | 1137 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1138 | |
<> | 144:ef7eb2e8f9f7 | 1139 | /*Multi packet transfer*/ |
<> | 144:ef7eb2e8f9f7 | 1140 | if (ep->xfer_len > ep->maxpacket) |
<> | 144:ef7eb2e8f9f7 | 1141 | { |
<> | 144:ef7eb2e8f9f7 | 1142 | len=ep->maxpacket; |
<> | 144:ef7eb2e8f9f7 | 1143 | ep->xfer_len-=len; |
<> | 144:ef7eb2e8f9f7 | 1144 | } |
<> | 144:ef7eb2e8f9f7 | 1145 | else |
<> | 144:ef7eb2e8f9f7 | 1146 | { |
<> | 144:ef7eb2e8f9f7 | 1147 | len=ep->xfer_len; |
<> | 144:ef7eb2e8f9f7 | 1148 | ep->xfer_len =0; |
<> | 144:ef7eb2e8f9f7 | 1149 | } |
<> | 144:ef7eb2e8f9f7 | 1150 | |
<> | 144:ef7eb2e8f9f7 | 1151 | /* configure and validate Tx endpoint */ |
<> | 144:ef7eb2e8f9f7 | 1152 | if (ep->doublebuffer == 0) |
<> | 144:ef7eb2e8f9f7 | 1153 | { |
<> | 144:ef7eb2e8f9f7 | 1154 | PCD_WritePMA(hpcd->Instance, ep->xfer_buff, ep->pmaadress, len); |
<> | 144:ef7eb2e8f9f7 | 1155 | PCD_SET_EP_TX_CNT(hpcd->Instance, ep->num, len); |
<> | 144:ef7eb2e8f9f7 | 1156 | } |
<> | 144:ef7eb2e8f9f7 | 1157 | else |
<> | 144:ef7eb2e8f9f7 | 1158 | { |
<> | 144:ef7eb2e8f9f7 | 1159 | /*Write the data to the USB endpoint*/ |
<> | 144:ef7eb2e8f9f7 | 1160 | if (PCD_GET_ENDPOINT(hpcd->Instance, ep->num)& USB_EP_DTOG_TX) |
<> | 144:ef7eb2e8f9f7 | 1161 | { |
<> | 144:ef7eb2e8f9f7 | 1162 | pmabuffer = ep->pmaaddr1; |
<> | 144:ef7eb2e8f9f7 | 1163 | } |
<> | 144:ef7eb2e8f9f7 | 1164 | else |
<> | 144:ef7eb2e8f9f7 | 1165 | { |
<> | 144:ef7eb2e8f9f7 | 1166 | pmabuffer = ep->pmaaddr0; |
<> | 144:ef7eb2e8f9f7 | 1167 | } |
<> | 144:ef7eb2e8f9f7 | 1168 | PCD_WritePMA(hpcd->Instance, ep->xfer_buff, pmabuffer, len); |
<> | 144:ef7eb2e8f9f7 | 1169 | PCD_FreeUserBuffer(hpcd->Instance, ep->num, ep->is_in); |
<> | 144:ef7eb2e8f9f7 | 1170 | } |
<> | 144:ef7eb2e8f9f7 | 1171 | |
<> | 144:ef7eb2e8f9f7 | 1172 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_VALID); |
<> | 144:ef7eb2e8f9f7 | 1173 | |
<> | 144:ef7eb2e8f9f7 | 1174 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1175 | |
<> | 144:ef7eb2e8f9f7 | 1176 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1177 | } |
<> | 144:ef7eb2e8f9f7 | 1178 | |
<> | 144:ef7eb2e8f9f7 | 1179 | /** |
<> | 144:ef7eb2e8f9f7 | 1180 | * @brief Set a STALL condition over an endpoint |
<> | 144:ef7eb2e8f9f7 | 1181 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1182 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1183 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1184 | */ |
<> | 144:ef7eb2e8f9f7 | 1185 | HAL_StatusTypeDef HAL_PCD_EP_SetStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) |
<> | 144:ef7eb2e8f9f7 | 1186 | { |
<> | 144:ef7eb2e8f9f7 | 1187 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 1188 | |
<> | 144:ef7eb2e8f9f7 | 1189 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1190 | |
<> | 144:ef7eb2e8f9f7 | 1191 | if ((0x80 & ep_addr) == 0x80) |
<> | 144:ef7eb2e8f9f7 | 1192 | { |
<> | 144:ef7eb2e8f9f7 | 1193 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 1194 | } |
<> | 144:ef7eb2e8f9f7 | 1195 | else |
<> | 144:ef7eb2e8f9f7 | 1196 | { |
<> | 144:ef7eb2e8f9f7 | 1197 | ep = &hpcd->OUT_ep[ep_addr]; |
<> | 144:ef7eb2e8f9f7 | 1198 | } |
<> | 144:ef7eb2e8f9f7 | 1199 | |
<> | 144:ef7eb2e8f9f7 | 1200 | ep->is_stall = 1; |
<> | 144:ef7eb2e8f9f7 | 1201 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 1202 | ep->is_in = ((ep_addr & 0x80) == 0x80); |
<> | 144:ef7eb2e8f9f7 | 1203 | |
<> | 144:ef7eb2e8f9f7 | 1204 | if (ep->num == 0) |
<> | 144:ef7eb2e8f9f7 | 1205 | { |
<> | 144:ef7eb2e8f9f7 | 1206 | /* This macro sets STALL status for RX & TX*/ |
<> | 144:ef7eb2e8f9f7 | 1207 | PCD_SET_EP_TXRX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_STALL, USB_EP_TX_STALL); |
<> | 144:ef7eb2e8f9f7 | 1208 | } |
<> | 144:ef7eb2e8f9f7 | 1209 | else |
<> | 144:ef7eb2e8f9f7 | 1210 | { |
<> | 144:ef7eb2e8f9f7 | 1211 | if (ep->is_in) |
<> | 144:ef7eb2e8f9f7 | 1212 | { |
<> | 144:ef7eb2e8f9f7 | 1213 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num , USB_EP_TX_STALL); |
<> | 144:ef7eb2e8f9f7 | 1214 | } |
<> | 144:ef7eb2e8f9f7 | 1215 | else |
<> | 144:ef7eb2e8f9f7 | 1216 | { |
<> | 144:ef7eb2e8f9f7 | 1217 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num , USB_EP_RX_STALL); |
<> | 144:ef7eb2e8f9f7 | 1218 | } |
<> | 144:ef7eb2e8f9f7 | 1219 | } |
<> | 144:ef7eb2e8f9f7 | 1220 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1221 | |
<> | 144:ef7eb2e8f9f7 | 1222 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1223 | } |
<> | 144:ef7eb2e8f9f7 | 1224 | |
<> | 144:ef7eb2e8f9f7 | 1225 | /** |
<> | 144:ef7eb2e8f9f7 | 1226 | * @brief Clear a STALL condition over in an endpoint |
<> | 144:ef7eb2e8f9f7 | 1227 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1228 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1229 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1230 | */ |
<> | 144:ef7eb2e8f9f7 | 1231 | HAL_StatusTypeDef HAL_PCD_EP_ClrStall(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) |
<> | 144:ef7eb2e8f9f7 | 1232 | { |
<> | 144:ef7eb2e8f9f7 | 1233 | PCD_EPTypeDef *ep; |
<> | 144:ef7eb2e8f9f7 | 1234 | |
<> | 144:ef7eb2e8f9f7 | 1235 | if ((0x80 & ep_addr) == 0x80) |
<> | 144:ef7eb2e8f9f7 | 1236 | { |
<> | 144:ef7eb2e8f9f7 | 1237 | ep = &hpcd->IN_ep[ep_addr & 0x7F]; |
<> | 144:ef7eb2e8f9f7 | 1238 | } |
<> | 144:ef7eb2e8f9f7 | 1239 | else |
<> | 144:ef7eb2e8f9f7 | 1240 | { |
<> | 144:ef7eb2e8f9f7 | 1241 | ep = &hpcd->OUT_ep[ep_addr]; |
<> | 144:ef7eb2e8f9f7 | 1242 | } |
<> | 144:ef7eb2e8f9f7 | 1243 | |
<> | 144:ef7eb2e8f9f7 | 1244 | ep->is_stall = 0; |
<> | 144:ef7eb2e8f9f7 | 1245 | ep->num = ep_addr & 0x7F; |
<> | 144:ef7eb2e8f9f7 | 1246 | ep->is_in = ((ep_addr & 0x80) == 0x80); |
<> | 144:ef7eb2e8f9f7 | 1247 | |
<> | 144:ef7eb2e8f9f7 | 1248 | __HAL_LOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1249 | |
<> | 144:ef7eb2e8f9f7 | 1250 | if (ep->is_in) |
<> | 144:ef7eb2e8f9f7 | 1251 | { |
<> | 144:ef7eb2e8f9f7 | 1252 | PCD_CLEAR_TX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1253 | PCD_SET_EP_TX_STATUS(hpcd->Instance, ep->num, USB_EP_TX_VALID); |
<> | 144:ef7eb2e8f9f7 | 1254 | } |
<> | 144:ef7eb2e8f9f7 | 1255 | else |
<> | 144:ef7eb2e8f9f7 | 1256 | { |
<> | 144:ef7eb2e8f9f7 | 1257 | PCD_CLEAR_RX_DTOG(hpcd->Instance, ep->num); |
<> | 144:ef7eb2e8f9f7 | 1258 | PCD_SET_EP_RX_STATUS(hpcd->Instance, ep->num, USB_EP_RX_VALID); |
<> | 144:ef7eb2e8f9f7 | 1259 | } |
<> | 144:ef7eb2e8f9f7 | 1260 | __HAL_UNLOCK(hpcd); |
<> | 144:ef7eb2e8f9f7 | 1261 | |
<> | 144:ef7eb2e8f9f7 | 1262 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1263 | } |
<> | 144:ef7eb2e8f9f7 | 1264 | |
<> | 144:ef7eb2e8f9f7 | 1265 | /** |
<> | 144:ef7eb2e8f9f7 | 1266 | * @brief Flush an endpoint |
<> | 144:ef7eb2e8f9f7 | 1267 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1268 | * @param ep_addr: endpoint address |
<> | 144:ef7eb2e8f9f7 | 1269 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1270 | */ |
<> | 144:ef7eb2e8f9f7 | 1271 | HAL_StatusTypeDef HAL_PCD_EP_Flush(PCD_HandleTypeDef *hpcd, uint8_t ep_addr) |
<> | 144:ef7eb2e8f9f7 | 1272 | { |
<> | 144:ef7eb2e8f9f7 | 1273 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1274 | } |
<> | 144:ef7eb2e8f9f7 | 1275 | |
<> | 144:ef7eb2e8f9f7 | 1276 | /** |
<> | 144:ef7eb2e8f9f7 | 1277 | * @brief HAL_PCD_ActivateRemoteWakeup : active remote wakeup signalling |
<> | 144:ef7eb2e8f9f7 | 1278 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1279 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1280 | */ |
<> | 144:ef7eb2e8f9f7 | 1281 | HAL_StatusTypeDef HAL_PCD_ActivateRemoteWakeup(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 1282 | { |
<> | 144:ef7eb2e8f9f7 | 1283 | hpcd->Instance->CNTR |= USB_CNTR_RESUME; |
<> | 144:ef7eb2e8f9f7 | 1284 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1285 | } |
<> | 144:ef7eb2e8f9f7 | 1286 | |
<> | 144:ef7eb2e8f9f7 | 1287 | /** |
<> | 144:ef7eb2e8f9f7 | 1288 | * @brief HAL_PCD_DeActivateRemoteWakeup : de-active remote wakeup signalling |
<> | 144:ef7eb2e8f9f7 | 1289 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 1290 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 1291 | */ |
<> | 144:ef7eb2e8f9f7 | 1292 | HAL_StatusTypeDef HAL_PCD_DeActivateRemoteWakeup(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 1293 | { |
<> | 144:ef7eb2e8f9f7 | 1294 | hpcd->Instance->CNTR &= ~(USB_CNTR_RESUME); |
<> | 144:ef7eb2e8f9f7 | 1295 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 1296 | } |
<> | 144:ef7eb2e8f9f7 | 1297 | |
<> | 144:ef7eb2e8f9f7 | 1298 | /** |
<> | 144:ef7eb2e8f9f7 | 1299 | * @} |
<> | 144:ef7eb2e8f9f7 | 1300 | */ |
<> | 144:ef7eb2e8f9f7 | 1301 | |
<> | 144:ef7eb2e8f9f7 | 1302 | /** @defgroup PCD_Exported_Functions_Group4 Peripheral State functions |
<> | 144:ef7eb2e8f9f7 | 1303 | * @brief Peripheral State functions |
<> | 144:ef7eb2e8f9f7 | 1304 | * |
<> | 144:ef7eb2e8f9f7 | 1305 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 1306 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 1307 | ##### Peripheral State functions ##### |
<> | 144:ef7eb2e8f9f7 | 1308 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 1309 | [..] |
<> | 144:ef7eb2e8f9f7 | 1310 | This subsection permits to get in run-time the status of the peripheral |
<> | 144:ef7eb2e8f9f7 | 1311 | and the data flow. |
<> | 144:ef7eb2e8f9f7 | 1312 | |
<> | 144:ef7eb2e8f9f7 | 1313 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 1314 | * @{ |
<> | 144:ef7eb2e8f9f7 | 1315 | */ |
<> | 144:ef7eb2e8f9f7 | 1316 | |
<> | 144:ef7eb2e8f9f7 | 1317 | /** |
<> | 144:ef7eb2e8f9f7 | 1318 | * @brief Return the PCD state |
<> | 144:ef7eb2e8f9f7 | 1319 | * @param hpcd : PCD handle |
<> | 144:ef7eb2e8f9f7 | 1320 | * @retval HAL state |
<> | 144:ef7eb2e8f9f7 | 1321 | */ |
<> | 144:ef7eb2e8f9f7 | 1322 | PCD_StateTypeDef HAL_PCD_GetState(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 1323 | { |
<> | 144:ef7eb2e8f9f7 | 1324 | return hpcd->State; |
<> | 144:ef7eb2e8f9f7 | 1325 | } |
<> | 144:ef7eb2e8f9f7 | 1326 | /** |
<> | 144:ef7eb2e8f9f7 | 1327 | * @} |
<> | 144:ef7eb2e8f9f7 | 1328 | */ |
<> | 144:ef7eb2e8f9f7 | 1329 | |
<> | 144:ef7eb2e8f9f7 | 1330 | |
<> | 144:ef7eb2e8f9f7 | 1331 | /** |
<> | 144:ef7eb2e8f9f7 | 1332 | * @} |
<> | 144:ef7eb2e8f9f7 | 1333 | */ |
<> | 144:ef7eb2e8f9f7 | 1334 | |
<> | 144:ef7eb2e8f9f7 | 1335 | /** |
<> | 144:ef7eb2e8f9f7 | 1336 | * @} |
<> | 144:ef7eb2e8f9f7 | 1337 | */ |
<> | 144:ef7eb2e8f9f7 | 1338 | |
<> | 144:ef7eb2e8f9f7 | 1339 | /** |
<> | 144:ef7eb2e8f9f7 | 1340 | * @} |
<> | 144:ef7eb2e8f9f7 | 1341 | */ |
<> | 144:ef7eb2e8f9f7 | 1342 | |
<> | 144:ef7eb2e8f9f7 | 1343 | #endif /* STM32F302xE || STM32F303xE || */ |
<> | 144:ef7eb2e8f9f7 | 1344 | /* STM32F302xC || STM32F303xC || */ |
<> | 144:ef7eb2e8f9f7 | 1345 | /* STM32F302x8 || */ |
<> | 144:ef7eb2e8f9f7 | 1346 | /* STM32F373xC */ |
<> | 144:ef7eb2e8f9f7 | 1347 | |
<> | 144:ef7eb2e8f9f7 | 1348 | #endif /* HAL_PCD_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 1349 | |
<> | 144:ef7eb2e8f9f7 | 1350 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |