@@ -168,6 +168,7 @@ public: | |||
virtual size_t write9bit(uint32_t c) { serial_putchar(c); return 1; } | |||
}; | |||
extern HardwareSerial Serial1; | |||
extern void serialEvent1(void); | |||
class HardwareSerial2 : public HardwareSerial | |||
{ | |||
@@ -195,6 +196,7 @@ public: | |||
virtual size_t write9bit(uint32_t c) { serial2_putchar(c); return 1; } | |||
}; | |||
extern HardwareSerial2 Serial2; | |||
extern void serialEvent2(void); | |||
class HardwareSerial3 : public HardwareSerial | |||
{ | |||
@@ -222,6 +224,7 @@ public: | |||
virtual size_t write9bit(uint32_t c) { serial3_putchar(c); return 1; } | |||
}; | |||
extern HardwareSerial3 Serial3; | |||
extern void serialEvent3(void); | |||
#endif | |||
#endif |
@@ -2,3 +2,5 @@ | |||
HardwareSerial Serial1; | |||
void serialEvent1() __attribute__((weak)); | |||
void serialEvent1() {} |
@@ -2,3 +2,5 @@ | |||
HardwareSerial2 Serial2; | |||
void serialEvent2() __attribute__((weak)); | |||
void serialEvent2() {} |
@@ -2,3 +2,5 @@ | |||
HardwareSerial3 Serial3; | |||
void serialEvent3() __attribute__((weak)); | |||
void serialEvent3() {} |
@@ -77,3 +77,6 @@ usb_seremu_class Serial; | |||
#endif | |||
#endif // F_CPU | |||
void serialEvent() __attribute__((weak)); | |||
void serialEvent() {} |
@@ -84,6 +84,7 @@ public: | |||
operator bool() { return usb_configuration; } | |||
}; | |||
extern usb_seremu_class Serial; | |||
extern void serialEvent(void); | |||
#endif // __cplusplus | |||
@@ -120,6 +121,7 @@ public: | |||
}; | |||
extern usb_seremu_class Serial; | |||
extern void serialEvent(void); | |||
#endif // __cplusplus | |||
@@ -100,6 +100,7 @@ public: | |||
}; | |||
extern usb_serial_class Serial; | |||
extern void serialEvent(void); | |||
#endif // __cplusplus | |||
@@ -135,6 +136,7 @@ public: | |||
}; | |||
extern usb_serial_class Serial; | |||
extern void serialEvent(void); | |||
#endif // __cplusplus | |||
#endif // F_CPU |
@@ -1,6 +1,6 @@ | |||
/* Teensyduino Core Library | |||
* http://www.pjrc.com/teensy/ | |||
* Copyright (c) 2013 PJRC.COM, LLC. | |||
* Copyright (c) 2014 PJRC.COM, LLC. | |||
* | |||
* Permission is hereby granted, free of charge, to any person obtaining | |||
* a copy of this software and associated documentation files (the | |||
@@ -28,5 +28,21 @@ | |||
* SOFTWARE. | |||
*/ | |||
#include "core_pins.h" | |||
#include "HardwareSerial.h" | |||
#include "usb_serial.h" | |||
#include "usb_seremu.h" | |||
void yield(void) __attribute__ ((weak)); | |||
void yield(void) {}; | |||
void yield(void) | |||
{ | |||
static uint8_t running=0; | |||
if (running) return; // TODO: does this need to be atomic? | |||
running = 1; | |||
if (Serial.available()) serialEvent(); | |||
if (Serial1.available()) serialEvent1(); | |||
if (Serial2.available()) serialEvent2(); | |||
if (Serial3.available()) serialEvent3(); | |||
running = 0; | |||
}; |