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