[M487] Fix premature lp_ticker interrupt

Old lp_ticker handles past event, but it has a bug with premature go-off.
The bug can re-produce on mbed-os-tests-mbed_drivers-lp_timeout/mbed-os-tests-mbed_hal-lp_us_tickers (mbed-os commit: 9c1fd48529).
Because upper layer (mbed-os/hal/mbed_ticker_api.c) has handled past event, this code can be removed from lp_ticker.

The similar fix also applies to us_ticker.
pull/5553/head
ccli8 2017-10-23 15:28:17 +08:00 committed by Martin Kojtal
parent a519b8449b
commit 8b86d44867
2 changed files with 9 additions and 24 deletions

View File

@ -144,21 +144,13 @@ timestamp_t lp_ticker_read()
void lp_ticker_set_interrupt(timestamp_t timestamp)
{
uint32_t now = lp_ticker_read();
uint32_t delta = timestamp - lp_ticker_read();
wakeup_tick = timestamp;
TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
int delta = (int) (timestamp - now);
if (delta > 0) {
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
lp_ticker_arm_cd();
} else {
// NOTE: With lp_ticker_fire_interrupt() introduced, upper layer would handle past event case.
// This code fragment gets redundant, but it is still kept here for backward-compatible.
void lp_ticker_fire_interrupt(void);
lp_ticker_fire_interrupt();
}
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
lp_ticker_arm_cd();
}
void lp_ticker_fire_interrupt(void)

View File

@ -146,17 +146,10 @@ void us_ticker_clear_interrupt(void)
void us_ticker_set_interrupt(timestamp_t timestamp)
{
TIMER_Stop((TIMER_T *) NU_MODBASE(timer1hires_modinit.modname));
int delta = (int) (timestamp - us_ticker_read());
if (delta > 0) {
cd_major_minor_us = delta * US_PER_TICK;
us_ticker_arm_cd();
} else {
// NOTE: With us_ticker_fire_interrupt() introduced, upper layer would handle past event case.
// This code fragment gets redundant, but it is still kept here for backward-compatible.
void us_ticker_fire_interrupt(void);
us_ticker_fire_interrupt();
}
uint32_t delta = timestamp - us_ticker_read();
cd_major_minor_us = delta * US_PER_TICK;
us_ticker_arm_cd();
}
void us_ticker_fire_interrupt(void)