Huge refactoring for C++ and low-power mode
The display currently shows the time, with hours and minutes, and is capable of receiving input with buttons (though does nothing). It sleeps during intervals where nothing is happening. The display task runs once per second, and RTC alarm A is used for periodic alarms to update the system time.
This commit is contained in:
15
LowPower.cpp
15
LowPower.cpp
@@ -43,25 +43,20 @@ ReturnCode LowPower::init()
|
||||
|
||||
ReturnCode LowPower::sleep()
|
||||
{
|
||||
// TODO: unimplemented
|
||||
|
||||
return ReturnCode::FAIL;
|
||||
}
|
||||
|
||||
ReturnCode LowPower::stop()
|
||||
{
|
||||
|
||||
/* Prepare to enter stop mode */
|
||||
SET(PWR->CR, PWR_CR_CWUF); // clear WUF
|
||||
SET(PWR->CR, PWR_CR_CWUF); // clear wakeup flag
|
||||
while(PWR->CSR & PWR_CSR_WUF) {};
|
||||
|
||||
CLR(PWR->CR, PWR_CR_PDDS); // Enter stop mode when the CPU enters deepsleep
|
||||
CLR(RCC->CFGR, RCC_CFGR_STOPWUCK); // MSI oscillator is wake-up from stop clock
|
||||
SET(SCB->SCR, SCB_SCR_SLEEPDEEP_Msk); // low-power mode = stop mode
|
||||
// Common::time_t time0 = ~0;
|
||||
// SystemTimer::get_time(time0);
|
||||
__WFI(); // enter low-power mode
|
||||
// Common::time_t time1 = ~0;
|
||||
// SystemTimer::get_time(time1);
|
||||
// Common::time_t timediff = time1 - time0;
|
||||
// volatile Common::time_t timediff2 = timediff;
|
||||
__WFI(); // enter low-power mode (Wake from interrupt)
|
||||
|
||||
return ReturnCode::OK;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user