mbed library sources. Supersedes mbed-src.
Dependents: Nucleo_Hello_Encoder BLE_iBeaconScan AM1805_DEMO DISCO-F429ZI_ExportTemplate1 ... more
targets/TARGET_STM/TARGET_STM32F7/device/stm32f7xx_hal_pcd_ex.c@165:e614a9f1c9e2, 2017-05-26 (annotated)
- Committer:
- AnnaBridge
- Date:
- Fri May 26 12:39:01 2017 +0100
- Revision:
- 165:e614a9f1c9e2
- Parent:
- 161:2cc1468da177
- Child:
- 168:9672193075cf
This updates the lib to the mbed lib v 143
Who changed what in which revision?
User | Revision | Line number | New contents of line |
---|---|---|---|
<> | 144:ef7eb2e8f9f7 | 1 | /** |
<> | 144:ef7eb2e8f9f7 | 2 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 3 | * @file stm32f7xx_hal_pcd_ex.c |
<> | 144:ef7eb2e8f9f7 | 4 | * @author MCD Application Team |
<> | 161:2cc1468da177 | 5 | * @version V1.2.0 |
<> | 161:2cc1468da177 | 6 | * @date 30-December-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 | * + Extended features functions |
<> | 144:ef7eb2e8f9f7 | 11 | * |
<> | 144:ef7eb2e8f9f7 | 12 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 13 | * @attention |
<> | 144:ef7eb2e8f9f7 | 14 | * |
<> | 144:ef7eb2e8f9f7 | 15 | * <h2><center>© COPYRIGHT(c) 2016 STMicroelectronics</center></h2> |
<> | 144:ef7eb2e8f9f7 | 16 | * |
<> | 144:ef7eb2e8f9f7 | 17 | * Redistribution and use in source and binary forms, with or without modification, |
<> | 144:ef7eb2e8f9f7 | 18 | * are permitted provided that the following conditions are met: |
<> | 144:ef7eb2e8f9f7 | 19 | * 1. Redistributions of source code must retain the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 20 | * this list of conditions and the following disclaimer. |
<> | 144:ef7eb2e8f9f7 | 21 | * 2. Redistributions in binary form must reproduce the above copyright notice, |
<> | 144:ef7eb2e8f9f7 | 22 | * this list of conditions and the following disclaimer in the documentation |
<> | 144:ef7eb2e8f9f7 | 23 | * and/or other materials provided with the distribution. |
<> | 144:ef7eb2e8f9f7 | 24 | * 3. Neither the name of STMicroelectronics nor the names of its contributors |
<> | 144:ef7eb2e8f9f7 | 25 | * may be used to endorse or promote products derived from this software |
<> | 144:ef7eb2e8f9f7 | 26 | * without specific prior written permission. |
<> | 144:ef7eb2e8f9f7 | 27 | * |
<> | 144:ef7eb2e8f9f7 | 28 | * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" |
<> | 144:ef7eb2e8f9f7 | 29 | * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE |
<> | 144:ef7eb2e8f9f7 | 30 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE |
<> | 144:ef7eb2e8f9f7 | 31 | * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE |
<> | 144:ef7eb2e8f9f7 | 32 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL |
<> | 144:ef7eb2e8f9f7 | 33 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR |
<> | 144:ef7eb2e8f9f7 | 34 | * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER |
<> | 144:ef7eb2e8f9f7 | 35 | * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, |
<> | 144:ef7eb2e8f9f7 | 36 | * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE |
<> | 144:ef7eb2e8f9f7 | 37 | * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. |
<> | 144:ef7eb2e8f9f7 | 38 | * |
<> | 144:ef7eb2e8f9f7 | 39 | ****************************************************************************** |
<> | 144:ef7eb2e8f9f7 | 40 | */ |
<> | 144:ef7eb2e8f9f7 | 41 | |
<> | 144:ef7eb2e8f9f7 | 42 | /* Includes ------------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 43 | #include "stm32f7xx_hal.h" |
<> | 144:ef7eb2e8f9f7 | 44 | |
<> | 144:ef7eb2e8f9f7 | 45 | /** @addtogroup STM32F7xx_HAL_Driver |
<> | 144:ef7eb2e8f9f7 | 46 | * @{ |
<> | 144:ef7eb2e8f9f7 | 47 | */ |
<> | 144:ef7eb2e8f9f7 | 48 | |
<> | 144:ef7eb2e8f9f7 | 49 | /** @defgroup PCDEx PCDEx |
<> | 144:ef7eb2e8f9f7 | 50 | * @brief PCD Extended HAL module driver |
<> | 144:ef7eb2e8f9f7 | 51 | * @{ |
<> | 144:ef7eb2e8f9f7 | 52 | */ |
<> | 144:ef7eb2e8f9f7 | 53 | #ifdef HAL_PCD_MODULE_ENABLED |
<> | 144:ef7eb2e8f9f7 | 54 | |
<> | 144:ef7eb2e8f9f7 | 55 | /* Private types -------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 56 | /* Private variables ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 57 | /* Private constants ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 58 | /* Private macros ------------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 59 | /* Private functions ---------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 60 | /* Exported functions --------------------------------------------------------*/ |
<> | 144:ef7eb2e8f9f7 | 61 | |
<> | 144:ef7eb2e8f9f7 | 62 | /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions |
<> | 144:ef7eb2e8f9f7 | 63 | * @{ |
<> | 144:ef7eb2e8f9f7 | 64 | */ |
<> | 144:ef7eb2e8f9f7 | 65 | |
<> | 144:ef7eb2e8f9f7 | 66 | /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions |
<> | 144:ef7eb2e8f9f7 | 67 | * @brief PCDEx control functions |
<> | 144:ef7eb2e8f9f7 | 68 | * |
<> | 144:ef7eb2e8f9f7 | 69 | @verbatim |
<> | 144:ef7eb2e8f9f7 | 70 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 71 | ##### Extended features functions ##### |
<> | 144:ef7eb2e8f9f7 | 72 | =============================================================================== |
<> | 144:ef7eb2e8f9f7 | 73 | [..] This section provides functions allowing to: |
<> | 144:ef7eb2e8f9f7 | 74 | (+) Update FIFO configuration |
<> | 144:ef7eb2e8f9f7 | 75 | |
<> | 144:ef7eb2e8f9f7 | 76 | @endverbatim |
<> | 144:ef7eb2e8f9f7 | 77 | * @{ |
<> | 144:ef7eb2e8f9f7 | 78 | */ |
<> | 144:ef7eb2e8f9f7 | 79 | |
<> | 144:ef7eb2e8f9f7 | 80 | /** |
<> | 144:ef7eb2e8f9f7 | 81 | * @brief Set Tx FIFO |
<> | 144:ef7eb2e8f9f7 | 82 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 83 | * @param fifo: The number of Tx fifo |
<> | 144:ef7eb2e8f9f7 | 84 | * @param size: Fifo size |
<> | 144:ef7eb2e8f9f7 | 85 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 86 | */ |
<> | 144:ef7eb2e8f9f7 | 87 | HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size) |
<> | 144:ef7eb2e8f9f7 | 88 | { |
<> | 144:ef7eb2e8f9f7 | 89 | uint8_t i = 0; |
<> | 144:ef7eb2e8f9f7 | 90 | uint32_t Tx_Offset = 0; |
<> | 144:ef7eb2e8f9f7 | 91 | |
<> | 144:ef7eb2e8f9f7 | 92 | /* TXn min size = 16 words. (n : Transmit FIFO index) |
<> | 144:ef7eb2e8f9f7 | 93 | When a TxFIFO is not used, the Configuration should be as follows: |
<> | 144:ef7eb2e8f9f7 | 94 | case 1 : n > m and Txn is not used (n,m : Transmit FIFO indexes) |
<> | 144:ef7eb2e8f9f7 | 95 | --> Txm can use the space allocated for Txn. |
<> | 144:ef7eb2e8f9f7 | 96 | case2 : n < m and Txn is not used (n,m : Transmit FIFO indexes) |
<> | 144:ef7eb2e8f9f7 | 97 | --> Txn should be configured with the minimum space of 16 words |
<> | 144:ef7eb2e8f9f7 | 98 | The FIFO is used optimally when used TxFIFOs are allocated in the top |
<> | 144:ef7eb2e8f9f7 | 99 | of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones. |
<> | 144:ef7eb2e8f9f7 | 100 | When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */ |
<> | 144:ef7eb2e8f9f7 | 101 | |
<> | 144:ef7eb2e8f9f7 | 102 | Tx_Offset = hpcd->Instance->GRXFSIZ; |
<> | 144:ef7eb2e8f9f7 | 103 | |
<> | 144:ef7eb2e8f9f7 | 104 | if(fifo == 0) |
<> | 144:ef7eb2e8f9f7 | 105 | { |
<> | 144:ef7eb2e8f9f7 | 106 | hpcd->Instance->DIEPTXF0_HNPTXFSIZ = (uint32_t)(((uint32_t)size << 16) | Tx_Offset); |
<> | 144:ef7eb2e8f9f7 | 107 | } |
<> | 144:ef7eb2e8f9f7 | 108 | else |
<> | 144:ef7eb2e8f9f7 | 109 | { |
<> | 144:ef7eb2e8f9f7 | 110 | Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16; |
<> | 144:ef7eb2e8f9f7 | 111 | for (i = 0; i < (fifo - 1); i++) |
<> | 144:ef7eb2e8f9f7 | 112 | { |
<> | 144:ef7eb2e8f9f7 | 113 | Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16); |
<> | 144:ef7eb2e8f9f7 | 114 | } |
<> | 144:ef7eb2e8f9f7 | 115 | |
<> | 144:ef7eb2e8f9f7 | 116 | /* Multiply Tx_Size by 2 to get higher performance */ |
<> | 144:ef7eb2e8f9f7 | 117 | hpcd->Instance->DIEPTXF[fifo - 1] = (uint32_t)(((uint32_t)size << 16) | Tx_Offset); |
<> | 144:ef7eb2e8f9f7 | 118 | } |
<> | 144:ef7eb2e8f9f7 | 119 | |
<> | 144:ef7eb2e8f9f7 | 120 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 121 | } |
<> | 144:ef7eb2e8f9f7 | 122 | |
<> | 144:ef7eb2e8f9f7 | 123 | /** |
<> | 144:ef7eb2e8f9f7 | 124 | * @brief Set Rx FIFO |
<> | 144:ef7eb2e8f9f7 | 125 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 126 | * @param size: Size of Rx fifo |
<> | 144:ef7eb2e8f9f7 | 127 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 128 | */ |
<> | 144:ef7eb2e8f9f7 | 129 | HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size) |
<> | 144:ef7eb2e8f9f7 | 130 | { |
<> | 144:ef7eb2e8f9f7 | 131 | hpcd->Instance->GRXFSIZ = size; |
<> | 144:ef7eb2e8f9f7 | 132 | |
<> | 144:ef7eb2e8f9f7 | 133 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 134 | } |
<> | 144:ef7eb2e8f9f7 | 135 | |
<> | 144:ef7eb2e8f9f7 | 136 | /** |
<> | 144:ef7eb2e8f9f7 | 137 | * @brief Activate LPM Feature |
<> | 144:ef7eb2e8f9f7 | 138 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 139 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 140 | */ |
<> | 144:ef7eb2e8f9f7 | 141 | HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 142 | { |
<> | 144:ef7eb2e8f9f7 | 143 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; |
<> | 144:ef7eb2e8f9f7 | 144 | |
<> | 144:ef7eb2e8f9f7 | 145 | hpcd->lpm_active = ENABLE; |
<> | 144:ef7eb2e8f9f7 | 146 | hpcd->LPM_State = LPM_L0; |
<> | 144:ef7eb2e8f9f7 | 147 | USBx->GINTMSK |= USB_OTG_GINTMSK_LPMINTM; |
<> | 144:ef7eb2e8f9f7 | 148 | USBx->GLPMCFG |= (USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL); |
<> | 144:ef7eb2e8f9f7 | 149 | |
<> | 144:ef7eb2e8f9f7 | 150 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 151 | } |
<> | 144:ef7eb2e8f9f7 | 152 | |
<> | 144:ef7eb2e8f9f7 | 153 | /** |
<> | 144:ef7eb2e8f9f7 | 154 | * @brief DeActivate LPM feature. |
<> | 144:ef7eb2e8f9f7 | 155 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 156 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 157 | */ |
<> | 144:ef7eb2e8f9f7 | 158 | HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd) |
<> | 144:ef7eb2e8f9f7 | 159 | { |
<> | 144:ef7eb2e8f9f7 | 160 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; |
<> | 144:ef7eb2e8f9f7 | 161 | |
<> | 144:ef7eb2e8f9f7 | 162 | hpcd->lpm_active = DISABLE; |
<> | 144:ef7eb2e8f9f7 | 163 | USBx->GINTMSK &= ~USB_OTG_GINTMSK_LPMINTM; |
<> | 144:ef7eb2e8f9f7 | 164 | USBx->GLPMCFG &= ~(USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL); |
<> | 144:ef7eb2e8f9f7 | 165 | |
<> | 144:ef7eb2e8f9f7 | 166 | return HAL_OK; |
<> | 144:ef7eb2e8f9f7 | 167 | } |
<> | 144:ef7eb2e8f9f7 | 168 | |
<> | 161:2cc1468da177 | 169 | #if defined (USB_OTG_GCCFG_BCDEN) |
<> | 161:2cc1468da177 | 170 | /** |
<> | 161:2cc1468da177 | 171 | * @brief Handle BatteryCharging Process. |
<> | 161:2cc1468da177 | 172 | * @param hpcd: PCD handle |
<> | 161:2cc1468da177 | 173 | * @retval HAL status |
<> | 161:2cc1468da177 | 174 | */ |
<> | 161:2cc1468da177 | 175 | void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd) |
<> | 161:2cc1468da177 | 176 | { |
<> | 161:2cc1468da177 | 177 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; |
<> | 161:2cc1468da177 | 178 | uint32_t tickstart = HAL_GetTick(); |
<> | 161:2cc1468da177 | 179 | |
<> | 161:2cc1468da177 | 180 | /* Start BCD When device is connected */ |
<> | 161:2cc1468da177 | 181 | if (USBx_DEVICE->DCTL & USB_OTG_DCTL_SDIS) |
<> | 161:2cc1468da177 | 182 | { |
<> | 161:2cc1468da177 | 183 | /* Enable DCD : Data Contact Detect */ |
<> | 161:2cc1468da177 | 184 | USBx->GCCFG |= USB_OTG_GCCFG_DCDEN; |
<> | 161:2cc1468da177 | 185 | |
<> | 161:2cc1468da177 | 186 | /* Wait Detect flag or a timeout is happen*/ |
<> | 161:2cc1468da177 | 187 | while ((USBx->GCCFG & USB_OTG_GCCFG_DCDET) == 0) |
<> | 161:2cc1468da177 | 188 | { |
<> | 161:2cc1468da177 | 189 | /* Check for the Timeout */ |
<> | 161:2cc1468da177 | 190 | if((HAL_GetTick() - tickstart ) > 1000) |
<> | 161:2cc1468da177 | 191 | { |
<> | 161:2cc1468da177 | 192 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_ERROR); |
<> | 161:2cc1468da177 | 193 | return; |
<> | 161:2cc1468da177 | 194 | } |
<> | 161:2cc1468da177 | 195 | } |
<> | 161:2cc1468da177 | 196 | |
<> | 161:2cc1468da177 | 197 | /* Right response got */ |
<> | 161:2cc1468da177 | 198 | HAL_Delay(100); |
<> | 161:2cc1468da177 | 199 | |
<> | 161:2cc1468da177 | 200 | /* Check Detect flag*/ |
<> | 161:2cc1468da177 | 201 | if (USBx->GCCFG & USB_OTG_GCCFG_DCDET) |
<> | 161:2cc1468da177 | 202 | { |
<> | 161:2cc1468da177 | 203 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CONTACT_DETECTION); |
<> | 161:2cc1468da177 | 204 | } |
<> | 161:2cc1468da177 | 205 | |
<> | 161:2cc1468da177 | 206 | /*Primary detection: checks if connected to Standard Downstream Port |
<> | 161:2cc1468da177 | 207 | (without charging capability) */ |
<> | 161:2cc1468da177 | 208 | USBx->GCCFG &=~ USB_OTG_GCCFG_DCDEN; |
<> | 161:2cc1468da177 | 209 | USBx->GCCFG |= USB_OTG_GCCFG_PDEN; |
<> | 161:2cc1468da177 | 210 | HAL_Delay(100); |
<> | 161:2cc1468da177 | 211 | |
<> | 161:2cc1468da177 | 212 | if (!(USBx->GCCFG & USB_OTG_GCCFG_PDET)) |
<> | 161:2cc1468da177 | 213 | { |
<> | 161:2cc1468da177 | 214 | /* Case of Standard Downstream Port */ |
<> | 161:2cc1468da177 | 215 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT); |
<> | 161:2cc1468da177 | 216 | } |
<> | 161:2cc1468da177 | 217 | else |
<> | 161:2cc1468da177 | 218 | { |
<> | 161:2cc1468da177 | 219 | /* start secondary detection to check connection to Charging Downstream |
<> | 161:2cc1468da177 | 220 | Port or Dedicated Charging Port */ |
<> | 161:2cc1468da177 | 221 | USBx->GCCFG &=~ USB_OTG_GCCFG_PDEN; |
<> | 161:2cc1468da177 | 222 | USBx->GCCFG |= USB_OTG_GCCFG_SDEN; |
<> | 161:2cc1468da177 | 223 | HAL_Delay(100); |
<> | 161:2cc1468da177 | 224 | |
<> | 161:2cc1468da177 | 225 | if ((USBx->GCCFG) & USB_OTG_GCCFG_SDET) |
<> | 161:2cc1468da177 | 226 | { |
<> | 161:2cc1468da177 | 227 | /* case Dedicated Charging Port */ |
<> | 161:2cc1468da177 | 228 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT); |
<> | 161:2cc1468da177 | 229 | } |
<> | 161:2cc1468da177 | 230 | else |
<> | 161:2cc1468da177 | 231 | { |
<> | 161:2cc1468da177 | 232 | /* case Charging Downstream Port */ |
<> | 161:2cc1468da177 | 233 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT); |
<> | 161:2cc1468da177 | 234 | } |
<> | 161:2cc1468da177 | 235 | } |
<> | 161:2cc1468da177 | 236 | /* Battery Charging capability discovery finished */ |
<> | 161:2cc1468da177 | 237 | HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DISCOVERY_COMPLETED); |
<> | 161:2cc1468da177 | 238 | } |
<> | 161:2cc1468da177 | 239 | } |
<> | 161:2cc1468da177 | 240 | |
<> | 161:2cc1468da177 | 241 | /** |
<> | 161:2cc1468da177 | 242 | * @brief Activate BatteryCharging feature. |
<> | 161:2cc1468da177 | 243 | * @param hpcd: PCD handle |
<> | 161:2cc1468da177 | 244 | * @retval HAL status |
<> | 161:2cc1468da177 | 245 | */ |
<> | 161:2cc1468da177 | 246 | HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd) |
<> | 161:2cc1468da177 | 247 | { |
<> | 161:2cc1468da177 | 248 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; |
<> | 161:2cc1468da177 | 249 | |
<> | 161:2cc1468da177 | 250 | hpcd->battery_charging_active = ENABLE; |
<> | 161:2cc1468da177 | 251 | USBx->GCCFG |= (USB_OTG_GCCFG_BCDEN); |
<> | 161:2cc1468da177 | 252 | |
<> | 161:2cc1468da177 | 253 | return HAL_OK; |
<> | 161:2cc1468da177 | 254 | } |
<> | 161:2cc1468da177 | 255 | |
<> | 161:2cc1468da177 | 256 | /** |
<> | 161:2cc1468da177 | 257 | * @brief Deactivate BatteryCharging feature. |
<> | 161:2cc1468da177 | 258 | * @param hpcd: PCD handle |
<> | 161:2cc1468da177 | 259 | * @retval HAL status |
<> | 161:2cc1468da177 | 260 | */ |
<> | 161:2cc1468da177 | 261 | HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd) |
<> | 161:2cc1468da177 | 262 | { |
<> | 161:2cc1468da177 | 263 | USB_OTG_GlobalTypeDef *USBx = hpcd->Instance; |
<> | 161:2cc1468da177 | 264 | hpcd->battery_charging_active = DISABLE; |
<> | 161:2cc1468da177 | 265 | USBx->GCCFG &= ~(USB_OTG_GCCFG_BCDEN); |
<> | 161:2cc1468da177 | 266 | return HAL_OK; |
<> | 161:2cc1468da177 | 267 | } |
<> | 161:2cc1468da177 | 268 | |
<> | 161:2cc1468da177 | 269 | |
<> | 161:2cc1468da177 | 270 | /** |
<> | 161:2cc1468da177 | 271 | * @brief Send BatteryCharging message to user layer callback. |
<> | 161:2cc1468da177 | 272 | * @param hpcd: PCD handle |
<> | 161:2cc1468da177 | 273 | * @param msg: LPM message |
<> | 161:2cc1468da177 | 274 | * @retval HAL status |
<> | 161:2cc1468da177 | 275 | */ |
<> | 161:2cc1468da177 | 276 | __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg) |
<> | 161:2cc1468da177 | 277 | { |
<> | 161:2cc1468da177 | 278 | /* Prevent unused argument(s) compilation warning */ |
<> | 161:2cc1468da177 | 279 | UNUSED(hpcd); |
<> | 161:2cc1468da177 | 280 | UNUSED(msg); |
<> | 161:2cc1468da177 | 281 | |
<> | 161:2cc1468da177 | 282 | /* NOTE : This function should not be modified, when the callback is needed, |
<> | 161:2cc1468da177 | 283 | the HAL_PCDEx_BCD_Callback could be implemented in the user file |
<> | 161:2cc1468da177 | 284 | */ |
<> | 161:2cc1468da177 | 285 | } |
<> | 161:2cc1468da177 | 286 | |
<> | 161:2cc1468da177 | 287 | #endif /* USB_OTG_GCCFG_BCDEN */ |
<> | 144:ef7eb2e8f9f7 | 288 | /** |
<> | 144:ef7eb2e8f9f7 | 289 | * @brief Send LPM message to user layer callback. |
<> | 144:ef7eb2e8f9f7 | 290 | * @param hpcd: PCD handle |
<> | 144:ef7eb2e8f9f7 | 291 | * @param msg: LPM message |
<> | 144:ef7eb2e8f9f7 | 292 | * @retval HAL status |
<> | 144:ef7eb2e8f9f7 | 293 | */ |
<> | 144:ef7eb2e8f9f7 | 294 | __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg) |
<> | 144:ef7eb2e8f9f7 | 295 | { |
<> | 144:ef7eb2e8f9f7 | 296 | /* Prevent unused argument(s) compilation warning */ |
<> | 144:ef7eb2e8f9f7 | 297 | UNUSED(hpcd); |
<> | 144:ef7eb2e8f9f7 | 298 | UNUSED(msg); |
<> | 144:ef7eb2e8f9f7 | 299 | |
<> | 144:ef7eb2e8f9f7 | 300 | /* NOTE : This function Should not be modified, when the callback is needed, |
<> | 144:ef7eb2e8f9f7 | 301 | the HAL_PCDEx_LPM_Callback could be implemented in the user file |
<> | 144:ef7eb2e8f9f7 | 302 | */ |
<> | 144:ef7eb2e8f9f7 | 303 | } |
<> | 144:ef7eb2e8f9f7 | 304 | |
<> | 144:ef7eb2e8f9f7 | 305 | /** |
<> | 144:ef7eb2e8f9f7 | 306 | * @} |
<> | 144:ef7eb2e8f9f7 | 307 | */ |
<> | 144:ef7eb2e8f9f7 | 308 | |
<> | 144:ef7eb2e8f9f7 | 309 | /** |
<> | 144:ef7eb2e8f9f7 | 310 | * @} |
<> | 144:ef7eb2e8f9f7 | 311 | */ |
<> | 144:ef7eb2e8f9f7 | 312 | |
<> | 144:ef7eb2e8f9f7 | 313 | #endif /* HAL_PCD_MODULE_ENABLED */ |
<> | 144:ef7eb2e8f9f7 | 314 | /** |
<> | 144:ef7eb2e8f9f7 | 315 | * @} |
<> | 144:ef7eb2e8f9f7 | 316 | */ |
<> | 144:ef7eb2e8f9f7 | 317 | |
<> | 144:ef7eb2e8f9f7 | 318 | /** |
<> | 144:ef7eb2e8f9f7 | 319 | * @} |
<> | 144:ef7eb2e8f9f7 | 320 | */ |
<> | 144:ef7eb2e8f9f7 | 321 | |
<> | 144:ef7eb2e8f9f7 | 322 | /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/ |