|
|
|
@ -15,7 +15,6 @@ |
|
|
|
|
|
|
|
|
|
#include "ROM.h" |
|
|
|
|
#include "Boards.h" |
|
|
|
|
#include "Modem.h" |
|
|
|
|
|
|
|
|
|
#ifndef CONFIG_H |
|
|
|
|
#define CONFIG_H |
|
|
|
@ -46,333 +45,16 @@ |
|
|
|
|
bool console_active = false; |
|
|
|
|
bool modem_installed = false; |
|
|
|
|
|
|
|
|
|
#if defined(__AVR_ATmega1284P__) |
|
|
|
|
#define PLATFORM PLATFORM_AVR |
|
|
|
|
#define MCU_VARIANT MCU_1284P |
|
|
|
|
#elif defined(__AVR_ATmega2560__) |
|
|
|
|
#define PLATFORM PLATFORM_AVR |
|
|
|
|
#define MCU_VARIANT MCU_2560 |
|
|
|
|
#elif defined(ESP32) |
|
|
|
|
#define PLATFORM PLATFORM_ESP32 |
|
|
|
|
#define MCU_VARIANT MCU_ESP32 |
|
|
|
|
#elif defined(NRF52840_XXAA) |
|
|
|
|
#define PLATFORM PLATFORM_NRF52 |
|
|
|
|
#define MCU_VARIANT MCU_NRF52 |
|
|
|
|
#else |
|
|
|
|
#error "The firmware cannot be compiled for the selected MCU variant" |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#define MTU 508 |
|
|
|
|
#define SINGLE_MTU 255 |
|
|
|
|
#define HEADER_L 1 |
|
|
|
|
#define MIN_L 1 |
|
|
|
|
|
|
|
|
|
#define CMD_L 64 |
|
|
|
|
|
|
|
|
|
// MCU dependent configuration parameters
|
|
|
|
|
|
|
|
|
|
#define HAS_DISPLAY false |
|
|
|
|
#define HAS_BLUETOOTH false |
|
|
|
|
#define HAS_TCXO false |
|
|
|
|
#define HAS_PMU false |
|
|
|
|
#define HAS_NP false |
|
|
|
|
#define HAS_EEPROM false |
|
|
|
|
|
|
|
|
|
#if defined(ENABLE_TCXO) |
|
|
|
|
#define HAS_TCXO true |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if MCU_VARIANT == MCU_1284P |
|
|
|
|
const int pin_cs = 4; |
|
|
|
|
const int pin_reset = 3; |
|
|
|
|
const int pin_dio = 2; |
|
|
|
|
const int pin_led_rx = 12; |
|
|
|
|
const int pin_led_tx = 13; |
|
|
|
|
|
|
|
|
|
#define BOARD_MODEL BOARD_RNODE |
|
|
|
|
|
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
|
|
|
|
|
#define CONFIG_UART_BUFFER_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 200 |
|
|
|
|
|
|
|
|
|
#define EEPROM_SIZE 4096 |
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED |
|
|
|
|
|
|
|
|
|
#elif MCU_VARIANT == MCU_2560 |
|
|
|
|
const int pin_cs = 5; |
|
|
|
|
const int pin_reset = 4; |
|
|
|
|
const int pin_dio = 2; |
|
|
|
|
const int pin_led_rx = 12; |
|
|
|
|
const int pin_led_tx = 13; |
|
|
|
|
|
|
|
|
|
#define BOARD_MODEL BOARD_HMBRW |
|
|
|
|
|
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
|
|
|
|
|
#define CONFIG_UART_BUFFER_SIZE 768 |
|
|
|
|
#define CONFIG_QUEUE_SIZE 5120 |
|
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 24 |
|
|
|
|
|
|
|
|
|
#define EEPROM_SIZE 4096 |
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED |
|
|
|
|
|
|
|
|
|
#elif MCU_VARIANT == MCU_ESP32 |
|
|
|
|
|
|
|
|
|
// Board models for ESP32 based builds are
|
|
|
|
|
// defined by the build target in the makefile.
|
|
|
|
|
// If you are not using make to compile this
|
|
|
|
|
// firmware, you can manually define model here.
|
|
|
|
|
//
|
|
|
|
|
// #define BOARD_MODEL BOARD_GENERIC_ESP32
|
|
|
|
|
#define CONFIG_UART_BUFFER_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 200 |
|
|
|
|
|
|
|
|
|
#define EEPROM_SIZE 1024 |
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED |
|
|
|
|
|
|
|
|
|
#define GPS_BAUD_RATE 9600 |
|
|
|
|
#define PIN_GPS_TX 12 |
|
|
|
|
#define PIN_GPS_RX 34 |
|
|
|
|
|
|
|
|
|
#if BOARD_MODEL == BOARD_GENERIC_ESP32 |
|
|
|
|
const int pin_cs = 4; |
|
|
|
|
const int pin_reset = 36; |
|
|
|
|
const int pin_dio = 39; |
|
|
|
|
const int pin_led_rx = 14; |
|
|
|
|
const int pin_led_tx = 32; |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_TBEAM |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 23; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
const int pin_led_rx = 2; |
|
|
|
|
const int pin_led_tx = 4; |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_PMU true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_SD false |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#if MODEM == SX1262 |
|
|
|
|
// TODO: Figure out how on earth the SX1262 T-Beams are actually connected
|
|
|
|
|
// #define HAS_RF_SWITCH_RX_TX true
|
|
|
|
|
// const int pin_rxen = 32;
|
|
|
|
|
#define HAS_BUSY true |
|
|
|
|
const int pin_busy = 32; |
|
|
|
|
#endif |
|
|
|
|
#elif BOARD_MODEL == BOARD_HUZZAH32 |
|
|
|
|
const int pin_cs = 4; |
|
|
|
|
const int pin_reset = 36; |
|
|
|
|
const int pin_dio = 39; |
|
|
|
|
const int pin_led_rx = 14; |
|
|
|
|
const int pin_led_tx = 32; |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_LORA32_V1_0 |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 14; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 25; |
|
|
|
|
const int pin_led_tx = 2; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 2; |
|
|
|
|
const int pin_led_tx = 2; |
|
|
|
|
#endif |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_LORA32_V2_0 |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 12; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 2; |
|
|
|
|
const int pin_led_tx = 0; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 22; |
|
|
|
|
const int pin_led_tx = 22; |
|
|
|
|
#endif |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_LORA32_V2_1 |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 23; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
#if HAS_TCXO == true |
|
|
|
|
const int pin_tcxo_enable = 33; |
|
|
|
|
#endif |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 15; |
|
|
|
|
const int pin_led_tx = 4; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 25; |
|
|
|
|
const int pin_led_tx = 25; |
|
|
|
|
#endif |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_PMU true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_HELTEC32_V2 |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 23; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 36; |
|
|
|
|
const int pin_led_tx = 37; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 25; |
|
|
|
|
const int pin_led_tx = 25; |
|
|
|
|
#endif |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#elif BOARD_MODEL == BOARD_RNODE_NG_20 |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_NP true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 12; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
const int pin_np = 4; |
|
|
|
|
#if HAS_NP == false |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 2; |
|
|
|
|
const int pin_led_tx = 0; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 22; |
|
|
|
|
const int pin_led_tx = 22; |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
#elif BOARD_MODEL == BOARD_RNODE_NG_21 |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE true |
|
|
|
|
#define HAS_PMU true |
|
|
|
|
#define HAS_NP true |
|
|
|
|
#define HAS_SD false |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
const int pin_cs = 18; |
|
|
|
|
const int pin_reset = 23; |
|
|
|
|
const int pin_dio = 26; |
|
|
|
|
const int pin_np = 12; |
|
|
|
|
const int pin_dac = 25; |
|
|
|
|
const int pin_adc = 34; |
|
|
|
|
const int SD_MISO = 2; |
|
|
|
|
const int SD_MOSI = 15; |
|
|
|
|
const int SD_CLK = 14; |
|
|
|
|
const int SD_CS = 13; |
|
|
|
|
#if HAS_NP == false |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 12; |
|
|
|
|
const int pin_led_tx = 4; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 25; |
|
|
|
|
const int pin_led_tx = 25; |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
#elif BOARD_MODEL == BOARD_RNODE_NG_22 |
|
|
|
|
#define IS_ESP32S3 true |
|
|
|
|
#define HAS_DISPLAY true |
|
|
|
|
#define HAS_BLE true |
|
|
|
|
#define HAS_BLUETOOTH false // TODO: Implement
|
|
|
|
|
#define HAS_CONSOLE false // TODO: Implement
|
|
|
|
|
#define HAS_PMU true |
|
|
|
|
#define HAS_NP true |
|
|
|
|
#define HAS_SD false |
|
|
|
|
#define HAS_EEPROM true |
|
|
|
|
#define HAS_RF_SWITCH_RX_TX true |
|
|
|
|
#define HAS_BUSY true |
|
|
|
|
const int pin_reset = 8; |
|
|
|
|
const int pin_rxen = 21; |
|
|
|
|
const int pin_dio = 33; |
|
|
|
|
const int pin_busy = 34; |
|
|
|
|
|
|
|
|
|
const int pin_np = 38; |
|
|
|
|
const int pin_dac = 25; |
|
|
|
|
const int pin_adc = 1; |
|
|
|
|
const int SD_MISO = 2; |
|
|
|
|
const int SD_MOSI = 11; |
|
|
|
|
const int SD_CLK = 14; |
|
|
|
|
const int SD_CS = 13; |
|
|
|
|
#if HAS_NP == false |
|
|
|
|
#if defined(EXTERNAL_LEDS) |
|
|
|
|
const int pin_led_rx = 37; |
|
|
|
|
const int pin_led_tx = 37; |
|
|
|
|
#else |
|
|
|
|
const int pin_led_rx = 37; |
|
|
|
|
const int pin_led_tx = 37; |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
#endif |
|
|
|
|
#elif PLATFORM == PLATFORM_NRF52 |
|
|
|
|
#if BOARD_MODEL == BOARD_RAK4630 |
|
|
|
|
#define HAS_EEPROM false |
|
|
|
|
#define HAS_DISPLAY false // set for debugging
|
|
|
|
|
#define HAS_BLUETOOTH true |
|
|
|
|
#define HAS_CONSOLE false |
|
|
|
|
#define HAS_PMU false |
|
|
|
|
#define HAS_NP false |
|
|
|
|
#define HAS_SD false |
|
|
|
|
#define HAS_TCXO true |
|
|
|
|
#define HAS_RF_SWITCH_RX_TX true |
|
|
|
|
#define HAS_BUSY true |
|
|
|
|
#define CONFIG_UART_BUFFER_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_SIZE 6144 |
|
|
|
|
#define CONFIG_QUEUE_MAX_LENGTH 200 |
|
|
|
|
#define EEPROM_SIZE 200 |
|
|
|
|
//#define EEPROM_OFFSET EEPROM_SIZE+0xED000-EEPROM_RESERVED
|
|
|
|
|
#define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED |
|
|
|
|
|
|
|
|
|
// following pins are for the sx1262
|
|
|
|
|
const int pin_rxen = 37; |
|
|
|
|
const int pin_reset = 38; |
|
|
|
|
const int pin_cs = 42; |
|
|
|
|
const int pin_sclk = 43; |
|
|
|
|
const int pin_mosi = 44; |
|
|
|
|
const int pin_miso = 45; |
|
|
|
|
const int pin_busy = 46; |
|
|
|
|
const int pin_dio = 47; |
|
|
|
|
const int pin_led_rx = LED_BLUE; |
|
|
|
|
const int pin_led_tx = LED_GREEN; |
|
|
|
|
const int pin_tcxo_enable = -1; |
|
|
|
|
#endif |
|
|
|
|
#else |
|
|
|
|
#error An unsupported board was selected. Cannot compile RNode firmware. |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
bool mw_radio_online = false; |
|
|
|
|
|
|
|
|
|
#if BOARD_MODEL == BOARD_TBEAM |
|
|
|
|
#define I2C_SDA 21 |
|
|
|
|
#define I2C_SCL 22 |
|
|
|
|
#define PMU_IRQ 35 |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#define eeprom_addr(a) (a+EEPROM_OFFSET) |
|
|
|
|
|
|
|
|
|
#ifndef HAS_RF_SWITCH_RX_TX |
|
|
|
|
const int pin_rxen = -1; |
|
|
|
|
const int pin_txen = -1; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#ifndef HAS_BUSY |
|
|
|
|
const int pin_busy = -1; |
|
|
|
|
#endif |
|
|
|
|
|
|
|
|
|
#if (MODEM == SX1262 || MODEM == SX1280) && defined(NRF52840_XXAA) |
|
|
|
|
SPIClass spiModem(NRF_SPIM2, pin_miso, pin_sclk, pin_mosi); |
|
|
|
|
#endif |
|
|
|
|