Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependents: Hobbyking_Cheetah_Compact Hobbyking_Cheetah_Compact_DRV8323_14bit Hobbyking_Cheetah_Compact_DRV8323_V51_201907 HKC_MiniCheetah ... more
Fork of mbed-dev by
Diff: targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c
- Revision:
- 174:b96e65c34a4d
- Parent:
- 172:7d866c31b3c5
diff -r e131a1973e81 -r b96e65c34a4d targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c
--- a/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c Fri Sep 15 14:59:18 2017 +0100
+++ b/targets/TARGET_NUVOTON/TARGET_M451/lp_ticker.c Mon Oct 02 15:33:19 2017 +0100
@@ -145,31 +145,23 @@
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));
+ 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)
+{
+ cd_major_minor_clks = cd_minor_clks = 0;
/**
- * 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) {
- cd_major_minor_clks = (uint64_t) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC;
- lp_ticker_arm_cd();
- }
- else {
- cd_major_minor_clks = cd_minor_clks = 0;
- /**
- * This event was in the past. Set the interrupt as pending, but don't process it here.
- * This prevents a recurive loop under heavy load which can lead to a stack overflow.
- */
- NVIC_SetPendingIRQ(timer3_modinit.irq_n);
- }
+ * This event was in the past. Set the interrupt as pending, but don't process it here.
+ * This prevents a recurive loop under heavy load which can lead to a stack overflow.
+ */
+ NVIC_SetPendingIRQ(timer3_modinit.irq_n);
}
void lp_ticker_disable_interrupt(void)
