STM32F769IDiscovery  1.00
uDANTE Audio Networking with STM32F7 DISCO board
stm32f7xx_hal_pwr.c
Go to the documentation of this file.
1 
43 /* Includes ------------------------------------------------------------------*/
44 #include "stm32f7xx_hal.h"
45 
55 #ifdef HAL_PWR_MODULE_ENABLED
56 
57 /* Private typedef -----------------------------------------------------------*/
58 /* Private define ------------------------------------------------------------*/
66 #define PVD_MODE_IT ((uint32_t)0x00010000U)
67 #define PVD_MODE_EVT ((uint32_t)0x00020000U)
68 #define PVD_RISING_EDGE ((uint32_t)0x00000001U)
69 #define PVD_FALLING_EDGE ((uint32_t)0x00000002U)
70 
77 #define PWR_EWUP_MASK ((uint32_t)0x00003F00)
78 
85 /* Private macro -------------------------------------------------------------*/
86 /* Private variables ---------------------------------------------------------*/
87 /* Private function prototypes -----------------------------------------------*/
88 /* Private functions ---------------------------------------------------------*/
89 
118 void HAL_PWR_DeInit(void)
119 {
122 }
123 
131 void HAL_PWR_EnableBkUpAccess(void)
132 {
133  /* Enable access to RTC and backup registers */
134  SET_BIT(PWR->CR1, PWR_CR1_DBP);
135 }
136 
144 void HAL_PWR_DisableBkUpAccess(void)
145 {
146  /* Disable access to RTC and backup registers */
147  CLEAR_BIT(PWR->CR1, PWR_CR1_DBP);
148 }
149 
278 void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
279 {
280  /* Check the parameters */
281  assert_param(IS_PWR_PVD_LEVEL(sConfigPVD->PVDLevel));
282  assert_param(IS_PWR_PVD_MODE(sConfigPVD->Mode));
283 
284  /* Set PLS[7:5] bits according to PVDLevel value */
285  MODIFY_REG(PWR->CR1, PWR_CR1_PLS, sConfigPVD->PVDLevel);
286 
287  /* Clear any previous config. Keep it clear if no event or IT mode is selected */
292 
293  /* Configure interrupt mode */
294  if((sConfigPVD->Mode & PVD_MODE_IT) == PVD_MODE_IT)
295  {
297  }
298 
299  /* Configure event mode */
300  if((sConfigPVD->Mode & PVD_MODE_EVT) == PVD_MODE_EVT)
301  {
303  }
304 
305  /* Configure the edge */
306  if((sConfigPVD->Mode & PVD_RISING_EDGE) == PVD_RISING_EDGE)
307  {
309  }
310 
311  if((sConfigPVD->Mode & PVD_FALLING_EDGE) == PVD_FALLING_EDGE)
312  {
314  }
315 }
316 
321 void HAL_PWR_EnablePVD(void)
322 {
323  /* Enable the power voltage detector */
324  SET_BIT(PWR->CR1, PWR_CR1_PVDE);
325 }
326 
331 void HAL_PWR_DisablePVD(void)
332 {
333  /* Disable the power voltage detector */
334  CLEAR_BIT(PWR->CR1, PWR_CR1_PVDE);
335 }
336 
354 void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity)
355 {
356  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinPolarity));
357 
358  /* Enable wake-up pin */
359  SET_BIT(PWR->CSR2, (PWR_EWUP_MASK & WakeUpPinPolarity));
360 
361  /* Specifies the Wake-Up pin polarity for the event detection
362  (rising or falling edge) */
363  MODIFY_REG(PWR->CR2, (PWR_EWUP_MASK & WakeUpPinPolarity), (WakeUpPinPolarity >> 0x06));
364 }
365 
378 void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
379 {
380  assert_param(IS_PWR_WAKEUP_PIN(WakeUpPinx));
381 
382  CLEAR_BIT(PWR->CSR2, WakeUpPinx);
383 }
384 
405 void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
406 {
407  /* Check the parameters */
408  assert_param(IS_PWR_REGULATOR(Regulator));
409  assert_param(IS_PWR_SLEEP_ENTRY(SLEEPEntry));
410 
411  /* Clear SLEEPDEEP bit of Cortex System Control Register */
412  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPDEEP_Msk));
413 
414  /* Select SLEEP mode entry -------------------------------------------------*/
415  if(SLEEPEntry == PWR_SLEEPENTRY_WFI)
416  {
417  /* Request Wait For Interrupt */
418  __WFI();
419  }
420  else
421  {
422  /* Request Wait For Event */
423  __SEV();
424  __WFE();
425  __WFE();
426  }
427 }
428 
448 void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
449 {
450  uint32_t tmpreg = 0;
451 
452  /* Check the parameters */
453  assert_param(IS_PWR_REGULATOR(Regulator));
454  assert_param(IS_PWR_STOP_ENTRY(STOPEntry));
455 
456  /* Select the regulator state in Stop mode ---------------------------------*/
457  tmpreg = PWR->CR1;
458  /* Clear PDDS and LPDS bits */
459  tmpreg &= (uint32_t)~(PWR_CR1_PDDS | PWR_CR1_LPDS);
460 
461  /* Set LPDS, MRLVDS and LPLVDS bits according to Regulator value */
462  tmpreg |= Regulator;
463 
464  /* Store the new value */
465  PWR->CR1 = tmpreg;
466 
467  /* Set SLEEPDEEP bit of Cortex System Control Register */
468  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
469 
470  /* Select Stop mode entry --------------------------------------------------*/
471  if(STOPEntry == PWR_STOPENTRY_WFI)
472  {
473  /* Request Wait For Interrupt */
474  __WFI();
475  }
476  else
477  {
478  /* Request Wait For Event */
479  __SEV();
480  __WFE();
481  __WFE();
482  }
483  /* Reset SLEEPDEEP bit of Cortex System Control Register */
484  SCB->SCR &= (uint32_t)~((uint32_t)SCB_SCR_SLEEPDEEP_Msk);
485 }
486 
497 void HAL_PWR_EnterSTANDBYMode(void)
498 {
499  /* Select Standby mode */
500  PWR->CR1 |= PWR_CR1_PDDS;
501 
502  /* Set SLEEPDEEP bit of Cortex System Control Register */
503  SCB->SCR |= SCB_SCR_SLEEPDEEP_Msk;
504 
505  /* This option is used to ensure that store operations are completed */
506 #if defined ( __CC_ARM)
507  __force_stores();
508 #endif
509  /* Request Wait For Interrupt */
510  __WFI();
511 }
512 
518 void HAL_PWR_PVD_IRQHandler(void)
519 {
520  /* Check PWR Exti flag */
522  {
523  /* PWR PVD interrupt user callback */
525 
526  /* Clear PWR Exti pending bit */
528  }
529 }
530 
535 __weak void HAL_PWR_PVDCallback(void)
536 {
537  /* NOTE : This function Should not be modified, when the callback is needed,
538  the HAL_PWR_PVDCallback could be implemented in the user file
539  */
540 }
541 
550 void HAL_PWR_EnableSleepOnExit(void)
551 {
552  /* Set SLEEPONEXIT bit of Cortex System Control Register */
553  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
554 }
555 
563 {
564  /* Clear SLEEPONEXIT bit of Cortex System Control Register */
565  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SLEEPONEXIT_Msk));
566 }
567 
574 void HAL_PWR_EnableSEVOnPend(void)
575 {
576  /* Set SEVONPEND bit of Cortex System Control Register */
577  SET_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
578 }
579 
586 void HAL_PWR_DisableSEVOnPend(void)
587 {
588  /* Clear SEVONPEND bit of Cortex System Control Register */
589  CLEAR_BIT(SCB->SCR, ((uint32_t)SCB_SCR_SEVONPEND_Msk));
590 }
591 
600 #endif /* HAL_PWR_MODULE_ENABLED */
601 
609 /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
void HAL_PWR_EnableSleepOnExit(void)
#define CLEAR_BIT(REG, BIT)
Definition: stm32f7xx.h:180
#define MODIFY_REG(REG, CLEARMASK, SETMASK)
Definition: stm32f7xx.h:190
#define SCB_SCR_SLEEPDEEP_Msk
Definition: core_cm0.h:467
void HAL_PWR_DisableWakeUpPin(uint32_t WakeUpPinx)
void HAL_PWR_DisableBkUpAccess(void)
void HAL_PWR_DisableSEVOnPend(void)
void HAL_PWR_DisableSleepOnExit(void)
#define __HAL_PWR_PVD_EXTI_DISABLE_FALLING_EDGE()
Disable the PVD Extended Interrupt Falling Trigger.
#define __HAL_PWR_PVD_EXTI_CLEAR_FLAG()
Clear the PVD Exti flag.
#define __HAL_RCC_PWR_RELEASE_RESET()
#define IS_PWR_PVD_LEVEL(LEVEL)
#define __HAL_PWR_PVD_EXTI_GET_FLAG()
checks whether the specified PVD Exti interrupt flag is set or not.
#define assert_param(expr)
Include module's header file.
#define PWR_SLEEPENTRY_WFI
#define __SEV
Send Event.
Definition: cmsis_armcc.h:335
#define __HAL_PWR_PVD_EXTI_ENABLE_RISING_EDGE()
Enable the PVD Extended Interrupt Rising Trigger.
void HAL_PWR_EnterSTANDBYMode(void)
PWR PVD configuration structure definition.
#define SCB_SCR_SLEEPONEXIT_Msk
Definition: core_cm0.h:470
void HAL_PWR_DisablePVD(void)
#define IS_PWR_WAKEUP_PIN(__PIN__)
#define PWR_CR1_DBP
Definition: stm32f745xx.h:4979
void HAL_PWR_EnterSLEEPMode(uint32_t Regulator, uint8_t SLEEPEntry)
#define __HAL_PWR_PVD_EXTI_DISABLE_EVENT()
Disable event on PVD Exti Line 16.
#define __HAL_PWR_PVD_EXTI_ENABLE_FALLING_EDGE()
Enable the PVD Extended Interrupt Falling Trigger.
#define __HAL_PWR_PVD_EXTI_ENABLE_EVENT()
Enable event on PVD Exti Line 16.
#define SCB
Definition: core_cm0.h:587
#define PWR_CR1_PDDS
Definition: stm32f745xx.h:4962
This file contains all the functions prototypes for the HAL module driver.
#define SCB_SCR_SEVONPEND_Msk
Definition: core_cm0.h:464
void HAL_PWR_EnterSTOPMode(uint32_t Regulator, uint8_t STOPEntry)
#define PWR_CR1_PVDE
Definition: stm32f745xx.h:4964
void HAL_PWR_EnablePVD(void)
#define PWR
Definition: stm32f745xx.h:1285
#define __HAL_PWR_PVD_EXTI_DISABLE_IT()
Disable the PVD EXTI Line 16.
#define IS_PWR_STOP_ENTRY(ENTRY)
#define PWR_CR1_PLS
Definition: stm32f745xx.h:4965
#define PWR_CR1_LPDS
Definition: stm32f745xx.h:4961
void HAL_PWR_ConfigPVD(PWR_PVDTypeDef *sConfigPVD)
void HAL_PWR_PVDCallback(void)
#define SET_BIT(REG, BIT)
Definition: stm32f7xx.h:178
#define IS_PWR_SLEEP_ENTRY(ENTRY)
#define IS_PWR_PVD_MODE(MODE)
#define PWR_STOPENTRY_WFI
#define IS_PWR_REGULATOR(REGULATOR)
void HAL_PWR_PVD_IRQHandler(void)
#define __WFI
Wait For Interrupt.
Definition: cmsis_armcc.h:320
void HAL_PWR_EnableWakeUpPin(uint32_t WakeUpPinPolarity)
#define __HAL_PWR_PVD_EXTI_ENABLE_IT()
Enable the PVD Exti Line 16.
void HAL_PWR_EnableBkUpAccess(void)
#define __HAL_PWR_PVD_EXTI_DISABLE_RISING_EDGE()
Disable the PVD Extended Interrupt Rising Trigger.
#define __WFE
Wait For Event.
Definition: cmsis_armcc.h:328
void HAL_PWR_DeInit(void)
#define __HAL_RCC_PWR_FORCE_RESET()
void HAL_PWR_EnableSEVOnPend(void)