Skip to content

Commit 3e24e8f

Browse files
committed
lp_ticker test: Capture completion time at completion point.
1 parent 834a302 commit 3e24e8f

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

TESTS/mbed_hal/lp_ticker/main.cpp

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929
using namespace utest::v1;
3030

3131
volatile static bool complete;
32+
volatile static timestamp_t complete_timestamp;
3233
static ticker_event_t delay_event;
3334
static const ticker_data_t *lp_ticker_data = get_lp_ticker_data();
3435

@@ -39,6 +40,7 @@ static const ticker_data_t *lp_ticker_data = get_lp_ticker_data();
3940

4041
void cb_done(uint32_t id) {
4142
complete = true;
43+
complete_timestamp = us_ticker_read();
4244
}
4345

4446
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)
5355
timestamp_t start = us_ticker_read();
5456
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
5557
while (!complete);
56-
timestamp_t end = us_ticker_read();
58+
timestamp_t end = complete_timestamp;
5759

5860
TEST_ASSERT_UINT32_WITHIN(tolerance, delay_us, end - start);
5961
TEST_ASSERT_TRUE(complete);
@@ -87,7 +89,7 @@ void lp_ticker_1s_deepsleep()
8789
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
8890
deepsleep();
8991
while (!complete);
90-
timestamp_t end = lp_ticker_read();
92+
timestamp_t end = complete_timestamp;
9193

9294
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
9395
TEST_ASSERT_TRUE(complete);
@@ -106,7 +108,7 @@ void lp_ticker_1s_sleep()
106108
ticker_insert_event(lp_ticker_data, &delay_event, delay_ts, (uint32_t)&delay_event);
107109
sleep();
108110
while (!complete);
109-
timestamp_t end = us_ticker_read();
111+
timestamp_t end = complete_timestamp;
110112

111113
TEST_ASSERT_UINT32_WITHIN(LONG_TIMEOUT, 1000000, end - start);
112114
TEST_ASSERT_TRUE(complete);

0 commit comments

Comments
 (0)