Skip to content

Commit

Permalink
Allow to disable peripheral integration via define
Browse files Browse the repository at this point in the history
  • Loading branch information
tsandmann committed Aug 19, 2023
1 parent 20a2bfb commit 48e35f1
Show file tree
Hide file tree
Showing 4 changed files with 16 additions and 13 deletions.
2 changes: 1 addition & 1 deletion example/blink/platformio.ini
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@ platform = https://github.com/tsandmann/platform-teensy.git
board = teensy41
framework = arduino
lib_deps = https://github.com/tsandmann/freertos-teensy.git
build_flags = -Wformat=1 -DUSB_SERIAL -DTEENSY_OPT_FASTER_LTO
build_flags = -Wformat=1
upload_flags = -v
upload_protocol = teensy-cli
19 changes: 7 additions & 12 deletions src/arduino_freertos.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,23 +33,14 @@

#include "FreeRTOS.h"
#include "task.h"
#include "HardwareSerial.h"
#include "Arduino.h"
#include "Print.h"
#if defined(__has_include) && __has_include("Wire.h")
#include "Wire.h"
#else
class TwoWire;
class Wire;
class Wire1;
class Wire2;
class Wire3;
#endif
#if defined(__has_include) && __has_include("SPI.h")
#include "SPI.h"
#else
class SPI;
class SPI1;
class SPI2;
#endif
#if defined(__has_include) && __has_include("FS.h")
#include "FS.h"
Expand Down Expand Up @@ -132,8 +123,9 @@ using ::micros;
using ::millis;
using ::yield;

using ::HardwareSerial;
using ::Serial;
#if !defined DISABLE_ARDUINO_HWSERIAL
using ::HardwareSerial;
using ::Serial1;
using ::Serial2;
using ::Serial3;
Expand All @@ -146,19 +138,22 @@ using ::Serial7;
#ifdef ARDUINO_TEENSY41
using ::Serial8;
#endif
#if defined(__has_include) && __has_include("SPI.h")
#endif // !DISABLE_ARDUINO_HWSERIAL
#if defined(__has_include) && __has_include("SPI.h") && !defined DISABLE_ARDUINO_SPI
using ::SPI;
using ::SPI1;
using ::SPI2;
#endif // SPI.h
using ::Stream;
#if defined(__has_include) && __has_include("Wire.h") && !defined DISABLE_ARDUINO_WIRE
using ::TwoWire;
using ::Wire;
using ::Wire1;
using ::Wire2;
#ifdef WIRE_IMPLEMENT_WIRE3
using ::Wire3;
#endif
#endif // Wire.h

using ::String;

Expand Down
4 changes: 4 additions & 0 deletions src/portable/teensy_3.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -115,9 +115,13 @@ void yield() {
}
}
#endif // USB_TRIPLE_SERIAL

#if !defined DISABLE_ARDUINO_HWSERIAL
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) {
HardwareSerial::processSerialEventsList();
}
#endif // !DISABLE_ARDUINO_HWSERIAL

running = 0;
if (yield_active_check_flags & YIELD_CHECK_EVENT_RESPONDER) {
EventResponder::runFromYield();
Expand Down
4 changes: 4 additions & 0 deletions src/portable/teensy_4.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -131,10 +131,12 @@ FLASHMEM void yield() {
}
#endif // USB_TRIPLE_SERIAL

#if !defined DISABLE_ARDUINO_HWSERIAL
// Current workaround until integrate with EventResponder.
if (yield_active_check_flags & YIELD_CHECK_HARDWARE_SERIAL) {
HardwareSerial::processSerialEventsList();
}
#endif // !DISABLE_ARDUINO_HWSERIAL

running = 0;
if (yield_active_check_flags & YIELD_CHECK_EVENT_RESPONDER) {
Expand Down Expand Up @@ -177,10 +179,12 @@ FLASHMEM void yield() {
}
#endif // USB_TRIPLE_SERIAL

#if !defined DISABLE_ARDUINO_HWSERIAL
// Current workaround until integrate with EventResponder.
if (check_flags & YIELD_CHECK_HARDWARE_SERIAL) {
HardwareSerial::processSerialEventsList();
}
#endif // !DISABLE_ARDUINO_HWSERIAL

running = 0;
if (check_flags & YIELD_CHECK_EVENT_RESPONDER) {
Expand Down

0 comments on commit 48e35f1

Please sign in to comment.