stm32f469/stm32f469i-disco/Drivers/STM32F4xx_HAL_Driver/Src/stm32f4xx_hal_pwr.c
Go to the documentation of this file.
1 
25 /* Includes ------------------------------------------------------------------*/
26 #include "stm32f4xx_hal.h"
27 
37 #ifdef HAL_PWR_MODULE_ENABLED
38 
39 /* Private typedef -----------------------------------------------------------*/
40 /* Private define ------------------------------------------------------------*/
48 #define PVD_MODE_IT 0x00010000U
49 #define PVD_MODE_EVT 0x00020000U
50 #define PVD_RISING_EDGE 0x00000001U
51 #define PVD_FALLING_EDGE 0x00000002U
52 
59 /* Private macro -------------------------------------------------------------*/
60 /* Private variables ---------------------------------------------------------*/
61 /* Private function prototypes -----------------------------------------------*/
62 /* Private functions ---------------------------------------------------------*/
63 
92 void HAL_PWR_DeInit(void)
93 {
96 }
97 
105 void HAL_PWR_EnableBkUpAccess(void)
106 {
107  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)ENABLE;
108 }
109 
117 void HAL_PWR_DisableBkUpAccess(void)
118 {
119  *(__IO uint32_t *) CR_DBP_BB = (uint32_t)DISABLE;
120 }
121 
252 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
253 {
254  /* Check the parameters */
255  assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
256  assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
257 
258  /* Set PLS[7:5] bits according to PVDLevel value */
259  MODIFY_REG(PWR->CR, PWR_CR_PLS, sConfigPVD->PVDLevel);
260 
261  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
266 
267  /* Configure interrupt mode */
268  if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
269  {
271  }
272 
273  /* Configure event mode */
274  if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
275  {
277  }
278 
279  /* Configure the edge */
280  if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
281  {
283  }
284 
285  if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
286  {
288  }
289 }
290 
295 void HAL_PWR_EnablePVD(void)
296 {
297  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)ENABLE;
298 }
299 
304 void HAL_PWR_DisablePVD(void)
305 {
306  *(__IO uint32_t *) CR_PVDE_BB = (uint32_t)DISABLE;
307 }
308 
318 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
319 {
320  /* Check the parameter */
321  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
322 
323  /* Enable the wake up pin */
324  SET_BIT(PWR->CSR, WakeUpPinx);
325 }
326 
336 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
337 {
338  /* Check the parameter */
339  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
340 
341  /* Disable the wake up pin */
342  CLEAR_BIT(PWR->CSR, WakeUpPinx);
343 }
344 
365 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
366 {
367  /* Check the parameters */
368  assert_param(IS_PWR_REGULATOR(Regulator));
369  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
370 
371  /* Clear SLEEPDEEP bit of Cortex System Control Register */
372  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
373 
374  /* Select SLEEP mode entry -------------------------------------------------*/
375  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
376  {
377  /* Request Wait For Interrupt */
378  __WFI();
379  }
380  else
381  {
382  /* Request Wait For Event */
383  __SEV();
384  __WFE();
385  __WFE();
386  }
387 }
388 
408 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
409 {
410  /* Check the parameters */
411  assert_param(IS_PWR_REGULATOR(Regulator));
412  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
413 
414  /* Select the regulator state in Stop mode: Set PDDS and LPDS bits according to PWR_Regulator value */
415  MODIFY_REG(PWR->CR, (PWR_CR_PDDS | PWR_CR_LPDS), Regulator);
416 
417  /* Set SLEEPDEEP bit of Cortex System Control Register */
418  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
419 
420  /* Select Stop mode entry --------------------------------------------------*/
421  if(STOPEntry == PWR_STOPENTRY_WFI)
422  {
423  /* Request Wait For Interrupt */
424  __WFI();
425  }
426  else
427  {
428  /* Request Wait For Event */
429  __SEV();
430  __WFE();
431  __WFE();
432  }
433  /* Reset SLEEPDEEP bit of Cortex System Control Register */
434  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
435 }
436 
447 void HAL_PWR_EnterSTANDBYMode(void)
448 {
449  /* Select Standby mode */
450  SET_BIT(PWR->CR, PWR_CR_PDDS);
451 
452  /* Set SLEEPDEEP bit of Cortex System Control Register */
453  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
454 
455  /* This option is used to ensure that store operations are completed */
456 #if defined ( __CC_ARM)
457  __force_stores();
458 #endif
459  /* Request Wait For Interrupt */
460  __WFI();
461 }
462 
468 void HAL_PWR_PVD_IRQHandler(void)
469 {
470  /* Check PWR Exti flag */
472  {
473  /* PWR PVD interrupt user callback */
475 
476  /* Clear PWR Exti pending bit */
478  }
479 }
480 
485 __weak void HAL_PWR_PVDCallback(void)
486 {
487  /* NOTE : This function Should not be modified, when the callback is needed,
488  the HAL_PWR_PVDCallback could be implemented in the user file
489  */
490 }
491 
500 void HAL_PWR_EnableSleepOnExit(void)
501 {
502  /* Set SLEEPONEXIT bit of Cortex System Control Register */
503  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
504 }
505 
513 {
514  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
515  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
516 }
517 
524 void HAL_PWR_EnableSEVOnPend(void)
525 {
526  /* Set SEVONPEND bit of Cortex System Control Register */
527  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
528 }
529 
536 void HAL_PWR_DisableSEVOnPend(void)
537 {
538  /* Clear SEVONPEND bit of Cortex System Control Register */
539  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
540 }
541 
550 #endif /* HAL_PWR_MODULE_ENABLED */
551 
559 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
__HAL_PWR_PVD_EXTI_DISABLE_IT
#define __HAL_PWR_PVD_EXTI_DISABLE_IT()
Disable the PVD EXTI Line 16.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:193
SCB
#define SCB
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:1778
assert_param
#define assert_param(expr)
Include module's header file.
Definition: stm32f407/stm32f407g-disc1/Inc/stm32f4xx_hal_conf.h:353
__HAL_PWR_PVD_EXTI_GET_FLAG
#define __HAL_PWR_PVD_EXTI_GET_FLAG()
checks whether the specified PVD Exti interrupt flag is set or not.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:254
__IO
#define __IO
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:237
HAL_PWR_EnterSTOPMode
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
PWR_CR_LPDS
#define PWR_CR_LPDS
Definition: stm32f407xx.h:9351
HAL_PWR_EnablePVD
void HAL_PWR_EnablePVD(void)
HAL_PWR_EnterSTANDBYMode
void HAL_PWR_EnterSTANDBYMode(void)
DISABLE
@ DISABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:193
PWR
#define PWR
Definition: stm32f407xx.h:1083
PWR_PVDTypeDef::PVDLevel
uint32_t PVDLevel
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:50
__HAL_RCC_PWR_RELEASE_RESET
#define __HAL_RCC_PWR_RELEASE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:704
PWR_PVDTypeDef
PWR PVD configuration structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:48
__HAL_RCC_PWR_FORCE_RESET
#define __HAL_RCC_PWR_FORCE_RESET()
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_rcc.h:695
PWR_CR_PDDS
#define PWR_CR_PDDS
Definition: stm32f407xx.h:9354
HAL_PWR_DisableBkUpAccess
void HAL_PWR_DisableBkUpAccess(void)
PWR_PVDTypeDef::Mode
uint32_t Mode
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:53
HAL_PWR_DisableSEVOnPend
void HAL_PWR_DisableSEVOnPend(void)
CLEAR_BIT
#define CLEAR_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:214
IS_PWR_STOP_ENTRY
#define IS_PWR_STOP_ENTRY(ENTRY)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:407
PWR_SLEEPENTRY_WFI
#define PWR_SLEEPENTRY_WFI
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:116
ENABLE
@ ENABLE
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:194
__HAL_PWR_PVD_EXTI_ENABLE_EVENT
#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT()
Enable event on PVD Exti Line 16.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:199
__HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE()
Enable the PVD Extended Interrupt Rising Trigger.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:211
HAL_PWR_PVDCallback
void HAL_PWR_PVDCallback(void)
HAL_PWR_EnableBkUpAccess
void HAL_PWR_EnableBkUpAccess(void)
PWR_STOPENTRY_WFI
#define PWR_STOPENTRY_WFI
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:125
__HAL_PWR_PVD_EXTI_DISABLE_EVENT
#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT()
Disable event on PVD Exti Line 16.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:205
MODIFY_REG
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:224
RESET
@ RESET
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:187
HAL_PWR_EnableSleepOnExit
void HAL_PWR_EnableSleepOnExit(void)
__HAL_PWR_PVD_EXTI_ENABLE_IT
#define __HAL_PWR_PVD_EXTI_ENABLE_IT()
Enable the PVD Exti Line 16.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:187
HAL_PWR_DisablePVD
void HAL_PWR_DisablePVD(void)
HAL_PWR_PVD_IRQHandler
void HAL_PWR_PVD_IRQHandler(void)
CR_DBP_BB
#define CR_DBP_BB
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:361
__HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE()
Disable the PVD Extended Interrupt Rising Trigger.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:217
HAL_PWR_ConfigPVD
void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
__HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE
#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE()
Enable the PVD Extended Interrupt Falling Trigger.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:223
HAL_PWR_DeInit
void HAL_PWR_DeInit(void)
IS_PWR_WAKEUP_PIN
#define IS_PWR_WAKEUP_PIN(PIN)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr_ex.h:317
IS_PWR_PVD_LEVEL
#define IS_PWR_PVD_LEVEL(LEVEL)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:396
PWR_CR_PLS
#define PWR_CR_PLS
Definition: stm32f407xx.h:9367
IS_PWR_REGULATOR
#define IS_PWR_REGULATOR(REGULATOR)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:404
CR_PVDE_BB
#define CR_PVDE_BB
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:365
__HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE
#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE()
Disable the PVD Extended Interrupt Falling Trigger.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:230
HAL_PWR_DisableWakeUpPin
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
IS_PWR_SLEEP_ENTRY
#define IS_PWR_SLEEP_ENTRY(ENTRY)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:406
IS_PWR_PVD_MODE
#define IS_PWR_PVD_MODE(MODE)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:400
__SEV
#define __SEV
Send Event.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_armcc.h:438
HAL_PWR_EnableSEVOnPend
void HAL_PWR_EnableSEVOnPend(void)
HAL_PWR_EnterSLEEPMode
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
__HAL_PWR_PVD_EXTI_CLEAR_FLAG
#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()
Clear the PVD Exti flag.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:260
HAL_PWR_DisableSleepOnExit
void HAL_PWR_DisableSleepOnExit(void)
SET_BIT
#define SET_BIT(REG, BIT)
Definition: stm32f407/stm32f407g-disc1/Drivers/CMSIS/Device/ST/STM32F4xx/Include/stm32f4xx.h:212
SCB_SCR_SLEEPONEXIT_Msk
#define SCB_SCR_SLEEPONEXIT_Msk
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:590
__WFE
#define __WFE
Wait For Event.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_armcc.h:431
__WFI
#define __WFI
Wait For Interrupt.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_armcc.h:423
HAL_PWR_EnableWakeUpPin
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
SCB_SCR_SLEEPDEEP_Msk
#define SCB_SCR_SLEEPDEEP_Msk
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:587
SCB_SCR_SEVONPEND_Msk
#define SCB_SCR_SEVONPEND_Msk
Definition: imxrt1050/imxrt1050-evkb/CMSIS/core_cm7.h:584


picovoice_driver
Author(s):
autogenerated on Fri Apr 1 2022 02:14:52