29
29
using namespace utest ::v1;
30
30
31
31
volatile static bool complete;
32
+ volatile static timestamp_t complete_timestamp;
32
33
static ticker_event_t delay_event;
33
34
static const ticker_data_t *lp_ticker_data = get_lp_ticker_data();
34
35
@@ -39,6 +40,7 @@ static const ticker_data_t *lp_ticker_data = get_lp_ticker_data();
39
40
40
41
void cb_done (uint32_t id) {
41
42
complete = true ;
43
+ complete_timestamp = us_ticker_read ();
42
44
}
43
45
44
46
void lp_ticker_delay_us (uint32_t delay_us, uint32_t tolerance)
@@ -53,7 +55,7 @@ void lp_ticker_delay_us(uint32_t delay_us, uint32_t tolerance)
53
55
timestamp_t start = us_ticker_read ();
54
56
ticker_insert_event (lp_ticker_data, &delay_event, delay_ts, (uint32_t )&delay_event);
55
57
while (!complete);
56
- timestamp_t end = us_ticker_read () ;
58
+ timestamp_t end = complete_timestamp ;
57
59
58
60
TEST_ASSERT_UINT32_WITHIN (tolerance, delay_us, end - start);
59
61
TEST_ASSERT_TRUE (complete);
@@ -87,7 +89,7 @@ void lp_ticker_1s_deepsleep()
87
89
ticker_insert_event (lp_ticker_data, &delay_event, delay_ts, (uint32_t )&delay_event);
88
90
deepsleep ();
89
91
while (!complete);
90
- timestamp_t end = lp_ticker_read () ;
92
+ timestamp_t end = complete_timestamp ;
91
93
92
94
TEST_ASSERT_UINT32_WITHIN (LONG_TIMEOUT, 1000000 , end - start);
93
95
TEST_ASSERT_TRUE (complete);
@@ -106,7 +108,7 @@ void lp_ticker_1s_sleep()
106
108
ticker_insert_event (lp_ticker_data, &delay_event, delay_ts, (uint32_t )&delay_event);
107
109
sleep ();
108
110
while (!complete);
109
- timestamp_t end = us_ticker_read () ;
111
+ timestamp_t end = complete_timestamp ;
110
112
111
113
TEST_ASSERT_UINT32_WITHIN (LONG_TIMEOUT, 1000000 , end - start);
112
114
TEST_ASSERT_TRUE (complete);
0 commit comments