Verify the main app mostly sleeps

This validates that the main watch app spends at
least 99.5% of it's time sleeping in the first 10
seconds.
This commit is contained in:
2020-06-14 18:12:36 +00:00
parent 0ee9d39e81
commit 08085c465d
8 changed files with 130 additions and 71 deletions

View File

@@ -31,9 +31,19 @@ namespace BSP {
using BSP::ReturnCode;
GpioPin *LowPower::m_timing_pin = nullptr;
ReturnCode LowPower::init()
{
enable_debug();
m_timing_pin = nullptr;
return ReturnCode::OK;
}
ReturnCode LowPower::init(GpioPin &timing_pin)
{
m_timing_pin = &timing_pin;
m_timing_pin->write(0);
return ReturnCode::OK;
}
@@ -93,7 +103,13 @@ ReturnCode LowPower::stop()
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
__WFI(); // enter low-power mode (Wake from interrupt)
if (m_timing_pin != nullptr) {
m_timing_pin->write(1);
__WFI(); // enter low-power mode (Wake from interrupt)
m_timing_pin->write(0);
} else{
__WFI();
}
wakeups++;

View File

@@ -22,6 +22,7 @@
#pragma once
#include "Bsp/ReturnCode.h"
#include "Bsp/Drivers/GpioDriver.h"
extern uint32_t wakeups;
@@ -32,10 +33,14 @@ public:
LowPower() = delete;
static BSP::ReturnCode init();
static BSP::ReturnCode init(GpioPin &timing_pin);
static BSP::ReturnCode sleep();
static BSP::ReturnCode stop();
static BSP::ReturnCode enable_debug();
static BSP::ReturnCode disable_debug();
static GpioPin *m_timing_pin;
};
}