stm32h747/stm32h747i-disco/CM7/Drivers/STM32H7xx_HAL_Driver/Src/stm32h7xx_hal_pwr.c
Go to the documentation of this file.
1 
146 /* Includes ------------------------------------------------------------------*/
147 #include "stm32h7xx_hal.h"
148 
158 #ifdef HAL_PWR_MODULE_ENABLED
159 
160 /* Private typedef -----------------------------------------------------------*/
161 /* Private define ------------------------------------------------------------*/
162 
170 #if !defined (DUAL_CORE)
171 #define PVD_MODE_IT (0x00010000U)
172 #define PVD_MODE_EVT (0x00020000U)
173 #endif /* !defined (DUAL_CORE) */
174 
175 #define PVD_RISING_EDGE (0x00000001U)
176 #define PVD_FALLING_EDGE (0x00000002U)
177 #define PVD_RISING_FALLING_EDGE (0x00000003U)
178 
186 /* Private macro -------------------------------------------------------------*/
187 /* Private variables ---------------------------------------------------------*/
188 /* Private function prototypes -----------------------------------------------*/
189 /* Private functions ---------------------------------------------------------*/
190 
226 void HAL_PWR_DeInit (void)
227 {
228 }
229 
237 void HAL_PWR_EnableBkUpAccess (void)
238 {
239  /* Enable access to RTC and backup registers */
240  SET_BIT (PWR->CR1, PWR_CR1_DBP);
241 }
242 
250 void HAL_PWR_DisableBkUpAccess (void)
251 {
252  /* Disable access to RTC and backup registers */
253  CLEAR_BIT (PWR->CR1, PWR_CR1_DBP);
254 }
416 void HAL_PWR_ConfigPVD (PWR_PVDTypeDef *sConfigPVD)
417 {
418  /* Check the PVD configuration parameter */
419  if (sConfigPVD == NULL)
420  {
421  return;
422  }
423 
424  /* Check the parameters */
425  assert_param (IS_PWR_PVD_LEVEL (sConfigPVD->PVDLevel));
426  assert_param (IS_PWR_PVD_MODE (sConfigPVD->Mode));
427 
428  /* Set PLS[7:5] bits according to PVDLevel value */
429  MODIFY_REG (PWR->CR1, PWR_CR1_PLS, sConfigPVD->PVDLevel);
430 
431  /* Clear previous config */
432 #if !defined (DUAL_CORE)
435 #endif /* !defined (DUAL_CORE) */
436 
439 
440 #if !defined (DUAL_CORE)
441  /* Interrupt mode configuration */
442  if ((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
443  {
445  }
446 
447  /* Event mode configuration */
448  if ((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
449  {
451  }
452 #endif /* !defined (DUAL_CORE) */
453 
454  /* Rising edge configuration */
455  if ((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
456  {
458  }
459 
460  /* Falling edge configuration */
461  if ((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
462  {
464  }
465 }
466 
471 void HAL_PWR_EnablePVD (void)
472 {
473  /* Enable the power voltage detector */
474  SET_BIT (PWR->CR1, PWR_CR1_PVDEN);
475 }
476 
481 void HAL_PWR_DisablePVD (void)
482 {
483  /* Disable the power voltage detector */
484  CLEAR_BIT (PWR->CR1, PWR_CR1_PVDEN);
485 }
486 
508 void HAL_PWR_EnableWakeUpPin (uint32_t WakeUpPinPolarity)
509 {
510  /* Check the parameters */
511  assert_param (IS_PWR_WAKEUP_PIN (WakeUpPinPolarity));
512 
513  /*
514  Enable and Specify the Wake-Up pin polarity and the pull configuration
515  for the event detection (rising or falling edge).
516  */
517  MODIFY_REG (PWR->WKUPEPR, PWR_EWUP_MASK, WakeUpPinPolarity);
518 }
519 
537 void HAL_PWR_DisableWakeUpPin (uint32_t WakeUpPinx)
538 {
539  /* Check the parameters */
540  assert_param (IS_PWR_WAKEUP_PIN (WakeUpPinx));
541 
542  /* Disable the wake up pin selected */
543  CLEAR_BIT (PWR->WKUPEPR, (PWR_WKUPEPR_WKUPEN & WakeUpPinx));
544 }
545 
565 void HAL_PWR_EnterSLEEPMode (uint32_t Regulator, uint8_t SLEEPEntry)
566 {
567  /* Check the parameters */
568  assert_param (IS_PWR_REGULATOR (Regulator));
569  assert_param (IS_PWR_SLEEP_ENTRY (SLEEPEntry));
570 
571  /* Clear SLEEPDEEP bit of Cortex System Control Register */
573 
574  /* Select SLEEP mode entry */
575  if (SLEEPEntry == PWR_SLEEPENTRY_WFI)
576  {
577  /* Request Wait For Interrupt */
578  __WFI ();
579  }
580  else
581  {
582  /* Request Wait For Event */
583  __WFE ();
584  }
585 }
586 
616 void HAL_PWR_EnterSTOPMode (uint32_t Regulator, uint8_t STOPEntry)
617 {
618  /* Check the parameters */
619  assert_param (IS_PWR_REGULATOR (Regulator));
620  assert_param (IS_PWR_STOP_ENTRY (STOPEntry));
621 
622  /* Select the regulator state in STOP mode */
623  MODIFY_REG (PWR->CR1, PWR_CR1_LPDS, Regulator);
624 
625  /* Configure the PWR mode for the different Domains */
626 #if defined (DUAL_CORE)
627  /* Check CPU ID */
628  if (HAL_GetCurrentCPUID () == CM7_CPUID)
629  {
630  /* Keep DSTOP mode when Cortex-M7 enters DEEP-SLEEP */
632  }
633  else
634  {
635  /* Keep DSTOP mode when Cortex-M4 enters DEEP-SLEEP */
637  }
638 #else /* Single core devices */
639  /* Keep DSTOP mode when Cortex-M7 enter in DEEP-SLEEP */
641 
642 #if defined (PWR_CPUCR_PDDS_D2)
643  /* Keep DSTOP mode when Cortex-M7 enter in DEEP-SLEEP */
644  CLEAR_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D2);
645 #endif /* PWR_CPUCR_PDDS_D2 */
646 #endif /* defined (DUAL_CORE) */
647 
648  /* Set SLEEPDEEP bit of Cortex System Control Register */
650 
651  /* Ensure that all instructions are done before entering STOP mode */
652  __DSB ();
653  __ISB ();
654 
655  /* Select STOP mode entry */
656  if (STOPEntry == PWR_STOPENTRY_WFI)
657  {
658  /* Request Wait For Interrupt */
659  __WFI ();
660  }
661  else
662  {
663  /* Request Wait For Event */
664  __WFE ();
665  }
666 
667  /* Clear SLEEPDEEP bit of Cortex-Mx in the System Control Register */
669 }
670 
687 void HAL_PWR_EnterSTANDBYMode (void)
688 {
689  /* Configure the PWR mode for the different Domains */
690 #if defined (DUAL_CORE)
691  /* Check CPU ID */
692  if (HAL_GetCurrentCPUID () == CM7_CPUID)
693  {
694  /* Enter DSTANDBY mode when Cortex-M7 enters DEEP-SLEEP */
697  }
698  else
699  {
700  /* Enter DSTANDBY mode when Cortex-M4 enters DEEP-SLEEP */
703  }
704 #else /* Single core devices */
705  /* Enter DSTANDBY mode when Cortex-M7 enters DEEP-SLEEP */
707 
708 #if defined (PWR_CPUCR_PDDS_D2)
709  /* Enter DSTANDBY mode when Cortex-M7 enters DEEP-SLEEP */
710  SET_BIT (PWR->CPUCR, PWR_CPUCR_PDDS_D2);
711 #endif /* PWR_CPUCR_PDDS_D2 */
712 #endif /* defined (DUAL_CORE) */
713 
714  /* Set SLEEPDEEP bit of Cortex System Control Register */
716 
717  /* Ensure that all instructions are done before entering STOP mode */
718  __DSB ();
719  __ISB ();
720 
721  /* This option is used to ensure that store operations are completed */
722 #if defined (__CC_ARM)
723  __force_stores();
724 #endif /* defined (__CC_ARM) */
725 
726  /* Request Wait For Interrupt */
727  __WFI ();
728 }
729 
739 void HAL_PWR_EnableSleepOnExit (void)
740 {
741  /* Set SLEEPONEXIT bit of Cortex-Mx System Control Register */
743 }
744 
752 void HAL_PWR_DisableSleepOnExit (void)
753 {
754  /* Clear SLEEPONEXIT bit of Cortex-Mx System Control Register */
756 }
757 
765 void HAL_PWR_EnableSEVOnPend (void)
766 {
767  /* Set SEVONPEND bit of Cortex-Mx System Control Register */
769 }
770 
777 void HAL_PWR_DisableSEVOnPend (void)
778 {
779  /* Clear SEVONPEND bit of Cortex System Control Register */
781 }
806 void HAL_PWR_PVD_IRQHandler (void)
807 {
808 #if defined (DUAL_CORE)
809  /* Check Cortex-Mx ID */
810  if (HAL_GetCurrentCPUID () == CM7_CPUID)
811  {
812  /* Check PWR EXTI D1 flag */
813  if(__HAL_PWR_PVD_EXTI_GET_FLAG () != 0U)
814  {
815  /* Clear PWR EXTI D1 pending bit */
817 
818  /* PWR PVD interrupt user callback */
820  }
821  }
822  else
823  {
824  /* Check PWR EXTI D2 flag */
825  if (__HAL_PWR_PVD_EXTID2_GET_FLAG () != 0U)
826  {
827  /* Clear PWR EXTI D2 pending bit */
828  __HAL_PWR_PVD_EXTID2_CLEAR_FLAG ();
829 
830  /* PWR PVD interrupt user callback */
832  }
833  }
834 #else /* Single core devices */
835  /* PVD EXTI line interrupt detected */
836  if (__HAL_PWR_PVD_EXTI_GET_FLAG () != 0U)
837  {
838  /* Clear PWR EXTI pending bit */
840 
841  /* PWR PVD interrupt user callback */
843  }
844 #endif /* defined (DUAL_CORE) */
845 }
846 
851 __weak void HAL_PWR_PVDCallback (void)
852 {
853  /* NOTE : This function should not be modified, when the callback is needed,
854  the HAL_PWR_PVDCallback can be implemented in the user file
855  */
856 }
857 
866 #endif /* HAL_PWR_MODULE_ENABLED */
867 
875 /************************ (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
NULL
#define NULL
Definition: porcupine/demo/c/dr_libs/tests/external/miniaudio/extras/speex_resampler/thirdparty/resample.c:92
PWR_CR1_PVDEN
#define PWR_CR1_PVDEN
Definition: stm32h735xx.h:14551
__DSB
__STATIC_FORCEINLINE void __DSB(void)
Data Synchronization Barrier.
Definition: imxrt1050/imxrt1050-evkb/CMSIS/cmsis_gcc.h:944
PWR_PVDTypeDef
PWR PVD configuration structure definition.
Definition: stm32f407/stm32f407g-disc1/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_pwr.h:48
__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
PWR_CPUCR_PDDS_D1
#define PWR_CPUCR_PDDS_D1
Definition: stm32h735xx.h:14695
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
PWR_CPU2CR_PDDS_D2
#define PWR_CPU2CR_PDDS_D2
Definition: stm32h747xx.h:17791
__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_GetCurrentCPUID
uint32_t HAL_GetCurrentCPUID(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
PWR_WKUPEPR_WKUPEN
#define PWR_WKUPEPR_WKUPEN
Definition: stm32h735xx.h:14783
PWR_CPU2CR_PDDS_D1
#define PWR_CPU2CR_PDDS_D1
Definition: stm32h747xx.h:17794
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)
PWR_CPUCR_PDDS_D2
#define PWR_CPUCR_PDDS_D2
Definition: stm32h735xx.h:14692
__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
CM7_CPUID
#define CM7_CPUID
Definition: stm32h735/stm32h735g-dk/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_cortex.h:275
__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
PWR_CPUCR_PDDS_D3
#define PWR_CPUCR_PDDS_D3
Definition: stm32h735xx.h:14689
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
PWR_CR1_PLS
#define PWR_CR1_PLS
Definition: stm32f769xx.h:10443
HAL_PWR_EnableWakeUpPin
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinx)
PWR_CPU2CR_PDDS_D3
#define PWR_CPU2CR_PDDS_D3
Definition: stm32h747xx.h:17788
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:54