Browse Source

EventResponder cosmetic internal name change for consistency

teensy4-core
PaulStoffregen 7 years ago
parent
commit
c9a8bb6379
2 changed files with 12 additions and 12 deletions
  1. +9
    -9
      teensy3/EventResponder.cpp
  2. +3
    -3
      teensy3/EventResponder.h

+ 9
- 9
teensy3/EventResponder.cpp View File



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 {

+ 3
- 3
teensy3/EventResponder.h View File

} else { } else {
lastYield = nullptr; lastYield = nullptr;
} }
first->_pending = false;
first->_triggered = false;
(*(first->_function))(*first); (*(first->_function))(*first);
runningFromYield = false; runningFromYield = false;
} }
static void runFromInterrupt(); static void runFromInterrupt();
operator bool() { return _pending; }
operator bool() { return _triggered; }
protected: protected:
void triggerEventNotImmediate(); void triggerEventNotImmediate();
int _status = 0; int _status = 0;
EventResponder *_next = nullptr; EventResponder *_next = nullptr;
EventResponder *_prev = nullptr; EventResponder *_prev = nullptr;
EventType _type = EventTypeDetached; EventType _type = EventTypeDetached;
bool _pending = false;
bool _triggered = false;
static EventResponder *firstYield; static EventResponder *firstYield;
static EventResponder *lastYield; static EventResponder *lastYield;
static EventResponder *firstInterrupt; static EventResponder *firstInterrupt;

Loading…
Cancel
Save