Skip to content

Nuvoton: fix lpticker interrupt #5553

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 3 additions & 13 deletions targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand Down Expand Up @@ -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)
Expand Down
13 changes: 3 additions & 10 deletions targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down