@@ -32,15 +32,7 @@ void LowPowerTickerWrapper::irq_handler(ticker_irq_handler_type handler)
32
32
{
33
33
core_util_critical_section_enter ();
34
34
35
- if (_suspended) {
36
- if (handler) {
37
- handler (&data);
38
- }
39
- core_util_critical_section_exit ();
40
- return ;
41
- }
42
-
43
- if (_pending_fire_now || _match_check (_intf->read ())) {
35
+ if (_pending_fire_now || _match_check (_intf->read ()) || _suspended) {
44
36
_timeout.detach ();
45
37
_pending_timeout = false ;
46
38
_pending_match = false ;
@@ -78,6 +70,14 @@ void LowPowerTickerWrapper::resume()
78
70
{
79
71
core_util_critical_section_enter ();
80
72
73
+ // Wait until rescheduling is allowed
74
+ while (!_set_interrupt_allowed) {
75
+ timestamp_t current = _intf->read ();
76
+ if (((current - _last_actual_set_interrupt) & _mask) >= _min_count_between_writes) {
77
+ _set_interrupt_allowed = true ;
78
+ }
79
+ }
80
+
81
81
_suspended = false ;
82
82
83
83
core_util_critical_section_exit ();
@@ -118,7 +118,7 @@ uint32_t LowPowerTickerWrapper::read()
118
118
core_util_critical_section_enter ();
119
119
120
120
timestamp_t current = _intf->read ();
121
- if (_match_check (current)) {
121
+ if (!_suspended && _match_check (current)) {
122
122
_intf->fire_interrupt ();
123
123
}
124
124
@@ -133,7 +133,13 @@ void LowPowerTickerWrapper::set_interrupt(timestamp_t timestamp)
133
133
_last_set_interrupt = _intf->read ();
134
134
_cur_match_time = timestamp;
135
135
_pending_match = true ;
136
- _schedule_match (_last_set_interrupt);
136
+ if (!_suspended) {
137
+ _schedule_match (_last_set_interrupt);
138
+ } else {
139
+ _intf->set_interrupt (timestamp);
140
+ _last_actual_set_interrupt = _last_set_interrupt;
141
+ _set_interrupt_allowed = false ;
142
+ }
137
143
138
144
core_util_critical_section_exit ();
139
145
}
@@ -277,7 +283,7 @@ void LowPowerTickerWrapper::_schedule_match(timestamp_t current)
277
283
_intf->set_interrupt (_cur_match_time);
278
284
current = _intf->read ();
279
285
_last_actual_set_interrupt = current;
280
- _set_interrupt_allowed = false ;
286
+ _set_interrupt_allowed = false ;
281
287
282
288
// Check for overflow
283
289
uint32_t new_cycles_until_match = (_cur_match_time - current) & _mask;
0 commit comments