From 02f9dc13450d55c8fad1dfbf8826c3d9a5ab0879 Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 12 Sep 2024 10:57:16 -0400 Subject: [PATCH 1/3] Squashed commit of the following: commit 2e25bff15413f2365f1b18c901f93297ce07c645 Author: jeremy Date: Thu Sep 12 10:19:07 2024 -0400 Adds t-echo support commit aa44625847179c5b3c4d03b9f7e062f409da0d8a Author: jeremy Date: Thu Sep 12 10:19:07 2024 -0400 Adds t-echo support --- .vscode/settings.json | 16 +++++++++++ Boards.h | 64 +++++++++++++++++++++++++++++++++++++++++-- Device.h | 6 +++- Makefile | 15 ++++++++++ RNode_Firmware_CE.ino | 26 +++++++++++++----- ROM.h | 3 ++ Radio.cpp | 5 ++++ Utilities.h | 13 +++++++-- 8 files changed, 136 insertions(+), 12 deletions(-) create mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json new file mode 100644 index 0000000..48174a9 --- /dev/null +++ b/.vscode/settings.json @@ -0,0 +1,16 @@ +{ + "files.associations": { + "array": "cpp", + "deque": "cpp", + "list": "cpp", + "string": "cpp", + "unordered_map": "cpp", + "unordered_set": "cpp", + "vector": "cpp", + "string_view": "cpp", + "initializer_list": "cpp", + "ranges": "cpp", + "span": "cpp", + "format": "cpp" + } +} \ No newline at end of file diff --git a/Boards.h b/Boards.h index 3193b8e..eb2527b 100644 --- a/Boards.h +++ b/Boards.h @@ -39,6 +39,7 @@ #define BOARD_RNODE_NG_20 0x40 #define BOARD_RNODE_NG_21 0x41 #define BOARD_T3S3 0x42 + #define BOARD_TECHO 0x43 #define BOARD_GENERIC_NRF52 0x50 #define BOARD_RAK4631 0x51 @@ -50,7 +51,7 @@ #if defined(ESP32) #define PLATFORM PLATFORM_ESP32 #define MCU_VARIANT MCU_ESP32 - #elif defined(NRF52840_XXAA) + #elif defined(NRF52840_XXAA) || defined(_VARIANT_PCA10056_) #include #define PLATFORM PLATFORM_NRF52 #define MCU_VARIANT MCU_NRF52 @@ -629,7 +630,66 @@ #endif #elif MCU_VARIANT == MCU_NRF52 - #if BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_FREENODE + #if BOARD_MODEL == BOARD_TECHO + #define VALIDATE_FIRMWARE false + //#define GPS_BAUD_RATE 115200 + //#define PIN_GPS_TX 41 + //#define PIN_GPS_RX 40 + #define EEPROM_SIZE 296 + #define EEPROM_OFFSET EEPROM_SIZE-EEPROM_RESERVED + //#define HAS_EEPROM true + //#define HAS_SD true + //#define HAS_DISPLAY true + //#define HAS_CONSOLE true + //#define HAS_TXCO true + //#define DISPLAY EINK_BW + //#define HAS_BLE true + //#define HAS_PMU true + #define CONFIG_UART_BUFFER_SIZE 40000 + #define CONFIG_QUEUE_0_SIZE 6144 + #define CONFIG_QUEUE_MAX_LENGTH 200 + #define BLE_MANUFACTURER "LilyGO" + #define BLE_MODEL "T-Echo" + #define INTERFACE_COUNT 1 + //#define I2C_SDA 26 + //#define I2C_SCL 27 + #define CONFIG_QUEUE_1_SIZE 40000 + // first interface in list is the primary + const uint8_t interfaces[INTERFACE_COUNT] = {SX126X}; + const bool interface_cfg[INTERFACE_COUNT][3] = { + // SX1262 + { + false, // DEFAULT_SPI + true, // HAS_TCXO + true // DIO2_AS_RF_SWITCH + } + }; + + const int8_t interface_pins[INTERFACE_COUNT][10] = { + // SX1262 + { + 24, // pin_ss + 19, // pin_sclk + 22, // pin_mosi + 23, // pin_miso + 17, // pin_busy + 20, // pin_dio + 25, // pin_reset + -1, // pin_txen + -1, // pin_rxen + 21 // pin_tcxo_enable + } + }; + + const int pin_disp_cs = 30; + const int pin_disp_dc = 28; + const int pin_disp_reset = 2; + const int pin_disp_busy = 3; + const int pin_disp_en = 43; + + const int pin_led_rx = LED_BLUE; + const int pin_led_tx = LED_RED; + #elif BOARD_MODEL == BOARD_RAK4631 || BOARD_MODEL == BOARD_FREENODE #define HAS_EEPROM false #define HAS_DISPLAY true #define DISPLAY EINK_BW diff --git a/Device.h b/Device.h index 944479d..304e676 100644 --- a/Device.h +++ b/Device.h @@ -275,6 +275,7 @@ bool device_firmware_ok() { #if MCU_VARIANT == MCU_ESP32 || MCU_VARIANT == MCU_NRF52 bool device_init() { + #if VALIDATE_FIRMWARE if (bt_ready) { #if MCU_VARIANT == MCU_ESP32 for (uint8_t i=0; i #include "Utilities.h" -#if MCU_VARIANT == MCU_NRF52 - #define INTERFACE_SPI +#if MCU_VARIANT == MCU_NRF52 + #define INTERFACE_SPI + #if BOARD_MODEL == BOARD_RAK4631 // Required because on RAK4631, non-default SPI pins must be initialised when class is declared. SPIClass interface_spi[1] = { // SX1262 @@ -29,6 +30,17 @@ interface_pins[0][2] ) }; + #elif BOARD_MODEL == BOARD_TECHO + SPIClass interface_spi[1] = { + // SX1262 + SPIClass( + NRF_SPIM3, + interface_pins[0][3], + interface_pins[0][1], + interface_pins[0][2] + ) + }; + #endif #endif #ifndef INTERFACE_SPI @@ -1101,11 +1113,11 @@ void validate_status() { if (eeprom_checksum_valid()) { eeprom_ok = true; if (modems_installed) { - if (device_init()) { - hw_ready = true; - } else { - hw_ready = false; - } + if (device_init()) { + hw_ready = true; + } else { + hw_ready = false; + } } else { hw_ready = false; Serial.write("No valid radio module found\r\n"); diff --git a/ROM.h b/ROM.h index 323449d..4ecd02a 100644 --- a/ROM.h +++ b/ROM.h @@ -32,6 +32,9 @@ #define MODEL_12 0x12 #define MODEL_13 0x13 // RAK4631 LF with WisBlock SX1280 module (LIBSYS002) #define MODEL_14 0x14 // RAK4631 HF with WisBlock SX1280 module (LIBSYS002) + #define PRODUCT_TECHO 0x15 + #define MODEL_16 0x16 // T-Echo 433 + #define MODEL_17 0x17 // T-Echo 915 #define MODEL_21 0x21 // European band, 868MHz #define MODEL_A1 0xA1 #define MODEL_A5 0xA5 // T3S3 SX1280 PA diff --git a/Radio.cpp b/Radio.cpp index e0df264..0686b0b 100644 --- a/Radio.cpp +++ b/Radio.cpp @@ -744,6 +744,8 @@ void sx126x::enableTCXO() { uint8_t buf[4] = {MODE_TCXO_3_3V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_TBEAM uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; + #elif BOARD_MODEL == BOARD_TECHO + uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; #elif BOARD_MODEL == BOARD_T3S3 uint8_t buf[4] = {MODE_TCXO_1_8V_6X, 0x00, 0x00, 0xFF}; #else @@ -2563,6 +2565,9 @@ void sx128x::disableCrc() byte sx128x::random() { // todo: implement + return 0x4; //chosen by fair die roll + //guarenteed to be random + //https://xkcd.com/221/ } void sx128x::setSPIFrequency(uint32_t frequency) diff --git a/Utilities.h b/Utilities.h index f1e832d..8405736 100644 --- a/Utilities.h +++ b/Utilities.h @@ -210,7 +210,12 @@ uint8_t boot_vector = 0x00; void led_rx_off() { digitalWrite(pin_led_rx, LOW); } void led_tx_on() { digitalWrite(pin_led_tx, HIGH); } void led_tx_off() { digitalWrite(pin_led_tx, LOW); } - #endif + #elif BOARD_MODEL == BOARD_TECHO + void led_rx_on() { digitalWrite(pin_led_rx, HIGH); } + void led_rx_off() { digitalWrite(pin_led_rx, LOW); } + void led_tx_on() { digitalWrite(pin_led_tx, HIGH); } + void led_tx_off() { digitalWrite(pin_led_tx, LOW); } + #endif #endif void hard_reset(void) { @@ -1160,6 +1165,8 @@ uint16_t getQueueSize(uint8_t index) { case 11: return CONFIG_QUEUE_11_SIZE; #endif + default: + return CONFIG_QUEUE_0_SIZE; } } @@ -1334,7 +1341,7 @@ bool eeprom_product_valid() { #if PLATFORM == PLATFORM_ESP32 if (rval == PRODUCT_RNODE || rval == BOARD_RNODE_NG_20 || rval == BOARD_RNODE_NG_21 || rval == PRODUCT_HMBRW || rval == PRODUCT_TBEAM || rval == PRODUCT_T32_10 || rval == PRODUCT_T32_20 || rval == PRODUCT_T32_21 || rval == PRODUCT_H32_V2 || rval == PRODUCT_H32_V3) { #elif PLATFORM == PLATFORM_NRF52 - if (rval == PRODUCT_RAK4631 || rval == PRODUCT_HMBRW || rval == PRODUCT_FREENODE) { + if (rval == PRODUCT_TECHO || rval == MODEL_16 || rval == MODEL_17 || rval == PRODUCT_RAK4631 || rval == PRODUCT_HMBRW || rval == PRODUCT_FREENODE) { #else if (false) { #endif @@ -1362,6 +1369,8 @@ bool eeprom_model_valid() { if (model == MODEL_FF || model == MODEL_FE) { #elif BOARD_MODEL == BOARD_TBEAM if (model == MODEL_E4 || model == MODEL_E9 || model == MODEL_E3 || model == MODEL_E8) { + #elif BOARD_MODEL == BOARD_TECHO + if (model == MODEL_16 || model == MODEL_17) { #elif BOARD_MODEL == BOARD_LORA32_V1_0 if (model == MODEL_BA || model == MODEL_BB) { #elif BOARD_MODEL == BOARD_LORA32_V2_0 From 2550b7a379f7ace8c467d94fe1717c63b15d64a8 Mon Sep 17 00:00:00 2001 From: jeremy Date: Thu, 12 Sep 2024 11:02:21 -0400 Subject: [PATCH 2/3] adds .vscode to git ignore file --- .gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/.gitignore b/.gitignore index c585a06..b879ff5 100644 --- a/.gitignore +++ b/.gitignore @@ -7,3 +7,4 @@ Release/*.zip Release/*.json Console/build build/* +.vscode \ No newline at end of file From 83ae40470f4891512da07b9a975504dd375959e3 Mon Sep 17 00:00:00 2001 From: jeremybox <33465600+jeremybox@users.noreply.github.com> Date: Thu, 12 Sep 2024 11:03:56 -0400 Subject: [PATCH 3/3] Delete .vscode/settings.json --- .vscode/settings.json | 16 ---------------- 1 file changed, 16 deletions(-) delete mode 100644 .vscode/settings.json diff --git a/.vscode/settings.json b/.vscode/settings.json deleted file mode 100644 index 48174a9..0000000 --- a/.vscode/settings.json +++ /dev/null @@ -1,16 +0,0 @@ -{ - "files.associations": { - "array": "cpp", - "deque": "cpp", - "list": "cpp", - "string": "cpp", - "unordered_map": "cpp", - "unordered_set": "cpp", - "vector": "cpp", - "string_view": "cpp", - "initializer_list": "cpp", - "ranges": "cpp", - "span": "cpp", - "format": "cpp" - } -} \ No newline at end of file