stm32f1xx_HBL/drv/pwr.c
2024-07-14 19:17:20 +02:00

52 lines
1.1 KiB
C

/** @file pwr.c
* Module handling the power management's control
*
* The module provides functions to enter the different sleep states, control
* and filter wakeup events (WKUP and RTC) and configure power voltage
* detection
*/
//--includes--------------------------------------------------------------------
#include "pwr.h"
#include "pwr_regs.h"
#include "scb.h"
//--local definitions-----------------------------------------------------------
//--local variables-------------------------------------------------------------
static volatile struct PWR* regs = (struct PWR*)PWR_BASE_ADDRESS;
//--public functions------------------------------------------------------------
void pwr_sleep(void)
{
scb_configure_deepsleep(false);
__asm("wfi");
}
void pwr_stop(enum PwrWakeupSpeed speed)
{
scb_configure_deepsleep(true);
regs->CR.PDDS = 0;
regs->CR.LPDS = speed;
__asm("wfi");
}
void pwr_standby(void)
{
scb_configure_deepsleep(true);
regs->CR.PDDS = 1;
__asm("wfi");
}
//--local functions-------------------------------------------------------------
//--ISRs------------------------------------------------------------------------