Ver código fonte

Merge pull request #477 from KurtE/serialEventUSB1_serialEventUSB2

Fix/Add seralEventUSB1 and serialEventUSB2
main
Paul Stoffregen 4 anos atrás
pai
commit
cc025d05bd
Nenhuma conta vinculada ao e-mail do autor do commit
10 arquivos alterados com 62 adições e 10 exclusões
  1. +3
    -1
      teensy3/core_pins.h
  2. +5
    -0
      teensy3/serialEventUSB1.cpp
  3. +5
    -0
      teensy3/serialEventUSB2.cpp
  4. +0
    -7
      teensy3/usb_inst.cpp
  5. +7
    -1
      teensy3/yield.cpp
  6. +2
    -0
      teensy4/EventResponder.cpp
  7. +5
    -1
      teensy4/core_pins.h
  8. +5
    -0
      teensy4/serialEventUSB1.cpp
  9. +5
    -0
      teensy4/serialEventUSB2.cpp
  10. +25
    -0
      teensy4/yield.cpp

+ 3
- 1
teensy3/core_pins.h Ver arquivo

@@ -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);


+ 5
- 0
teensy3/serialEventUSB1.cpp Ver arquivo

@@ -0,0 +1,5 @@

#include <Arduino.h>
void serialEventUSB1() __attribute__((weak));
void serialEventUSB1() {}
uint8_t _serialEventUSB1_default PROGMEM = 1;

+ 5
- 0
teensy3/serialEventUSB2.cpp Ver arquivo

@@ -0,0 +1,5 @@

#include <Arduino.h>
void serialEventUSB2() __attribute__((weak));
void serialEventUSB2() {}
uint8_t _serialEventUSB2_default PROGMEM = 1;

+ 0
- 7
teensy3/usb_inst.cpp Ver arquivo

@@ -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() {}

+ 7
- 1
teensy3/yield.cpp Ver arquivo

@@ -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

+ 2
- 0
teensy4/EventResponder.cpp Ver arquivo

@@ -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()
{

+ 5
- 1
teensy4/core_pins.h Ver arquivo

@@ -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);

+ 5
- 0
teensy4/serialEventUSB1.cpp Ver arquivo

@@ -0,0 +1,5 @@

#include <Arduino.h>
void serialEventUSB1() __attribute__((weak));
void serialEventUSB1() {}
uint8_t _serialEventUSB1_default PROGMEM = 1;

+ 5
- 0
teensy4/serialEventUSB2.cpp Ver arquivo

@@ -0,0 +1,5 @@

#include <Arduino.h>
void serialEventUSB2() __attribute__((weak));
void serialEventUSB2() {}
uint8_t _serialEventUSB2_default PROGMEM = 1;

+ 25
- 0
teensy4/yield.cpp Ver arquivo

@@ -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();


Carregando…
Cancelar
Salvar