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:
2019-04-17 21:51:35 -07:00
parent 6747d6c831
commit a7f1ffc1b5
22 changed files with 1051 additions and 231 deletions

View File

@@ -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;
}