Skip to content

Commit dd84c0b

Browse files
test-mbed_drivers-ticker: fix ticker cross attach
This commit fixes ticker cross-schedule bug in test_case_2x_callbacks subtest In effect of this bug: ticker_callback_1_switch_to_2 was called only once ticker2 was never been fired because it was repeatedly detached just before fire and attached again
1 parent 3c793a7 commit dd84c0b

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

TESTS/mbed_drivers/ticker/main.cpp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,7 +69,9 @@ void ticker_callback_1_switch_to_2(void)
6969
// If ticker is NULL then it is being or has been deleted
7070
if (ticker1) {
7171
ticker1->detach();
72-
ticker1->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC);
72+
}
73+
if (ticker2) {
74+
ticker2->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC);
7375
}
7476
switch_led1_state();
7577
}
@@ -80,7 +82,9 @@ void ticker_callback_2_switch_to_1(void)
8082
// If ticker is NULL then it is being or has been deleted
8183
if (ticker2) {
8284
ticker2->detach();
83-
ticker2->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC);
85+
}
86+
if (ticker1) {
87+
ticker1->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC);
8488
}
8589
switch_led2_state();
8690
}

0 commit comments

Comments
 (0)