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