The code for T3.x was broken, especially for USB2... And the code was not setup for T4.x. So added it.main
@@ -2000,9 +2000,11 @@ void _restart_Teensyduino_(void) __attribute__((noreturn)); | |||
// Probably should be in a better spot. | |||
extern uint8_t yield_active_check_flags; | |||
#define YIELD_CHECK_USB_SERIAL 0x1 // check the USB for Serial.available() | |||
#define YIELD_CHECK_USB_SERIAL 0x1 // check the USB for Serial.available() | |||
#define YIELD_CHECK_HARDWARE_SERIAL 0x2 // check Hardware Serial ports available | |||
#define YIELD_CHECK_EVENT_RESPONDER 0x4 // User has created eventResponders that use yield | |||
#define YIELD_CHECK_USB_SERIALUSB1 0x8 // Check for SerialUSB1 | |||
#define YIELD_CHECK_USB_SERIALUSB2 0x10 // Check for SerialUSB2 | |||
void yield(void); | |||
@@ -0,0 +1,5 @@ | |||
#include <Arduino.h> | |||
void serialEventUSB1() __attribute__((weak)); | |||
void serialEventUSB1() {} | |||
uint8_t _serialEventUSB1_default PROGMEM = 1; |
@@ -0,0 +1,5 @@ | |||
#include <Arduino.h> | |||
void serialEventUSB2() __attribute__((weak)); | |||
void serialEventUSB2() {} | |||
uint8_t _serialEventUSB2_default PROGMEM = 1; |
@@ -97,10 +97,3 @@ usb_seremu_class Serial; | |||
#endif | |||
#endif // F_CPU | |||
//void serialEvent() __attribute__((weak)); | |||
//void serialEvent() {} | |||
void serialEventUSB1() __attribute__((weak)); | |||
void serialEventUSB1() {} | |||
void serialEventUSB2() __attribute__((weak)); | |||
void serialEventUSB2() {} |
@@ -33,11 +33,17 @@ | |||
#ifdef USB_TRIPLE_SERIAL | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1 | YIELD_CHECK_USB_SERIALUSB2; // default to check USB. | |||
extern const uint8_t _serialEventUSB2_default; | |||
extern const uint8_t _serialEventUSB1_default; | |||
#elif defined(USB_DUAL_SERIAL) | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1; // default to check USB. | |||
extern const uint8_t _serialEventUSB1_default; | |||
#else | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL; // default to check USB. | |||
#endif | |||
extern const uint8_t _serialEvent_default; | |||
void yield(void) __attribute__ ((weak)); | |||
@@ -64,7 +70,7 @@ void yield(void) | |||
#endif | |||
#ifdef USB_TRIPLE_SERIAL | |||
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB2) { | |||
if (SerialUSB1.available()) serialEventUSB1(); | |||
if (SerialUSB2.available()) serialEventUSB2(); | |||
if (_serialEventUSB2_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB2; | |||
} | |||
#endif |
@@ -43,6 +43,8 @@ bool EventResponder::runningFromYield = false; | |||
// TODO: interrupt disable/enable needed in many places!!! | |||
// BUGBUG: See if file name order makes difference? | |||
uint8_t _serialEvent_default __attribute__((weak)) PROGMEM = 0 ; | |||
uint8_t _serialEventUSB1_default __attribute__((weak)) PROGMEM = 0 ; | |||
uint8_t _serialEventUSB2_default __attribute__((weak)) PROGMEM = 0 ; | |||
void EventResponder::triggerEventNotImmediate() | |||
{ |
@@ -1548,9 +1548,13 @@ void _restart_Teensyduino_(void) __attribute__((noreturn)); | |||
// Define a set of flags to know which things yield should check when called. | |||
extern uint8_t yield_active_check_flags; | |||
#define YIELD_CHECK_USB_SERIAL 0x1 // check the USB for Serial.available() | |||
#define YIELD_CHECK_USB_SERIAL 0x1 // check the USB for Serial.available() | |||
#define YIELD_CHECK_HARDWARE_SERIAL 0x2 // check Hardware Serial ports available | |||
#define YIELD_CHECK_EVENT_RESPONDER 0x4 // User has created eventResponders that use yield | |||
#define YIELD_CHECK_USB_SERIALUSB1 0x8 // Check for SerialUSB1 | |||
#define YIELD_CHECK_USB_SERIALUSB2 0x10 // Check for SerialUSB2 | |||
void yield(void); | |||
void delay(uint32_t msec); |
@@ -0,0 +1,5 @@ | |||
#include <Arduino.h> | |||
void serialEventUSB1() __attribute__((weak)); | |||
void serialEventUSB1() {} | |||
uint8_t _serialEventUSB1_default PROGMEM = 1; |
@@ -0,0 +1,5 @@ | |||
#include <Arduino.h> | |||
void serialEventUSB2() __attribute__((weak)); | |||
void serialEventUSB2() {} | |||
uint8_t _serialEventUSB2_default PROGMEM = 1; |
@@ -31,7 +31,19 @@ | |||
#include <Arduino.h> | |||
#include "EventResponder.h" | |||
#ifdef USB_TRIPLE_SERIAL | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1 | YIELD_CHECK_USB_SERIALUSB2; // default to check USB. | |||
extern const uint8_t _serialEventUSB2_default; | |||
extern const uint8_t _serialEventUSB1_default; | |||
#elif defined(USB_DUAL_SERIAL) | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL | YIELD_CHECK_USB_SERIALUSB1; // default to check USB. | |||
extern const uint8_t _serialEventUSB1_default; | |||
#else | |||
uint8_t yield_active_check_flags = YIELD_CHECK_USB_SERIAL; // default to check USB. | |||
#endif | |||
extern const uint8_t _serialEvent_default; | |||
void yield(void) __attribute__ ((weak)); | |||
@@ -49,6 +61,19 @@ void yield(void) | |||
if (_serialEvent_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIAL; | |||
} | |||
#if defined(USB_DUAL_SERIAL) || defined(USB_TRIPLE_SERIAL) | |||
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB1) { | |||
if (SerialUSB1.available()) serialEventUSB1(); | |||
if (_serialEventUSB1_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB1; | |||
} | |||
#endif | |||
#ifdef USB_TRIPLE_SERIAL | |||
if (yield_active_check_flags & YIELD_CHECK_USB_SERIALUSB2) { | |||
if (SerialUSB2.available()) serialEventUSB2(); | |||
if (_serialEventUSB2_default) yield_active_check_flags &= ~YIELD_CHECK_USB_SERIALUSB2; | |||
} | |||
#endif | |||
// Current workaround until integrate with EventResponder. | |||
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) HardwareSerial::processSerialEventsList(); | |||