Skip to content

Commit b7a7d4e

Browse files
Merge pull request #5553 from 0xc0170/OpenNuvoton-nuvoton_fix_lpticker
Nuvoton: fix lpticker interrupt
2 parents 941f572 + bc9c9ca commit b7a7d4e

File tree

2 files changed

+6
-23
lines changed

2 files changed

+6
-23
lines changed

targets/TARGET_NUVOTON/TARGET_M480/lp_ticker.c

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -103,8 +103,6 @@ void lp_ticker_init(void)
103103

104104
// Schedule wakeup to match semantics of lp_ticker_get_compare_match()
105105
lp_ticker_set_interrupt(wakeup_tick);
106-
107-
108106
}
109107

110108
timestamp_t lp_ticker_read()
@@ -144,21 +142,13 @@ timestamp_t lp_ticker_read()
144142

145143
void lp_ticker_set_interrupt(timestamp_t timestamp)
146144
{
147-
uint32_t now = lp_ticker_read();
145+
uint32_t delta = timestamp - lp_ticker_read();
148146
wakeup_tick = timestamp;
149147

150148
TIMER_Stop((TIMER_T *) NU_MODBASE(timer3_modinit.modname));
151149

152-
int delta = (int) (timestamp - now);
153-
if (delta > 0) {
154-
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
155-
lp_ticker_arm_cd();
156-
} else {
157-
// NOTE: With lp_ticker_fire_interrupt() introduced, upper layer would handle past event case.
158-
// This code fragment gets redundant, but it is still kept here for backward-compatible.
159-
void lp_ticker_fire_interrupt(void);
160-
lp_ticker_fire_interrupt();
161-
}
150+
cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
151+
lp_ticker_arm_cd();
162152
}
163153

164154
void lp_ticker_fire_interrupt(void)

targets/TARGET_NUVOTON/TARGET_M480/us_ticker.c

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -147,16 +147,9 @@ void us_ticker_set_interrupt(timestamp_t timestamp)
147147
{
148148
TIMER_Stop((TIMER_T *) NU_MODBASE(timer1hires_modinit.modname));
149149

150-
int delta = (int) (timestamp - us_ticker_read());
151-
if (delta > 0) {
152-
cd_major_minor_us = delta * US_PER_TICK;
153-
us_ticker_arm_cd();
154-
} else {
155-
// NOTE: With us_ticker_fire_interrupt() introduced, upper layer would handle past event case.
156-
// This code fragment gets redundant, but it is still kept here for backward-compatible.
157-
void us_ticker_fire_interrupt(void);
158-
us_ticker_fire_interrupt();
159-
}
150+
uint32_t delta = timestamp - us_ticker_read();
151+
cd_major_minor_us = delta * US_PER_TICK;
152+
us_ticker_arm_cd();
160153
}
161154

162155
void us_ticker_fire_interrupt(void)

0 commit comments

Comments
 (0)