From 6b83e08cfaa25ce520ee98da1bc68f8d70172a49 Mon Sep 17 00:00:00 2001 From: jgromes Date: Sun, 12 Jun 2022 19:31:15 +0200 Subject: [PATCH] Added support for Teensy (#175) --- .github/workflows/main.yml | 5 +++++ README.md | 3 +++ src/BuildOpt.h | 36 +++++++++++++++++++++++++++++++++++- 3 files changed, 43 insertions(+), 1 deletion(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index c1e134c3..bb7d6d52 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -33,6 +33,7 @@ jobs: - arduino:mbed_rp2040:pico - CubeCell:CubeCell:CubeCell-Board - MegaCore:avr:1281 + - teensy:avr:teensy41 runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -137,6 +138,10 @@ jobs: # MegaCore echo "::set-output name=index-url::--additional-urls https://mcudude.github.io/MegaCore/package_MCUdude_MegaCore_index.json" + elif [[ "${{ contains(matrix.board, 'teensy:avr') }}" == "true" ]]; then + # Teensy + echo "::set-output name=index-url::--additional-urls https://www.pjrc.com/teensy/td_156/package_teensy_index.json" + fi - name: Install platform diff --git a/README.md b/README.md index 6229160f..cd61be2f 100644 --- a/README.md +++ b/README.md @@ -75,6 +75,9 @@ SX127x, RFM9x, SX126x, RF69, SX1231, CC1101, nRF24L01, RFM2x, Si443x and SX128x * __Heltec__ * [__CubeCell__](https://github.com/HelTecAutomation/CubeCell-Arduino) - ASR650X series (CubeCell-Board, CubeCell-Capsule, CubeCell-Module etc.) +* __PJRC__ + * [__Teensy__](https://github.com/PaulStoffregen/cores) - Teensy 2.x, 3.x and 4.x boards + The list above is by no means exhaustive - RadioLib code is independent of the used platform! Compilation of all examples is tested for all platforms officially supported prior to releasing new version. ### In development: diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 143e274e..29e80d2d 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -734,7 +734,7 @@ #undef yield #endif -#elif defined(RASPI) + #elif defined(RASPI) // RaspiDuino framework (https://github.com/me-no-dev/RasPiArduino) #define RADIOLIB_PLATFORM "RasPiArduino" #define RADIOLIB_PIN_TYPE uint8_t @@ -788,6 +788,40 @@ inline unsigned long micros() { return((unsigned long)(STCV)); }; #endif + #elif defined(TEENSYDUINO) + // Teensy + #define RADIOLIB_PLATFORM "Teensy" + #define RADIOLIB_PIN_TYPE uint8_t + #define RADIOLIB_PIN_MODE uint8_t + #define RADIOLIB_PIN_STATUS uint8_t + #define RADIOLIB_INTERRUPT_STATUS RADIOLIB_PIN_STATUS + #define RADIOLIB_DIGITAL_PIN_TO_INTERRUPT(p) digitalPinToInterrupt(p) + #define RADIOLIB_NC (0xFF) + #define RADIOLIB_DEFAULT_SPI SPI + #define RADIOLIB_DEFAULT_SPI_SETTINGS SPISettings(2000000, MSBFIRST, SPI_MODE0) + #define RADIOLIB_NONVOLATILE PROGMEM + #define RADIOLIB_NONVOLATILE_READ_BYTE(addr) pgm_read_byte(addr) + #define RADIOLIB_TYPE_ALIAS(type, alias) using alias = type; + + // Arduino API callbacks + #define RADIOLIB_CB_ARGS_PIN_MODE (void, pinMode, uint8_t pin, uint8_t mode) + #define RADIOLIB_CB_ARGS_DIGITAL_WRITE (void, digitalWrite, uint8_t pin, uint8_t value) + #define RADIOLIB_CB_ARGS_DIGITAL_READ (uint8_t, digitalRead, uint8_t pin) + #define RADIOLIB_CB_ARGS_TONE (void, tone, uint8_t _pin, short unsigned int frequency, long unsigned int duration) + #define RADIOLIB_CB_ARGS_NO_TONE (void, noTone, uint8_t _pin) + #define RADIOLIB_CB_ARGS_ATTACH_INTERRUPT (void, attachInterrupt, uint8_t interruptNum, void (*userFunc)(void), int mode) + #define RADIOLIB_CB_ARGS_DETACH_INTERRUPT (void, detachInterrupt, uint8_t interruptNum) + #define RADIOLIB_CB_ARGS_YIELD (void, yield, void) + #define RADIOLIB_CB_ARGS_DELAY (void, delay, unsigned long ms) + #define RADIOLIB_CB_ARGS_DELAY_MICROSECONDS (void, delayMicroseconds, long unsigned int us) + #define RADIOLIB_CB_ARGS_MILLIS (unsigned long, millis, void) + #define RADIOLIB_CB_ARGS_MICROS (unsigned long, micros, void) + #define RADIOLIB_CB_ARGS_SPI_BEGIN (void, SPIbegin, void) + #define RADIOLIB_CB_ARGS_SPI_BEGIN_TRANSACTION (void, SPIbeginTransaction, void) + #define RADIOLIB_CB_ARGS_SPI_TRANSFER (uint8_t, SPItransfer, uint8_t b) + #define RADIOLIB_CB_ARGS_SPI_END_TRANSACTION (void, SPIendTransaction, void) + #define RADIOLIB_CB_ARGS_SPI_END (void, SPIend, void) + #else // other Arduino platforms not covered by the above list - this may or may not work #define RADIOLIB_PLATFORM "Unknown Arduino"