|
|
|
|
|
|
|
|
|
|
|
|
|
|
void EventResponder::triggerEventNotImmediate() |
|
|
void EventResponder::triggerEventNotImmediate() |
|
|
{ |
|
|
{ |
|
|
if (_pending) { |
|
|
|
|
|
|
|
|
if (_triggered) { |
|
|
// already triggered |
|
|
// already triggered |
|
|
return; |
|
|
return; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
_prev->_next = this; |
|
|
_prev->_next = this; |
|
|
lastYield = this; |
|
|
lastYield = this; |
|
|
} |
|
|
} |
|
|
_pending = true; |
|
|
|
|
|
|
|
|
_triggered = true; |
|
|
} else if (_type == EventTypeInterrupt) { |
|
|
} else if (_type == EventTypeInterrupt) { |
|
|
// interrupt, called from software interrupt |
|
|
// interrupt, called from software interrupt |
|
|
if (firstInterrupt == nullptr) { |
|
|
if (firstInterrupt == nullptr) { |
|
|
|
|
|
|
|
|
_prev->_next = this; |
|
|
_prev->_next = this; |
|
|
lastInterrupt = this; |
|
|
lastInterrupt = this; |
|
|
} |
|
|
} |
|
|
_pending = true; |
|
|
|
|
|
|
|
|
_triggered = true; |
|
|
SCB_ICSR = SCB_ICSR_PENDSVSET; // set PendSV interrupt |
|
|
SCB_ICSR = SCB_ICSR_PENDSVSET; // set PendSV interrupt |
|
|
} else { |
|
|
} else { |
|
|
// detached, easy :-) |
|
|
// detached, easy :-) |
|
|
_pending = true; |
|
|
|
|
|
|
|
|
_triggered = true; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
} else { |
|
|
} else { |
|
|
lastInterrupt = nullptr; |
|
|
lastInterrupt = nullptr; |
|
|
} |
|
|
} |
|
|
first->_pending = false; |
|
|
|
|
|
|
|
|
first->_triggered = false; |
|
|
(*(first->_function))(*first); |
|
|
(*(first->_function))(*first); |
|
|
} else { |
|
|
} else { |
|
|
break; |
|
|
break; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
bool EventResponder::clearEvent() |
|
|
bool EventResponder::clearEvent() |
|
|
{ |
|
|
{ |
|
|
if (_pending) { |
|
|
|
|
|
|
|
|
if (_triggered) { |
|
|
if (_type == EventTypeYield) { |
|
|
if (_type == EventTypeYield) { |
|
|
if (_prev) { |
|
|
if (_prev) { |
|
|
_prev->_next = _next; |
|
|
_prev->_next = _next; |
|
|
|
|
|
|
|
|
lastInterrupt = _prev; |
|
|
lastInterrupt = _prev; |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
_pending = false; |
|
|
|
|
|
|
|
|
_triggered = false; |
|
|
return true; |
|
|
return true; |
|
|
} |
|
|
} |
|
|
return false; |
|
|
return false; |
|
|
|
|
|
|
|
|
void EventResponder::detach() |
|
|
void EventResponder::detach() |
|
|
{ |
|
|
{ |
|
|
if (_type == EventTypeYield) { |
|
|
if (_type == EventTypeYield) { |
|
|
if (_pending) { |
|
|
|
|
|
|
|
|
if (_triggered) { |
|
|
if (_prev) { |
|
|
if (_prev) { |
|
|
_prev->_next = _next; |
|
|
_prev->_next = _next; |
|
|
} else { |
|
|
} else { |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
_type = EventTypeDetached; |
|
|
_type = EventTypeDetached; |
|
|
} else if (_type == EventTypeInterrupt) { |
|
|
} else if (_type == EventTypeInterrupt) { |
|
|
if (_pending) { |
|
|
|
|
|
|
|
|
if (_triggered) { |
|
|
if (_prev) { |
|
|
if (_prev) { |
|
|
_prev->_next = _next; |
|
|
_prev->_next = _next; |
|
|
} else { |
|
|
} else { |