Merge pull request #5553 from 0xc0170/OpenNuvoton-nuvoton_fix_lpticker

Nuvoton: fix lpticker interrupt
pull/5526/head
Jimmy Brisson 2017-11-22 10:20:31 -06:00 committed by GitHub
commit b7a7d4ed1a
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 23 deletions

View File

@ -103,8 +103,6 @@ void lp_ticker_init(void)
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
lp_ticker_set_interrupt(wakeup_tick);
}
timestamp_t lp_ticker_read()
@ -144,21 +142,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

@ -147,16 +147,9 @@ 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)