1 /**
2   ******************************************************************************
3   * @file    stm32u5xx_hal_pcd_ex.c
4   * @author  MCD Application Team
5   * @brief   PCD Extended HAL module driver.
6   *          This file provides firmware functions to manage the following
7   *          functionalities of the USB Peripheral Controller:
8   *           + Extended features functions
9   *
10   ******************************************************************************
11   * @attention
12   *
13   * Copyright (c) 2021 STMicroelectronics.
14   * All rights reserved.
15   *
16   * This software is licensed under terms that can be found in the LICENSE file
17   * in the root directory of this software component.
18   * If no LICENSE file comes with this software, it is provided AS-IS.
19   *
20   ******************************************************************************
21   */
22 
23 /* Includes ------------------------------------------------------------------*/
24 #include "stm32u5xx_hal.h"
25 
26 /** @addtogroup STM32U5xx_HAL_Driver
27   * @{
28   */
29 
30 /** @defgroup PCDEx PCDEx
31   * @brief PCD Extended HAL module driver
32   * @{
33   */
34 
35 #ifdef HAL_PCD_MODULE_ENABLED
36 
37 #if defined (USB_OTG_FS) || defined (USB_OTG_HS) || defined (USB_DRD_FS)
38 /* Private types -------------------------------------------------------------*/
39 /* Private variables ---------------------------------------------------------*/
40 /* Private constants ---------------------------------------------------------*/
41 /* Private macros ------------------------------------------------------------*/
42 /* Private functions ---------------------------------------------------------*/
43 /* Exported functions --------------------------------------------------------*/
44 
45 /** @defgroup PCDEx_Exported_Functions PCDEx Exported Functions
46   * @{
47   */
48 
49 /** @defgroup PCDEx_Exported_Functions_Group1 Peripheral Control functions
50   * @brief    PCDEx control functions
51   *
52 @verbatim
53  ===============================================================================
54                  ##### Extended features functions #####
55  ===============================================================================
56     [..]  This section provides functions allowing to:
57       (+) Update FIFO configuration
58 
59 @endverbatim
60   * @{
61   */
62 #if defined (USB_OTG_FS) || defined (USB_OTG_HS)
63 /**
64   * @brief  Set Tx FIFO
65   * @param  hpcd PCD handle
66   * @param  fifo The number of Tx fifo
67   * @param  size Fifo size
68   * @retval HAL status
69   */
HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef * hpcd,uint8_t fifo,uint16_t size)70 HAL_StatusTypeDef HAL_PCDEx_SetTxFiFo(PCD_HandleTypeDef *hpcd, uint8_t fifo, uint16_t size)
71 {
72   uint8_t i;
73   uint32_t Tx_Offset;
74 
75   /*  TXn min size = 16 words. (n  : Transmit FIFO index)
76       When a TxFIFO is not used, the Configuration should be as follows:
77           case 1 :  n > m    and Txn is not used    (n,m  : Transmit FIFO indexes)
78          --> Txm can use the space allocated for Txn.
79          case2  :  n < m    and Txn is not used    (n,m  : Transmit FIFO indexes)
80          --> Txn should be configured with the minimum space of 16 words
81      The FIFO is used optimally when used TxFIFOs are allocated in the top
82          of the FIFO.Ex: use EP1 and EP2 as IN instead of EP1 and EP3 as IN ones.
83      When DMA is used 3n * FIFO locations should be reserved for internal DMA registers */
84 
85   Tx_Offset = hpcd->Instance->GRXFSIZ;
86 
87   if (fifo == 0U)
88   {
89     hpcd->Instance->DIEPTXF0_HNPTXFSIZ = ((uint32_t)size << 16) | Tx_Offset;
90   }
91   else
92   {
93     Tx_Offset += (hpcd->Instance->DIEPTXF0_HNPTXFSIZ) >> 16;
94     for (i = 0U; i < (fifo - 1U); i++)
95     {
96       Tx_Offset += (hpcd->Instance->DIEPTXF[i] >> 16);
97     }
98 
99     /* Multiply Tx_Size by 2 to get higher performance */
100     hpcd->Instance->DIEPTXF[fifo - 1U] = ((uint32_t)size << 16) | Tx_Offset;
101   }
102 
103   return HAL_OK;
104 }
105 
106 /**
107   * @brief  Set Rx FIFO
108   * @param  hpcd PCD handle
109   * @param  size Size of Rx fifo
110   * @retval HAL status
111   */
HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef * hpcd,uint16_t size)112 HAL_StatusTypeDef HAL_PCDEx_SetRxFiFo(PCD_HandleTypeDef *hpcd, uint16_t size)
113 {
114   hpcd->Instance->GRXFSIZ = size;
115 
116   return HAL_OK;
117 }
118 
119 /**
120   * @brief  Activate LPM feature.
121   * @param  hpcd PCD handle
122   * @retval HAL status
123   */
HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef * hpcd)124 HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd)
125 {
126   USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
127 
128   hpcd->lpm_active = 1U;
129   hpcd->LPM_State = LPM_L0;
130   USBx->GINTMSK |= USB_OTG_GINTMSK_LPMINTM;
131   USBx->GLPMCFG |= (USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
132 
133   return HAL_OK;
134 }
135 
136 /**
137   * @brief  Deactivate LPM feature.
138   * @param  hpcd PCD handle
139   * @retval HAL status
140   */
HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef * hpcd)141 HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd)
142 {
143   USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
144 
145   hpcd->lpm_active = 0U;
146   USBx->GINTMSK &= ~USB_OTG_GINTMSK_LPMINTM;
147   USBx->GLPMCFG &= ~(USB_OTG_GLPMCFG_LPMEN | USB_OTG_GLPMCFG_LPMACK | USB_OTG_GLPMCFG_ENBESL);
148 
149   return HAL_OK;
150 }
151 
152 
153 /**
154   * @brief  Handle BatteryCharging Process.
155   * @param  hpcd PCD handle
156   * @retval HAL status
157   */
HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef * hpcd)158 void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd)
159 {
160   USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
161   uint32_t tickstart = HAL_GetTick();
162 
163   /* Enable DCD : Data Contact Detect */
164   USBx->GCCFG |= USB_OTG_GCCFG_DCDEN;
165 
166   /* Wait for Min DCD Timeout */
167   HAL_Delay(300U);
168 
169 #if defined (STM32U575xx) || defined (STM32U585xx)
170   /* Check Detect flag */
171   if ((USBx->GCCFG & USB_OTG_GCCFG_DCDET) == USB_OTG_GCCFG_DCDET)
172   {
173 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
174     hpcd->BCDCallback(hpcd, PCD_BCD_CONTACT_DETECTION);
175 #else
176     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CONTACT_DETECTION);
177 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
178   }
179 #endif /* defined (STM32U575xx) || defined (STM32U585xx) */
180 
181   /* Primary detection: checks if connected to Standard Downstream Port
182   (without charging capability) */
183   USBx->GCCFG &= ~ USB_OTG_GCCFG_DCDEN;
184   HAL_Delay(50U);
185   USBx->GCCFG |= USB_OTG_GCCFG_PDEN;
186   HAL_Delay(50U);
187 
188 #if defined (STM32U575xx) || defined (STM32U585xx)
189   if ((USBx->GCCFG & USB_OTG_GCCFG_PDET) == 0U)
190 #else
191   if ((USBx->GCCFG & USB_OTG_GCCFG_CHGDET) == 0U)
192 #endif /* defined (STM32U575xx) || defined (STM32U585xx) */
193   {
194     /* Case of Standard Downstream Port */
195 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
196     hpcd->BCDCallback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
197 #else
198     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
199 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
200   }
201   else
202   {
203     /* start secondary detection to check connection to Charging Downstream
204     Port or Dedicated Charging Port */
205     USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
206     HAL_Delay(50U);
207     USBx->GCCFG |= USB_OTG_GCCFG_SDEN;
208     HAL_Delay(50U);
209 
210 #if defined (STM32U575xx) || defined (STM32U585xx)
211     if ((USBx->GCCFG & USB_OTG_GCCFG_SDET) == USB_OTG_GCCFG_SDET)
212 #else
213     if ((USBx->GCCFG & USB_OTG_GCCFG_FSVPLUS) == USB_OTG_GCCFG_FSVPLUS)
214 #endif /* defined (STM32U575xx) || defined (STM32U585xx) */
215     {
216       /* case Dedicated Charging Port  */
217 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
218       hpcd->BCDCallback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
219 #else
220       HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
221 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
222     }
223     else
224     {
225       /* case Charging Downstream Port */
226 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
227       hpcd->BCDCallback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
228 #else
229       HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
230 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
231     }
232   }
233 
234   /* Battery Charging capability discovery finished */
235   (void)HAL_PCDEx_DeActivateBCD(hpcd);
236 
237   /* Check for the Timeout, else start USB Device */
238   if ((HAL_GetTick() - tickstart) > 1000U)
239   {
240 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
241     hpcd->BCDCallback(hpcd, PCD_BCD_ERROR);
242 #else
243     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_ERROR);
244 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
245   }
246   else
247   {
248 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
249     hpcd->BCDCallback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
250 #else
251     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
252 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
253   }
254 }
255 
256 /**
257   * @brief  Activate BatteryCharging feature.
258   * @param  hpcd PCD handle
259   * @retval HAL status
260   */
HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef * hpcd)261 HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd)
262 {
263   USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
264 
265   USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
266   USBx->GCCFG &= ~(USB_OTG_GCCFG_SDEN);
267 
268 #if defined (STM32U575xx) || defined (STM32U585xx)
269   /* Power Down USB transceiver  */
270   USBx->GCCFG &= ~(USB_OTG_GCCFG_PWRDWN);
271 
272   /* Enable Battery charging */
273   USBx->GCCFG |= USB_OTG_GCCFG_BCDEN;
274 #endif /* defined (STM32U575xx) || defined (STM32U585xx) */
275 
276   hpcd->battery_charging_active = 1U;
277 
278   return HAL_OK;
279 }
280 
281 /**
282   * @brief  Deactivate BatteryCharging feature.
283   * @param  hpcd PCD handle
284   * @retval HAL status
285   */
HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef * hpcd)286 HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd)
287 {
288   USB_OTG_GlobalTypeDef *USBx = hpcd->Instance;
289 
290   USBx->GCCFG &= ~(USB_OTG_GCCFG_SDEN);
291   USBx->GCCFG &= ~(USB_OTG_GCCFG_PDEN);
292 
293 #if defined (STM32U575xx) || defined (STM32U585xx)
294   /* Disable Battery charging */
295   USBx->GCCFG &= ~(USB_OTG_GCCFG_BCDEN);
296 #endif /* defined (STM32U575xx) || defined (STM32U585xx) */
297 
298   hpcd->battery_charging_active = 0U;
299 
300   return HAL_OK;
301 }
302 
303 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) */
304 #if defined (USB_DRD_FS)
305 /**
306   * @brief  Configure PMA for EP
307   * @param  hpcd  Device instance
308   * @param  ep_addr endpoint address
309   * @param  ep_kind endpoint Kind
310   *                  USB_SNG_BUF: Single Buffer used
311   *                  USB_DBL_BUF: Double Buffer used
312   * @param  pmaadress: EP address in The PMA: In case of single buffer endpoint
313   *                   this parameter is 16-bit value providing the address
314   *                   in PMA allocated to endpoint.
315   *                   In case of double buffer endpoint this parameter
316   *                   is a 32-bit value providing the endpoint buffer 0 address
317   *                   in the LSB part of 32-bit value and endpoint buffer 1 address
318   *                   in the MSB part of 32-bit value.
319   * @retval HAL status
320   */
321 
HAL_PCDEx_PMAConfig(PCD_HandleTypeDef * hpcd,uint16_t ep_addr,uint16_t ep_kind,uint32_t pmaadress)322 HAL_StatusTypeDef  HAL_PCDEx_PMAConfig(PCD_HandleTypeDef *hpcd, uint16_t ep_addr,
323                                        uint16_t ep_kind, uint32_t pmaadress)
324 {
325   PCD_EPTypeDef *ep;
326 
327   /* initialize ep structure*/
328   if ((0x80U & ep_addr) == 0x80U)
329   {
330     ep = &hpcd->IN_ep[ep_addr & EP_ADDR_MSK];
331   }
332   else
333   {
334     ep = &hpcd->OUT_ep[ep_addr];
335   }
336 
337   /* Here we check if the endpoint is single or double Buffer*/
338   if (ep_kind == PCD_SNG_BUF)
339   {
340     /* Single Buffer */
341     ep->doublebuffer = 0U;
342     /* Configure the PMA */
343     ep->pmaadress = (uint16_t)pmaadress;
344   }
345 #if (USE_USB_DOUBLE_BUFFER == 1U)
346   else /* USB_DBL_BUF */
347   {
348     /* Double Buffer Endpoint */
349     ep->doublebuffer = 1U;
350     /* Configure the PMA */
351     ep->pmaaddr0 = (uint16_t)(pmaadress & 0xFFFFU);
352     ep->pmaaddr1 = (uint16_t)((pmaadress & 0xFFFF0000U) >> 16);
353   }
354 #endif /* (USE_USB_DOUBLE_BUFFER == 1U) */
355 
356   return HAL_OK;
357 }
358 
359 /**
360   * @brief  Activate BatteryCharging feature.
361   * @param  hpcd PCD handle
362   * @retval HAL status
363   */
HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef * hpcd)364 HAL_StatusTypeDef HAL_PCDEx_ActivateBCD(PCD_HandleTypeDef *hpcd)
365 {
366   USB_DRD_TypeDef *USBx = hpcd->Instance;
367   hpcd->battery_charging_active = 1U;
368 
369   /* Enable BCD feature */
370   USBx->BCDR |= USB_BCDR_BCDEN;
371 
372   /* Enable DCD : Data Contact Detect */
373   USBx->BCDR &= ~(USB_BCDR_PDEN);
374   USBx->BCDR &= ~(USB_BCDR_SDEN);
375   USBx->BCDR |= USB_BCDR_DCDEN;
376 
377   return HAL_OK;
378 }
379 
380 /**
381   * @brief  Deactivate BatteryCharging feature.
382   * @param  hpcd PCD handle
383   * @retval HAL status
384   */
HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef * hpcd)385 HAL_StatusTypeDef HAL_PCDEx_DeActivateBCD(PCD_HandleTypeDef *hpcd)
386 {
387   USB_DRD_TypeDef *USBx = hpcd->Instance;
388   hpcd->battery_charging_active = 0U;
389 
390   /* Disable BCD feature */
391   USBx->BCDR &= ~(USB_BCDR_BCDEN);
392 
393   return HAL_OK;
394 }
395 
396 /**
397   * @brief  Handle BatteryCharging Process.
398   * @param  hpcd PCD handle
399   * @retval HAL status
400   */
HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef * hpcd)401 void HAL_PCDEx_BCD_VBUSDetect(PCD_HandleTypeDef *hpcd)
402 {
403   USB_DRD_TypeDef *USBx = hpcd->Instance;
404   uint32_t tickstart = HAL_GetTick();
405 
406   /* Wait for Min DCD Timeout */
407   HAL_Delay(300U);
408 
409   /* Data Pin Contact ? Check Detect flag */
410   if ((USBx->BCDR & USB_BCDR_DCDET) == USB_BCDR_DCDET)
411   {
412 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
413     hpcd->BCDCallback(hpcd, PCD_BCD_CONTACT_DETECTION);
414 #else
415     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CONTACT_DETECTION);
416 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
417   }
418   /* Primary detection: checks if connected to Standard Downstream Port
419   (without charging capability) */
420   USBx->BCDR &= ~(USB_BCDR_DCDEN);
421   HAL_Delay(50U);
422   USBx->BCDR |= (USB_BCDR_PDEN);
423   HAL_Delay(50U);
424 
425   /* If Charger detect ? */
426   if ((USBx->BCDR & USB_BCDR_PDET) == USB_BCDR_PDET)
427   {
428     /* Start secondary detection to check connection to Charging Downstream
429     Port or Dedicated Charging Port */
430     USBx->BCDR &= ~(USB_BCDR_PDEN);
431     HAL_Delay(50U);
432     USBx->BCDR |= (USB_BCDR_SDEN);
433     HAL_Delay(50U);
434 
435     /* If CDP ? */
436     if ((USBx->BCDR & USB_BCDR_SDET) == USB_BCDR_SDET)
437     {
438       /* Dedicated Downstream Port DCP */
439 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
440       hpcd->BCDCallback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
441 #else
442       HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DEDICATED_CHARGING_PORT);
443 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
444     }
445     else
446     {
447       /* Charging Downstream Port CDP */
448 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
449       hpcd->BCDCallback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
450 #else
451       HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_CHARGING_DOWNSTREAM_PORT);
452 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
453     }
454   }
455   else /* NO */
456   {
457     /* Standard Downstream Port */
458 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
459     hpcd->BCDCallback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
460 #else
461     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_STD_DOWNSTREAM_PORT);
462 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
463   }
464 
465   /* Battery Charging capability discovery finished Start Enumeration */
466   (void)HAL_PCDEx_DeActivateBCD(hpcd);
467 
468   /* Check for the Timeout, else start USB Device */
469   if ((HAL_GetTick() - tickstart) > 1000U)
470   {
471 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
472     hpcd->BCDCallback(hpcd, PCD_BCD_ERROR);
473 #else
474     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_ERROR);
475 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
476   }
477   else
478   {
479 #if (USE_HAL_PCD_REGISTER_CALLBACKS == 1U)
480     hpcd->BCDCallback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
481 #else
482     HAL_PCDEx_BCD_Callback(hpcd, PCD_BCD_DISCOVERY_COMPLETED);
483 #endif /* USE_HAL_PCD_REGISTER_CALLBACKS */
484   }
485 }
486 
487 
488 /**
489   * @brief  Activate LPM feature.
490   * @param  hpcd PCD handle
491   * @retval HAL status
492   */
HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef * hpcd)493 HAL_StatusTypeDef HAL_PCDEx_ActivateLPM(PCD_HandleTypeDef *hpcd)
494 {
495 
496   USB_DRD_TypeDef *USBx = hpcd->Instance;
497   hpcd->lpm_active = 1U;
498   hpcd->LPM_State = LPM_L0;
499 
500   USBx->LPMCSR |= USB_LPMCSR_LMPEN;
501   USBx->LPMCSR |= USB_LPMCSR_LPMACK;
502 
503   return HAL_OK;
504 }
505 
506 /**
507   * @brief  Deactivate LPM feature.
508   * @param  hpcd PCD handle
509   * @retval HAL status
510   */
HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef * hpcd)511 HAL_StatusTypeDef HAL_PCDEx_DeActivateLPM(PCD_HandleTypeDef *hpcd)
512 {
513   USB_DRD_TypeDef *USBx = hpcd->Instance;
514 
515   hpcd->lpm_active = 0U;
516 
517   USBx->LPMCSR &= ~(USB_LPMCSR_LMPEN);
518   USBx->LPMCSR &= ~(USB_LPMCSR_LPMACK);
519 
520   return HAL_OK;
521 }
522 
523 #endif /* defined (USB_DRD_FS) */
524 
525 /**
526   * @brief  Send LPM message to user layer callback.
527   * @param  hpcd PCD handle
528   * @param  msg LPM message
529   * @retval HAL status
530   */
HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef * hpcd,PCD_LPM_MsgTypeDef msg)531 __weak void HAL_PCDEx_LPM_Callback(PCD_HandleTypeDef *hpcd, PCD_LPM_MsgTypeDef msg)
532 {
533   /* Prevent unused argument(s) compilation warning */
534   UNUSED(hpcd);
535   UNUSED(msg);
536 
537   /* NOTE : This function should not be modified, when the callback is needed,
538             the HAL_PCDEx_LPM_Callback could be implemented in the user file
539    */
540 }
541 
542 /**
543   * @brief  Send BatteryCharging message to user layer callback.
544   * @param  hpcd PCD handle
545   * @param  msg LPM message
546   * @retval HAL status
547   */
HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef * hpcd,PCD_BCD_MsgTypeDef msg)548 __weak void HAL_PCDEx_BCD_Callback(PCD_HandleTypeDef *hpcd, PCD_BCD_MsgTypeDef msg)
549 {
550   /* Prevent unused argument(s) compilation warning */
551   UNUSED(hpcd);
552   UNUSED(msg);
553 
554   /* NOTE : This function should not be modified, when the callback is needed,
555             the HAL_PCDEx_BCD_Callback could be implemented in the user file
556    */
557 }
558 
559 /**
560   * @}
561   */
562 
563 /**
564   * @}
565   */
566 #endif /* defined (USB_OTG_FS) || defined (USB_OTG_HS) || defined (USB_DRD_FS) */
567 #endif /* HAL_PCD_MODULE_ENABLED */
568 
569 /**
570   * @}
571   */
572 
573 /**
574   * @}
575   */
576