Fix RTC synchronization after sleep, add many more tests

There were two issues with the tests

1. Incorrect print formats causing incorrect output.

2. The RTC driver was not waiting for the shadow registers to be
updated after sleeping, their reset values to be read.
This commit is contained in:
2020-04-22 09:09:31 -07:00
parent 2fa4a5e658
commit f455ce9113
20 changed files with 700 additions and 94 deletions

View File

@@ -19,6 +19,7 @@
* THE SOFTWARE.
*/
#include <cinttypes>
#include "printf.h"
#include "Bsp/Drivers/GpioDriver.h"
@@ -67,17 +68,20 @@ static void stop_for(time_t delay) {
uint32_t pre_alarms = BSP::RtcDriver::get_alarm_count();
time_t before = get_time();
BSP::LowPower::stop();
while (pre_wakeups == BSP::RtcDriver::get_wakeup_count()) {
BSP::LowPower::stop();
}
time_t after = get_time();
uint32_t post_wakeups = BSP::RtcDriver::get_wakeup_count();
uint32_t post_alarms = BSP::RtcDriver::get_alarm_count();
static char buffer[128];
static char buffer[128] = { 0 };
snprintf(buffer, sizeof(buffer),
"Requested=%lld Actual=%lld Wakeups=%d Alarms=%d\r\n",
Time::to_millis(delay),
Time::to_millis(after - before),
"Requested=%" PRIu32 " Actual=%" PRIu32
" Wakeups=%" PRId32 " Alarms=%" PRId32 "\r\n",
(uint32_t) Time::to_millis(delay),
(uint32_t) Time::to_millis(after - before),
post_wakeups - pre_wakeups,
post_alarms - pre_alarms);
@@ -96,11 +100,17 @@ static void stop_for(time_t delay) {
g_test_uart.tx_blocking(test_start_text);
for (uint32_t i = 0; i <= 1000; i++) {
stop_for(Time::millis(5));
}
for (uint32_t delay_millis = 1; delay_millis <= 1024; delay_millis *= 2) {
stop_for(Time::millis(delay_millis));
}
stop_for(Time::seconds(10));
stop_for(Time::seconds(1));
stop_for(Time::seconds(2));
stop_for(Time::seconds(4));
stop_for(Time::seconds(60));
g_test_uart.tx_blocking(test_pass_text);