Browse Source

Add serialEvent (USB) and serialEvent1-3 (serial)

teensy4-core
PaulStoffregen 10 years ago
parent
commit
4c047eea2b
8 changed files with 34 additions and 2 deletions
  1. +3
    -0
      teensy3/HardwareSerial.h
  2. +2
    -0
      teensy3/HardwareSerial1.cpp
  3. +2
    -0
      teensy3/HardwareSerial2.cpp
  4. +2
    -0
      teensy3/HardwareSerial3.cpp
  5. +3
    -0
      teensy3/usb_inst.cpp
  6. +2
    -0
      teensy3/usb_seremu.h
  7. +2
    -0
      teensy3/usb_serial.h
  8. +18
    -2
      teensy3/yield.cpp

+ 3
- 0
teensy3/HardwareSerial.h View File

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

+ 2
- 0
teensy3/HardwareSerial1.cpp View File



HardwareSerial Serial1; HardwareSerial Serial1;


void serialEvent1() __attribute__((weak));
void serialEvent1() {}

+ 2
- 0
teensy3/HardwareSerial2.cpp View File



HardwareSerial2 Serial2; HardwareSerial2 Serial2;


void serialEvent2() __attribute__((weak));
void serialEvent2() {}

+ 2
- 0
teensy3/HardwareSerial3.cpp View File



HardwareSerial3 Serial3; HardwareSerial3 Serial3;


void serialEvent3() __attribute__((weak));
void serialEvent3() {}

+ 3
- 0
teensy3/usb_inst.cpp View File

#endif #endif


#endif // F_CPU #endif // F_CPU

void serialEvent() __attribute__((weak));
void serialEvent() {}

+ 2
- 0
teensy3/usb_seremu.h View File

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





+ 2
- 0
teensy3/usb_serial.h View File



}; };
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

teensy3/yield.c → teensy3/yield.cpp View File

/* 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;
};

Loading…
Cancel
Save