stm32f7xx_hal_pwr.c
Go to the documentation of this file.
1 
25 /* Includes ------------------------------------------------------------------*/
26 #include "stm32f7xx_hal.h"
27 
37 #ifdef HAL_PWR_MODULE_ENABLED
38 
39 /* Private typedef -----------------------------------------------------------*/
40 /* Private define ------------------------------------------------------------*/
48 #define PVD_MODE_IT ((uint32_t)0x00010000U)
49 #define PVD_MODE_EVT ((uint32_t)0x00020000U)
50 #define PVD_RISING_EDGE ((uint32_t)0x00000001U)
51 #define PVD_FALLING_EDGE ((uint32_t)0x00000002U)
52 
59 #define PWR_EWUP_MASK ((uint32_t)0x00003F00)
60 
67 /* Private macro -------------------------------------------------------------*/
68 /* Private variables ---------------------------------------------------------*/
69 /* Private function prototypes -----------------------------------------------*/
70 /* Private functions ---------------------------------------------------------*/
71 
100 void HAL_PWR_DeInit(void)
101 {
104 }
105 
113 void HAL_PWR_EnableBkUpAccess(void)
114 {
115  /* Enable access to RTC and backup registers */
116  SET_BIT(PWR->CR1, PWR_CR1_DBP);
117 }
118 
126 void HAL_PWR_DisableBkUpAccess(void)
127 {
128  /* Disable access to RTC and backup registers */
129  CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
130 }
131 
260 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
261 {
262  /* Check the parameters */
263  assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
264  assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
265 
266  /* Set PLS[7:5] bits according to PVDLevel value */
267  MODIFY_REG(PWR->CR1, PWR_CR1_PLS, sConfigPVD->PVDLevel);
268 
269  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
274 
275  /* Configure interrupt mode */
276  if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
277  {
279  }
280 
281  /* Configure event mode */
282  if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
283  {
285  }
286 
287  /* Configure the edge */
288  if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
289  {
291  }
292 
293  if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
294  {
296  }
297 }
298 
303 void HAL_PWR_EnablePVD(void)
304 {
305  /* Enable the power voltage detector */
306  SET_BIT(PWR->CR1, PWR_CR1_PVDE);
307 }
308 
313 void HAL_PWR_DisablePVD(void)
314 {
315  /* Disable the power voltage detector */
316  CLEAR_BIT(PWR->CR1, PWR_CR1_PVDE);
317 }
318 
336 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity)
337 {
338  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinPolarity));
339 
340  /* Enable wake-up pin */
341  SET_BIT(PWR->CSR2, (PWR_EWUP_MASK & WakeUpPinPolarity));
342 
343  /* Specifies the Wake-Up pin polarity for the event detection
344  (rising or falling edge) */
345  MODIFY_REG(PWR->CR2, (PWR_EWUP_MASK & WakeUpPinPolarity), (WakeUpPinPolarity >> 0x06));
346 }
347 
360 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
361 {
362  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
363 
364  CLEAR_BIT(PWR->CSR2, WakeUpPinx);
365 }
366 
387 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
388 {
389  /* Check the parameters */
390  assert_param(IS_PWR_REGULATOR(Regulator));
391  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
392 
393  /* Clear SLEEPDEEP bit of Cortex System Control Register */
394  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
395 
396  /* Ensure that all instructions done before entering SLEEP mode */
397  __DSB();
398  __ISB();
399 
400  /* Select SLEEP mode entry -------------------------------------------------*/
401  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
402  {
403  /* Request Wait For Interrupt */
404  __WFI();
405  }
406  else
407  {
408  /* Request Wait For Event */
409  __SEV();
410  __WFE();
411  __WFE();
412  }
413 }
414 
434 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
435 {
436  uint32_t tmpreg = 0;
437 
438  /* Check the parameters */
439  assert_param(IS_PWR_REGULATOR(Regulator));
440  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
441 
442  /* Select the regulator state in Stop mode ---------------------------------*/
443  tmpreg = PWR->CR1;
444  /* Clear PDDS and LPDS bits */
445  tmpreg &= (uint32_t)~(PWR_CR1_PDDS | PWR_CR1_LPDS);
446 
447  /* Set LPDS, MRLVDS and LPLVDS bits according to Regulator value */
448  tmpreg |= Regulator;
449 
450  /* Store the new value */
451  PWR->CR1 = tmpreg;
452 
453  /* Set SLEEPDEEP bit of Cortex System Control Register */
454  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
455 
456  /* Ensure that all instructions done before entering STOP mode */
457  __DSB();
458  __ISB();
459 
460  /* Select Stop mode entry --------------------------------------------------*/
461  if(STOPEntry == PWR_STOPENTRY_WFI)
462  {
463  /* Request Wait For Interrupt */
464  __WFI();
465  }
466  else
467  {
468  /* Request Wait For Event */
469  __SEV();
470  __WFE();
471  __WFE();
472  }
473  /* Reset SLEEPDEEP bit of Cortex System Control Register */
474  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
475 }
476 
487 void HAL_PWR_EnterSTANDBYMode(void)
488 {
489  /* Select Standby mode */
490  PWR->CR1 |= PWR_CR1_PDDS;
491 
492  /* Set SLEEPDEEP bit of Cortex System Control Register */
493  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
494 
495  /* This option is used to ensure that store operations are completed */
496 #if defined ( __CC_ARM)
497  __force_stores();
498 #endif
499  /* Request Wait For Interrupt */
500  __WFI();
501 }
502 
508 void HAL_PWR_PVD_IRQHandler(void)
509 {
510  /* Check PWR Exti flag */
512  {
513  /* PWR PVD interrupt user callback */
515 
516  /* Clear PWR Exti pending bit */
518  }
519 }
520 
525 __weak void HAL_PWR_PVDCallback(void)
526 {
527  /* NOTE : This function Should not be modified, when the callback is needed,
528  the HAL_PWR_PVDCallback could be implemented in the user file
529  */
530 }
531 
540 void HAL_PWR_EnableSleepOnExit(void)
541 {
542  /* Set SLEEPONEXIT bit of Cortex System Control Register */
543  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
544 }
545 
553 {
554  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
555  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
556 }
557 
564 void HAL_PWR_EnableSEVOnPend(void)
565 {
566  /* Set SEVONPEND bit of Cortex System Control Register */
567  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
568 }
569 
576 void HAL_PWR_DisableSEVOnPend(void)
577 {
578  /* Clear SEVONPEND bit of Cortex System Control Register */
579  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
580 }
581 
590 #endif /* HAL_PWR_MODULE_ENABLED */
591 
599 /************************ (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
HAL_PWR_EnterSTOPMode
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
HAL_PWR_EnablePVD
void HAL_PWR_EnablePVD(void)
HAL_PWR_EnterSTANDBYMode
void HAL_PWR_EnterSTANDBYMode(void)
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
__DSB
__STATIC_FORCEINLINE void __DSB(void)
Data Synchronization Barrier.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_gcc.h:944
__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
__ISB
__STATIC_FORCEINLINE void __ISB(void)
Instruction Synchronization Barrier.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_gcc.h:933
PWR_CR1_LPDS
#define PWR_CR1_LPDS
Definition: stm32f769xx.h:10431
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
__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_EWUP_MASK
#define PWR_EWUP_MASK
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_pwr.h:204
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
PWR_CR1_DBP
#define PWR_CR1_DBP
Definition: stm32f769xx.h:10473
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)
__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
IS_PWR_REGULATOR
#define IS_PWR_REGULATOR(REGULATOR)
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:404
__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
PWR_CR1_PVDE
#define PWR_CR1_PVDE
Definition: stm32f769xx.h:10440
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
PWR_CR1_PLS
#define PWR_CR1_PLS
Definition: stm32f769xx.h:10443
stm32f7xx_hal.h
This file contains all the functions prototypes for the HAL module driver.
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
PWR_CR1_PDDS
#define PWR_CR1_PDDS
Definition: stm32f769xx.h:10434
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:53