From 65379c477233732a08d856462155deb64aa3ee9d Mon Sep 17 00:00:00 2001 From: jgromes Date: Fri, 25 Dec 2020 14:21:41 +0100 Subject: [PATCH] Added support for MegaCoreX --- .github/workflows/main.yml | 5 +++++ src/BuildOpt.h | 15 ++++++++++++++- src/ISerial.cpp | 4 ++++ src/ISerial.h | 9 ++++----- 4 files changed, 27 insertions(+), 6 deletions(-) diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml index a68f9450..c4a32fa6 100644 --- a/.github/workflows/main.yml +++ b/.github/workflows/main.yml @@ -29,6 +29,7 @@ jobs: - SparkFun:apollo3:amap3redboard - STM32:stm32:GenF3 - stm32duino:STM32F1:mapleMini + - MegaCoreX:megaavr:4809 runs-on: ubuntu-latest name: ${{ matrix.board }} @@ -120,6 +121,10 @@ jobs: echo "::set-output name=options:::bootloader_version=original,cpu_speed=speed_72mhz" echo "::set-output name=index-url::--additional-urls http://dan.drown.org/stm32duino/package_STM32duino_index.json" + elif [[ "${{ contains(matrix.board, 'MegaCoreX:megaavr') }}" == "true" ]]; then + # MegaCoreX + echo "::set-output name=index-url::--additional-urls https://mcudude.github.io/MegaCoreX/package_MCUdude_MegaCoreX_index.json" + fi - name: Install platform diff --git a/src/BuildOpt.h b/src/BuildOpt.h index 68fb351e..6221de31 100644 --- a/src/BuildOpt.h +++ b/src/BuildOpt.h @@ -85,7 +85,7 @@ //#define RADIOLIB_EXCLUDE_SSTV #else - #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY)) + #if defined(__AVR__) && !(defined(ARDUINO_AVR_UNO_WIFI_REV2) || defined(ARDUINO_AVR_NANO_EVERY) || defined(ARDUINO_ARCH_MEGAAVR)) // Arduino AVR boards (except for megaAVR) - Uno, Mega etc. #define RADIOLIB_PLATFORM "Arduino AVR" #define RADIOLIB_PIN_TYPE uint8_t @@ -284,6 +284,19 @@ #define RADIOLIB_SOFTWARE_SERIAL_UNSUPPORTED #define RADIOLIB_HARDWARE_SERIAL_PORT Serial1 + #elif defined(ARDUINO_ARCH_MEGAAVR) + // MegaCoreX by MCUdude (https://github.com/MCUdude/MegaCoreX) + #define RADIOLIB_PLATFORM "MegaCoreX" + #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_PROGMEM PROGMEM + #define RADIOLIB_PROGMEM_READ_BYTE(addr) pgm_read_byte(addr) + #else // other platforms not covered by the above list - this may or may not work #define RADIOLIB_PLATFORM "Unknown" diff --git a/src/ISerial.cpp b/src/ISerial.cpp index 650cfb06..7822e5c2 100644 --- a/src/ISerial.cpp +++ b/src/ISerial.cpp @@ -33,9 +33,11 @@ void ISerial::flush() { _mod->ModuleSerial->flush(); } +#ifndef ARDUINO_ARCH_MEGAAVR size_t ISerial::print(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->print(ifsh)); } +#endif size_t ISerial::print(const String &s) { return(_mod->ModuleSerial->print(s)); @@ -77,9 +79,11 @@ size_t ISerial::print(const Printable& x) { return(_mod->ModuleSerial->print(x)); } +#ifndef ARDUINO_ARCH_MEGAAVR size_t ISerial::println(const __FlashStringHelper *ifsh) { return(_mod->ModuleSerial->println(ifsh)); } +#endif size_t ISerial::println(const String &s) { return(_mod->ModuleSerial->println(s)); diff --git a/src/ISerial.h b/src/ISerial.h index 0029234e..d34ff09d 100644 --- a/src/ISerial.h +++ b/src/ISerial.h @@ -3,11 +3,6 @@ #include "Module.h" -#include - -#include "WString.h" -#include "Printable.h" - /*! \class ISerial @@ -25,7 +20,9 @@ class ISerial { int available(); void flush(); + #ifndef ARDUINO_ARCH_MEGAAVR size_t print(const __FlashStringHelper *); + #endif size_t print(const String &); size_t print(const char[]); size_t print(char); @@ -37,7 +34,9 @@ class ISerial { size_t print(double, int = 2); size_t print(const Printable&); + #ifndef ARDUINO_ARCH_MEGAAVR size_t println(const __FlashStringHelper *); + #endif size_t println(const String &s); size_t println(const char[]); size_t println(char);