The "dumb" version is just this:
A simpler version of "smart" could look like this:
I personally would be very happy with the first version, because I don't use "SerialEVents".
The additions in the 2nd Version are just for the few who use it. It needs some more tweaks in the core to toggle the bits.
You see - it is faster in any case.
Both would switch to a faster Systick version, if it is disabled, too.
Code:
void yield(void)
{
[COLOR=#00ff00] if (!_eventResponder_enabled) return;[/COLOR]
static uint8_t running=0;
if (running) return; // TODO: does this need to be atomic?
running = 1;
// USB Serail - Add hack to minimize impact...
if (usb_enable_serial_event_processing && Serial.available() ) serialEvent();
// Current workaround until integrate with EventResponder.
if (HardwareSerial::serial_event_handlers_active) HardwareSerial::processSerialEvents();
running = 0;
EventResponder::runFromYield();
};
Code:
void yield(void)
{
static uint8_t running=0;
uint32_t e = [COLOR=#00ff00]_eventResponder_flags[/COLOR]
[COLOR=#00ff00] if ( ([/COLOR][COLOR=#00ff00][COLOR=#00ff00]e & 1[/COLOR] == 0) || running) return;[/COLOR]
if ([COLOR=#00ff00][COLOR=#00ff00]e > 1) {[/COLOR][/COLOR]
running = 1;
// USB Serail - Add hack to minimize impact...
if ([COLOR=#00ff00][COLOR=#00ff00]([/COLOR][/COLOR][COLOR=#00ff00][COLOR=#00ff00]e & 0x02[/COLOR][/COLOR] ) ) serialEvent();
// Current workaround until integrate with EventResponder.
if ([COLOR=#00ff00][COLOR=#00ff00]([/COLOR][/COLOR][COLOR=#00ff00][COLOR=#00ff00]e & 0x04[/COLOR][/COLOR]) ) HardwareSerial::processSerialEvents();
[COLOR=#00ff00]}[/COLOR]
running = 0;
EventResponder::runFromYield();
};
I personally would be very happy with the first version, because I don't use "SerialEVents".
The additions in the 2nd Version are just for the few who use it. It needs some more tweaks in the core to toggle the bits.
You see - it is faster in any case.
Both would switch to a faster Systick version, if it is disabled, too.
Last edited: