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
pull/5971/head
Maciej Bocianski 2018-01-29 15:29:15 +01:00
parent 3c793a714c
commit dd84c0bc5f
1 changed files with 6 additions and 2 deletions

View File

@ -69,7 +69,9 @@ void ticker_callback_1_switch_to_2(void)
// If ticker is NULL then it is being or has been deleted
if (ticker1) {
ticker1->detach();
ticker1->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC);
}
if (ticker2) {
ticker2->attach_us(ticker_callback_2_switch_to_1, ONE_MILLI_SEC);
}
switch_led1_state();
}
@ -80,7 +82,9 @@ void ticker_callback_2_switch_to_1(void)
// If ticker is NULL then it is being or has been deleted
if (ticker2) {
ticker2->detach();
ticker2->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC);
}
if (ticker1) {
ticker1->attach_us(ticker_callback_1_switch_to_2, ONE_MILLI_SEC);
}
switch_led2_state();
}