[NUC472/M453] Remove fix of lp_ticker wrap-around

The original fix cannot handle both wrap-around and scheduled alarm behind now well.
Leave wrap-around as known issue.
pull/2861/head
ccli8 2016-09-08 14:53:31 +08:00
parent 9b7642d783
commit da15379907
2 changed files with 16 additions and 2 deletions

View File

@ -147,7 +147,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname)); TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now); /**
* FIXME: Scheduled alarm may go off incorrectly due to wrap around.
* Conditions in which delta is negative:
* 1. Wrap around
* 2. Newly scheduled alarm is behind now
*/
//int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now);
int delta = (int) (timestamp - now);
if (delta > 0) { if (delta > 0) {
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC; cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
lp_ticker_arm_cd(); lp_ticker_arm_cd();

View File

@ -146,7 +146,14 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname)); TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now); /**
* FIXME: Scheduled alarm may go off incorrectly due to wrap around.
* Conditions in which delta is negative:
* 1. Wrap around
* 2. Newly scheduled alarm is behind now
*/
//int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now);
int delta = (int) (timestamp - now);
if (delta > 0) { if (delta > 0) {
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC; cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
lp_ticker_arm_cd(); lp_ticker_arm_cd();