Merge pull request #2651 from svastm/fix_lp_timer_test

Use lp_timer to count time in the deepsleep tests
pull/2604/head
Sam Grove 2016-09-09 18:02:10 -05:00 committed by GitHub
commit 7dd1b04c2e
2 changed files with 12 additions and 4 deletions

View File

@ -43,11 +43,15 @@ void lp_timeout_1s_deepsleep(void)
{ {
complete = false; complete = false;
timestamp_t start = us_ticker_read(); /*
* We use here lp_ticker_read() instead of us_ticker_read() for start and
* end because the microseconds timer might be disable during deepsleep.
*/
timestamp_t start = lp_ticker_read();
lpt.attach(&cb_done, 1); lpt.attach(&cb_done, 1);
deepsleep(); deepsleep();
while (!complete); while (!complete);
timestamp_t end = us_ticker_read(); timestamp_t end = lp_ticker_read();
/* It takes longer to wake up from deep sleep */ /* It takes longer to wake up from deep sleep */
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start); TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);

View File

@ -69,11 +69,15 @@ void lp_ticker_1s_deepsleep()
ticker_remove_event(lp_ticker_data, &delay_event); ticker_remove_event(lp_ticker_data, &delay_event);
delay_ts = lp_ticker_read() + 1000000; delay_ts = lp_ticker_read() + 1000000;
timestamp_t start = us_ticker_read(); /*
* We use here lp_ticker_read() instead of us_ticker_read() for start and
* end because the microseconds timer might be disable during deepsleep.
*/
timestamp_t start = lp_ticker_read();
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event); ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
deepsleep(); deepsleep();
while (!complete); while (!complete);
timestamp_t end = us_ticker_read(); timestamp_t end = lp_ticker_read();
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start); TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
TEST_ASSERT_TRUE(complete); TEST_ASSERT_TRUE(complete);