File tree Expand file tree Collapse file tree 2 files changed +26
-35
lines changed
targets/TARGET_NUVOTON/TARGET_M2351 Expand file tree Collapse file tree 2 files changed +26
-35
lines changed Original file line number Diff line number Diff line change @@ -145,32 +145,23 @@ timestamp_t lp_ticker_read()
145
145
146
146
void lp_ticker_set_interrupt (timestamp_t timestamp )
147
147
{
148
- uint32_t now = lp_ticker_read ();
148
+ uint32_t delta = timestamp - lp_ticker_read ();
149
149
wakeup_tick = timestamp ;
150
150
151
151
TIMER_Stop ((TIMER_T * ) NU_MODBASE (timer3_modinit .modname ));
152
-
152
+
153
+ cd_major_minor_clks = (uint64_t ) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC ;
154
+ lp_ticker_arm_cd ();
155
+ }
156
+
157
+ void lp_ticker_fire_interrupt (void )
158
+ {
159
+ cd_major_minor_clks = cd_minor_clks = 0 ;
153
160
/**
154
- * NOTE: Scheduled alarm may go off incorrectly due to wrap around.
155
- * Conditions in which delta is negative:
156
- * 1. Wrap around
157
- * 2. Newly scheduled alarm is behind now
158
- */
159
- //int delta = (timestamp > now) ? (timestamp - now) : (uint32_t) ((uint64_t) timestamp + 0xFFFFFFFFu - now);
160
- int delta = (int ) (timestamp - now );
161
-
162
- if (delta > 0 ) {
163
- cd_major_minor_clks = (uint64_t ) delta * US_PER_TICK * TMR3_CLK_PER_SEC / US_PER_SEC ;
164
- lp_ticker_arm_cd ();
165
- }
166
- else {
167
- cd_major_minor_clks = cd_minor_clks = 0 ;
168
- /**
169
- * This event was in the past. Set the interrupt as pending, but don't process it here.
170
- * This prevents a recurive loop under heavy load which can lead to a stack overflow.
171
- */
172
- NVIC_SetPendingIRQ (timer3_modinit .irq_n );
173
- }
161
+ * This event was in the past. Set the interrupt as pending, but don't process it here.
162
+ * This prevents a recurive loop under heavy load which can lead to a stack overflow.
163
+ */
164
+ NVIC_SetPendingIRQ (timer3_modinit .irq_n );
174
165
}
175
166
176
167
void lp_ticker_disable_interrupt (void )
Original file line number Diff line number Diff line change @@ -152,20 +152,20 @@ void us_ticker_clear_interrupt(void)
152
152
void us_ticker_set_interrupt (timestamp_t timestamp )
153
153
{
154
154
TIMER_Stop ((TIMER_T * ) NU_MODBASE (timer1hires_modinit .modname ));
155
- int delta = (int ) (timestamp - us_ticker_read ());
156
155
157
- if (delta > 0 ) {
158
- cd_major_minor_us = delta * US_PER_TICK ;
159
- us_ticker_arm_cd ();
160
- }
161
- else {
162
- cd_major_minor_us = cd_minor_us = 0 ;
163
- /**
164
- * This event was in the past. Set the interrupt as pending, but don't process it here.
165
- * This prevents a recurive loop under heavy load which can lead to a stack overflow.
166
- */
167
- NVIC_SetPendingIRQ (timer1hires_modinit .irq_n );
168
- }
156
+ uint32_t delta = timestamp - us_ticker_read ();
157
+ cd_major_minor_us = delta * US_PER_TICK ;
158
+ us_ticker_arm_cd ();
159
+ }
160
+
161
+ void us_ticker_fire_interrupt (void )
162
+ {
163
+ cd_major_minor_us = cd_minor_us = 0 ;
164
+ /**
165
+ * This event was in the past. Set the interrupt as pending, but don't process it here.
166
+ * This prevents a recurive loop under heavy load which can lead to a stack overflow.
167
+ */
168
+ NVIC_SetPendingIRQ (timer1hires_modinit .irq_n );
169
169
}
170
170
171
171
static void tmr0_vec (void )
You can’t perform that action at this time.
0 commit comments