mirror of https://github.com/ARMmbed/mbed-os.git
Merge pull request #6055 from mprse/ticker_k64f_set_interrupt_delta_fix
K64F lp ticker driver - calculation bug fix.pull/6162/head
commit
f2ff36b1e3
|
@ -83,10 +83,15 @@ void us_ticker_clear_interrupt(void)
|
|||
|
||||
void us_ticker_set_interrupt(timestamp_t timestamp)
|
||||
{
|
||||
uint32_t now_us, delta_us;
|
||||
|
||||
now_us = us_ticker_read();
|
||||
delta_us = timestamp >= now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
||||
|
||||
uint32_t delta = timestamp - us_ticker_read();
|
||||
PIT_StopTimer(PIT, kPIT_Chnl_3);
|
||||
PIT_StopTimer(PIT, kPIT_Chnl_2);
|
||||
PIT_SetTimerPeriod(PIT, kPIT_Chnl_3, (uint32_t)delta);
|
||||
PIT_SetTimerPeriod(PIT, kPIT_Chnl_3, (uint32_t)delta_us);
|
||||
PIT_EnableInterrupts(PIT, kPIT_Chnl_3, kPIT_TimerInterruptEnable);
|
||||
PIT_StartTimer(PIT, kPIT_Chnl_3);
|
||||
PIT_StartTimer(PIT, kPIT_Chnl_2);
|
||||
|
|
|
@ -135,7 +135,7 @@ void lp_ticker_set_interrupt(timestamp_t timestamp)
|
|||
|
||||
lptmr_schedule = 0;
|
||||
now_us = lp_ticker_read();
|
||||
delta_us = timestamp > now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
||||
delta_us = timestamp >= now_us ? timestamp - now_us : (uint32_t)((uint64_t)timestamp + 0xFFFFFFFF - now_us);
|
||||
|
||||
/* Checking if LPTRM can handle this sleep */
|
||||
delta_ticks = USEC_TO_COUNT(delta_us, CLOCK_GetFreq(kCLOCK_Er32kClk));
|
||||
|
|
Loading…
Reference in New Issue