virtual size_t write9bit(uint32_t c) { serial_putchar(c); return 1; } | virtual size_t write9bit(uint32_t c) { serial_putchar(c); return 1; } | ||||
}; | }; | ||||
extern HardwareSerial Serial1; | extern HardwareSerial Serial1; | ||||
extern void serialEvent1(void); | |||||
class HardwareSerial2 : public HardwareSerial | class HardwareSerial2 : public HardwareSerial | ||||
{ | { | ||||
virtual size_t write9bit(uint32_t c) { serial2_putchar(c); return 1; } | virtual size_t write9bit(uint32_t c) { serial2_putchar(c); return 1; } | ||||
}; | }; | ||||
extern HardwareSerial2 Serial2; | extern HardwareSerial2 Serial2; | ||||
extern void serialEvent2(void); | |||||
class HardwareSerial3 : public HardwareSerial | class HardwareSerial3 : public HardwareSerial | ||||
{ | { | ||||
virtual size_t write9bit(uint32_t c) { serial3_putchar(c); return 1; } | virtual size_t write9bit(uint32_t c) { serial3_putchar(c); return 1; } | ||||
}; | }; | ||||
extern HardwareSerial3 Serial3; | extern HardwareSerial3 Serial3; | ||||
extern void serialEvent3(void); | |||||
#endif | #endif | ||||
#endif | #endif |
HardwareSerial Serial1; | HardwareSerial Serial1; | ||||
void serialEvent1() __attribute__((weak)); | |||||
void serialEvent1() {} |
HardwareSerial2 Serial2; | HardwareSerial2 Serial2; | ||||
void serialEvent2() __attribute__((weak)); | |||||
void serialEvent2() {} |
HardwareSerial3 Serial3; | HardwareSerial3 Serial3; | ||||
void serialEvent3() __attribute__((weak)); | |||||
void serialEvent3() {} |
#endif | #endif | ||||
#endif // F_CPU | #endif // F_CPU | ||||
void serialEvent() __attribute__((weak)); | |||||
void serialEvent() {} |
operator bool() { return usb_configuration; } | operator bool() { return usb_configuration; } | ||||
}; | }; | ||||
extern usb_seremu_class Serial; | extern usb_seremu_class Serial; | ||||
extern void serialEvent(void); | |||||
#endif // __cplusplus | #endif // __cplusplus | ||||
}; | }; | ||||
extern usb_seremu_class Serial; | extern usb_seremu_class Serial; | ||||
extern void serialEvent(void); | |||||
#endif // __cplusplus | #endif // __cplusplus | ||||
}; | }; | ||||
extern usb_serial_class Serial; | extern usb_serial_class Serial; | ||||
extern void serialEvent(void); | |||||
#endif // __cplusplus | #endif // __cplusplus | ||||
}; | }; | ||||
extern usb_serial_class Serial; | extern usb_serial_class Serial; | ||||
extern void serialEvent(void); | |||||
#endif // __cplusplus | #endif // __cplusplus | ||||
#endif // F_CPU | #endif // F_CPU |
/* Teensyduino Core Library | /* Teensyduino Core Library | ||||
* http://www.pjrc.com/teensy/ | * 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 | * Permission is hereby granted, free of charge, to any person obtaining | ||||
* a copy of this software and associated documentation files (the | * a copy of this software and associated documentation files (the | ||||
* SOFTWARE. | * SOFTWARE. | ||||
*/ | */ | ||||
#include "core_pins.h" | |||||
#include "HardwareSerial.h" | |||||
#include "usb_serial.h" | |||||
#include "usb_seremu.h" | |||||
void yield(void) __attribute__ ((weak)); | 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; | |||||
}; |