diff --git a/software/firmware/source/SoftRF/src/driver/EEPROM.cpp b/software/firmware/source/SoftRF/src/driver/EEPROM.cpp index 9359a7020..bbfa0938a 100644 --- a/software/firmware/source/SoftRF/src/driver/EEPROM.cpp +++ b/software/firmware/source/SoftRF/src/driver/EEPROM.cpp @@ -83,7 +83,8 @@ void EEPROM_defaults() eeprom_block.field.magic = SOFTRF_EEPROM_MAGIC; eeprom_block.field.version = SOFTRF_EEPROM_VERSION; eeprom_block.field.settings.mode = SOFTRF_MODE_NORMAL; - eeprom_block.field.settings.rf_protocol = hw_info.model == SOFTRF_MODEL_BRACELET ? + eeprom_block.field.settings.rf_protocol = hw_info.model == SOFTRF_MODEL_BRACELET || + hw_info.model == SOFTRF_MODEL_CARD ? RF_PROTOCOL_FANET : hw_info.model == SOFTRF_MODEL_ES ? RF_PROTOCOL_ADSB_1090 : diff --git a/software/firmware/source/SoftRF/src/driver/GNSS.cpp b/software/firmware/source/SoftRF/src/driver/GNSS.cpp index 4977cb310..d0ace92fc 100644 --- a/software/firmware/source/SoftRF/src/driver/GNSS.cpp +++ b/software/firmware/source/SoftRF/src/driver/GNSS.cpp @@ -1227,6 +1227,7 @@ byte GNSS_setup() { hw_info.model == SOFTRF_MODEL_PRIME_MK3 || hw_info.model == SOFTRF_MODEL_UNI || hw_info.model == SOFTRF_MODEL_BADGE || + hw_info.model == SOFTRF_MODEL_ACADEMY || hw_info.model == SOFTRF_MODEL_LEGO || hw_info.model == SOFTRF_MODEL_ES || hw_info.model == SOFTRF_MODEL_BALKAN || diff --git a/software/firmware/source/SoftRF/src/platform/EFR32.cpp b/software/firmware/source/SoftRF/src/platform/EFR32.cpp index 60e6f5dd9..34d447d48 100644 --- a/software/firmware/source/SoftRF/src/platform/EFR32.cpp +++ b/software/firmware/source/SoftRF/src/platform/EFR32.cpp @@ -19,7 +19,6 @@ #if defined(ARDUINO_ARCH_SILABS) #include -#include #include "../system/SoC.h" #include "../driver/RF.h" @@ -43,7 +42,7 @@ lmic_pinmap lmic_pins = { .rxe = LMIC_UNUSED_PIN, .rst = SOC_GPIO_PIN_RST, .dio = {LMIC_UNUSED_PIN, LMIC_UNUSED_PIN, LMIC_UNUSED_PIN}, - .busy = LMIC_UNUSED_PIN, + .busy = SOC_GPIO_PIN_BUSY, .tcxo = LMIC_UNUSED_PIN, }; @@ -112,6 +111,19 @@ eeprom_t eeprom_block; settings_t *settings = &eeprom_block.field.settings; #endif /* EXCLUDE_EEPROM */ +#if defined(USE_SOFTSPI) +#include +SoftSPI RadioSPI(SOC_GPIO_PIN_MOSI,SOC_GPIO_PIN_MISO, SOC_GPIO_PIN_SCK); +#endif /* USE_SOFTSPI */ + +#if defined __has_include +#if __has_include() +#include + +FlexWire Wire = FlexWire(SOC_GPIO_PIN_SDA, SOC_GPIO_PIN_SCL, false); +#endif /* FlexWire.h */ +#endif /* __has_include */ + static void EFR32_setup() { uint32_t reset_cause = get_system_reset_cause(); @@ -183,6 +195,10 @@ static void EFR32_setup() reset_info.reason = REASON_EXCEPTION_RST; } +#if defined(USE_RADIOLIB) + lmic_pins.dio[0] = SOC_GPIO_PIN_DIO1; +#endif /* USE_RADIOLIB */ + #if SOC_GPIO_RADIO_LED_TX != SOC_UNUSED_PIN pinMode(SOC_GPIO_RADIO_LED_TX, OUTPUT); digitalWrite(SOC_GPIO_RADIO_LED_TX, ! LED_STATE_ON); @@ -302,7 +318,25 @@ static void EFR32_loop() static void EFR32_fini(int reason) { - LowPower.attachInterruptWakeup(SOC_GPIO_PIN_BUTTON, nullptr, RISING); + switch (reason) + { +#if SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN + case SOFTRF_SHUTDOWN_BUTTON: + case SOFTRF_SHUTDOWN_LOWBAT: + /* the GPIO must have EM4 wake functionality */ + pinMode(SOC_GPIO_PIN_BUTTON, INPUT_PULLUP); + LowPower.attachInterruptWakeup(SOC_GPIO_PIN_BUTTON, nullptr, FALLING); + break; +#endif /* SOC_GPIO_PIN_BUTTON != SOC_UNUSED_PIN */ + case SOFTRF_SHUTDOWN_NMEA: + /* the GPIO must have EM4 wake functionality */ + pinMode(SOC_GPIO_PIN_BUTTON, INPUT_PULLUP); + LowPower.attachInterruptWakeup(SOC_GPIO_PIN_CONS_RX, nullptr, FALLING); + break; + default: + break; + } + LowPower.deepSleep(); } @@ -413,17 +447,15 @@ static void EFR32_EEPROM_extension(int cmd) settings->mode = SOFTRF_MODE_NORMAL; } - if (settings->nmea_out == NMEA_BLUETOOTH || - settings->nmea_out == NMEA_UDP || + if (settings->nmea_out == NMEA_USB || + settings->nmea_out == NMEA_UDP || settings->nmea_out == NMEA_TCP ) { settings->nmea_out = NMEA_UART; } - if (settings->gdl90 == GDL90_BLUETOOTH || - settings->gdl90 == GDL90_UDP) { + if (settings->gdl90 == GDL90_USB || settings->gdl90 == GDL90_UDP) { settings->gdl90 = GDL90_UART; } - if (settings->d1090 == D1090_BLUETOOTH || - settings->d1090 == D1090_UDP) { + if (settings->d1090 == D1090_USB || settings->d1090 == D1090_UDP) { settings->d1090 = D1090_UART; } @@ -436,7 +468,9 @@ static void EFR32_EEPROM_extension(int cmd) static void EFR32_SPI_begin() { +#if !defined(EXCLUDE_NRF905) || defined(USE_OGN_RF_DRIVER) SPI.begin(); +#endif } static void EFR32_swSer_begin(unsigned long baud) @@ -603,7 +637,7 @@ static void EFR32_Button_setup() int button_pin = SOC_GPIO_PIN_BUTTON; // Button(s) uses external pull up resistor. - pinMode(button_pin, INPUT); + pinMode(button_pin, INPUT_PULLUP); button_1.init(button_pin); diff --git a/software/firmware/source/SoftRF/src/platform/EFR32.h b/software/firmware/source/SoftRF/src/platform/EFR32.h index bf35e09bf..98cc47b4c 100644 --- a/software/firmware/source/SoftRF/src/platform/EFR32.h +++ b/software/firmware/source/SoftRF/src/platform/EFR32.h @@ -91,6 +91,12 @@ struct rst_info { #define SOC_GPIO_PIN_SCK PIN_SPI_SCK #define SOC_GPIO_PIN_SS PIN_SPI_SS +//#include +//extern SoftSPI RadioSPI; +//#undef SPI +//#define SPI RadioSPI +//#define USE_SOFTSPI + /* NRF905 */ #define SOC_GPIO_PIN_TXE SOC_UNUSED_PIN #define SOC_GPIO_PIN_CE SOC_UNUSED_PIN @@ -98,7 +104,7 @@ struct rst_info { /* SX1276 */ #define SOC_GPIO_PIN_RST D0 /* PA0 */ -#define SOC_GPIO_PIN_BUSY SOC_UNUSED_PIN +#define SOC_GPIO_PIN_BUSY LMIC_UNUSED_PIN #define SOC_GPIO_PIN_DIO1 D5 /* PC6 */ /* I2C */ diff --git a/software/firmware/source/libraries/OGN/manchester.h b/software/firmware/source/libraries/OGN/manchester.h index 0ea8161fa..f847d538f 100644 --- a/software/firmware/source/libraries/OGN/manchester.h +++ b/software/firmware/source/libraries/OGN/manchester.h @@ -5,7 +5,8 @@ defined(ENERGIA_ARCH_CC13XX) || defined(ENERGIA_ARCH_CC13X2) || \ (defined(ARDUINO_ARCH_RP2040) && defined(ARDUINO_ARCH_MBED)) || \ (defined(ARDUINO_ARCH_NRF52840) && defined(ARDUINO_ARCH_MBED)) || \ - defined(ARDUINO_ARCH_RENESAS) || defined(ARDUINO_ARCH_SAMD) + defined(ARDUINO_ARCH_RENESAS) || defined(ARDUINO_ARCH_SAMD) || \ + defined(ARDUINO_ARCH_SILABS) #include #endif diff --git a/software/firmware/source/libraries/SoftSPI/SoftSPI.cpp b/software/firmware/source/libraries/SoftSPI/SoftSPI.cpp index 9f89a8a91..e96a59e0c 100644 --- a/software/firmware/source/libraries/SoftSPI/SoftSPI.cpp +++ b/software/firmware/source/libraries/SoftSPI/SoftSPI.cpp @@ -3,11 +3,11 @@ #if defined(ARDUINO_ARCH_NRF52) SoftSPI::SoftSPI(uint8_t mosi, uint8_t miso, uint8_t sck) : SPIClass(NRF_SPIM0, 0, 0, 0) #elif defined(ARDUINO_ARCH_ESP32) || defined(ARDUINO_ARCH_RP2040) || \ - defined(ARDUINO_ARCH_RENESAS) + defined(ARDUINO_ARCH_RENESAS) || defined(ARDUINO_ARCH_SILABS) SoftSPI::SoftSPI(uint8_t mosi, uint8_t miso, uint8_t sck) : SPIClass() #else #error "This build architecture is not supported!" -#endif /* ARDUINO_ARCH_NRF52 || ARDUINO_ARCH_ESP32 || ARDUINO_ARCH_RP2040 */ +#endif /* NRF52 || ESP32 || RP2040 || RENESAS || SILABS */ { _mosi = mosi; _miso = miso; @@ -134,10 +134,11 @@ void SoftSPI::endTransaction(void) { } -#if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RENESAS) +#if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RENESAS) || \ + defined(ARDUINO_ARCH_SILABS) /* compatibility with Arduino RP2040 Core */ void SoftSPI::usingInterrupt(int interruptNumber) {} void SoftSPI::notUsingInterrupt(int interruptNumber) {} void SoftSPI::attachInterrupt() {} void SoftSPI::detachInterrupt() {} -#endif /* ARDUINO_ARCH_RP2040 || ARDUINO_ARCH_RENESAS */ +#endif /* RP2040 || RENESAS || SILABS */ diff --git a/software/firmware/source/libraries/SoftSPI/SoftSPI.h b/software/firmware/source/libraries/SoftSPI/SoftSPI.h index 5037371da..7b570f6aa 100644 --- a/software/firmware/source/libraries/SoftSPI/SoftSPI.h +++ b/software/firmware/source/libraries/SoftSPI/SoftSPI.h @@ -24,13 +24,14 @@ class SoftSPI : public SPIClass // Transaction Functions void beginTransaction(SPISettings settings); void endTransaction(void); -#if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RENESAS) +#if defined(ARDUINO_ARCH_RP2040) || defined(ARDUINO_ARCH_RENESAS) || \ + defined(ARDUINO_ARCH_SILABS) /* compatibility with Arduino RP2040 Core */ void usingInterrupt(int interruptNumber); void notUsingInterrupt(int interruptNumber); void attachInterrupt(); void detachInterrupt(); -#endif /* ARDUINO_ARCH_RP2040 || ARDUINO_ARCH_RENESAS */ +#endif /* RP2040 || RENESAS || SILABS */ private: uint8_t _miso; uint8_t _mosi; diff --git a/software/firmware/source/libraries/arduino-lmic/src/hal/hal.cpp b/software/firmware/source/libraries/arduino-lmic/src/hal/hal.cpp index 14659de60..9db3a84b4 100644 --- a/software/firmware/source/libraries/arduino-lmic/src/hal/hal.cpp +++ b/software/firmware/source/libraries/arduino-lmic/src/hal/hal.cpp @@ -21,12 +21,12 @@ #include #endif /* ENERGIA_ARCH_CC13XX || ENERGIA_ARCH_CC13X2 */ -#if defined(ARDUINO_ARCH_RENESAS) +#if defined(ARDUINO_ARCH_RENESAS) // || defined(ARDUINO_ARCH_SILABS) #include extern SoftSPI RadioSPI; #undef SPI #define SPI RadioSPI -#endif /* ARDUINO_ARCH_RENESAS */ +#endif /* ARDUINO_ARCH_RENESAS || ARDUINO_ARCH_SILABS */ #include "../lmic.h" #include "hal.h"