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

@@ -38,12 +38,22 @@ using BSP::SystemTimer;
static BSP::Schedule::LowPowerTaskScheduler<1> g_sched;
static BSP::UsartDriver g_test_uart(USART1, g_sched);
static BSP::GpioDriver g_gpioa(GPIOA);
static BSP::GpioPin g_test_pin(g_gpioa, 6);
static BSP::time_t get_time() {
BSP::time_t time;
BSP::ReturnCode rc = SystemTimer::get_time(time);
if (rc != ReturnCode::OK) {
g_test_uart.tx_blocking("Failed while getting the time\r\n");
g_test_uart.tx_blocking(test_fail_text);
TEST_SPIN();
}
return time;
}
[[noreturn]] void main() {
g_gpioa.enable();
g_test_pin.configure_alternate_function(1);
g_test_uart.init();
g_test_uart.tx_blocking(test_start_text);
@@ -54,25 +64,14 @@ static BSP::GpioPin g_test_pin(g_gpioa, 6);
BSP::time_t now;
ReturnCode rc = SystemTimer::get_time(now);
if (rc != ReturnCode::OK) {
g_test_uart.tx_blocking("Failed while getting initial time\r\n");
g_test_uart.tx_blocking(test_fail_text);
TEST_SPIN();
}
now = get_time();
BSP::time_t end = now + Time::seconds(10);
g_test_uart.tx_blocking("GO\r\n");
char buffer[40] = { 0 };
static char buffer[40] = { 0 };
while (now < end) {
snprintf(buffer, sizeof(buffer), "%lld\r\n", BSP::Time::to_micros(now));
g_test_uart.tx_blocking(buffer);
rc = SystemTimer::get_time(now);
if (rc != ReturnCode::OK) {
g_test_uart.tx_blocking("Failed while waiting for time to pass\r\n");
g_test_uart.tx_blocking(test_fail_text);
TEST_SPIN();
}
now = get_time();
}
g_test_uart.tx_blocking("STOP\r\n");