diff --git a/boards/tlora-t3s3-v1.json b/boards/tlora-t3s3-v1.json new file mode 100644 index 00000000..36a54ad2 --- /dev/null +++ b/boards/tlora-t3s3-v1.json @@ -0,0 +1,47 @@ +{ + "build": { + "arduino": { + "ldscript": "esp32s3_out.ld" + }, + "core": "esp32", + "extra_flags": [ + "-DLILYGO_T3S3_V1", + "-DARDUINO_USB_CDC_ON_BOOT=1", + "-DARDUINO_USB_MODE=0", + "-DARDUINO_RUNNING_CORE=1", + "-DARDUINO_EVENT_RUNNING_CORE=1" + ], + "f_cpu": "240000000L", + "f_flash": "80000000L", + "flash_mode": "dio", + "hwids": [ + [ + "0X303A", + "0x1001" + ] + ], + "mcu": "esp32s3", + "variant": "tlora-t3s3-v1" + }, + "connectivity": [ + "wifi" + ], + "debug": { + "openocd_target": "esp32s3.cfg" + }, + "frameworks": [ + "arduino", + "espidf" + ], + "name": "LilyGo TLora-T3S3-V1", + "upload": { + "flash_size": "4MB", + "maximum_ram_size": 327680, + "maximum_size": 4194304, + "wait_for_upload_port": true, + "require_upload_port": true, + "speed": 921600 + }, + "url": "http://www.lilygo.cn/", + "vendor": "LilyGo" +} \ No newline at end of file diff --git a/protobufs b/protobufs index 0985b94c..05209dee 160000 --- a/protobufs +++ b/protobufs @@ -1 +1 @@ -Subproject commit 0985b94c20287552daf63831fd9eda4e0ed1bd0e +Subproject commit 05209dee1b8fe4376c221eabd29fc165273edd43 diff --git a/src/main.cpp b/src/main.cpp index c0fcaf96..f999ac70 100644 --- a/src/main.cpp +++ b/src/main.cpp @@ -242,7 +242,6 @@ void setup() digitalWrite(PIN_3V3_EN, 1); #endif - // Currently only the tbeam has a PMU // PMU initialization needs to be placed before scanI2Cdevice power = new Power(); @@ -462,17 +461,6 @@ if((config.lora.region == Config_LoRaConfig_RegionCode_LORA_24) && (!rIf->wideLo } } -if((config.lora.region != Config_LoRaConfig_RegionCode_LORA_24) && (rIf->wideLora())){ - DEBUG_MSG("Warning: Radio chip only supports 2.4GHz LoRa. Adjusting Region.\n"); - config.lora.region = Config_LoRaConfig_RegionCode_LORA_24; - nodeDB.saveToDisk(SEGMENT_CONFIG); - if(!rIf->reconfigure()) { - DEBUG_MSG("Reconfigure failed, rebooting\n"); - screen->startRebootScreen(); - rebootAtMsec = millis() + 5000; - } -} - #if HAS_WIFI || HAS_ETHERNET mqttInit(); #endif diff --git a/src/mesh/SX128xInterface.cpp b/src/mesh/SX128xInterface.cpp index 0a51d618..fa85963b 100644 --- a/src/mesh/SX128xInterface.cpp +++ b/src/mesh/SX128xInterface.cpp @@ -1,5 +1,6 @@ #include "configuration.h" #include "SX128xInterface.h" +#include "mesh/NodeDB.h" #include "error.h" // Particular boards might define a different max power based on what their hardware can do @@ -50,6 +51,20 @@ bool SX128xInterface::init() // \todo Display actual typename of the adapter, not just `SX128x` DEBUG_MSG("SX128x init result %d\n", res); + if((config.lora.region != Config_LoRaConfig_RegionCode_LORA_24) && (res == RADIOLIB_ERR_INVALID_FREQUENCY)) { + DEBUG_MSG("Warning: Radio chip only supports 2.4GHz LoRa. Adjusting Region and rebooting.\n"); + config.lora.region = Config_LoRaConfig_RegionCode_LORA_24; + nodeDB.saveToDisk(SEGMENT_CONFIG); + delay(2000); +#if defined(ARCH_ESP32) + ESP.restart(); +#elif defined(ARCH_NRF52) + NVIC_SystemReset(); +#else + DEBUG_MSG("FIXME implement reboot for this platform. Skipping for now.\n"); +#endif + } + DEBUG_MSG("Frequency set to %f\n", getFreq()); DEBUG_MSG("Bandwidth set to %f\n", bw); DEBUG_MSG("Power output set to %d\n", power); diff --git a/src/mesh/generated/mesh.pb.h b/src/mesh/generated/mesh.pb.h index 6fa6c8d3..31e7817a 100644 --- a/src/mesh/generated/mesh.pb.h +++ b/src/mesh/generated/mesh.pb.h @@ -54,6 +54,8 @@ typedef enum _HardwareModel { HardwareModel_NANO_G1 = 14, /* TODO: REPLACE */ HardwareModel_TLORA_V2_1_1P8 = 15, + /* TODO: REPLACE */ + HardwareModel_TLORA_T3_S3 = 16, /* B&Q Consulting Station Edition G1: https://uniteng.com/wiki/doku.php?id=meshtastic:station */ HardwareModel_STATION_G1 = 25, /* Less common/prototype boards listed here (needs one more byte over the air) */ diff --git a/src/platform/esp32/architecture.h b/src/platform/esp32/architecture.h index f80008ca..212df9f4 100644 --- a/src/platform/esp32/architecture.h +++ b/src/platform/esp32/architecture.h @@ -88,6 +88,8 @@ #define HW_VENDOR HardwareModel_HELTEC_V3 #elif defined(HELTEC_WSL_V3) #define HW_VENDOR HardwareModel_HELTEC_WSL_V3 +#elif defined(TLORA_T3S3_V1) + #define HW_VENDOR HardwareModel_TLORA_T3_S3 #endif // diff --git a/variants/tlora_t3s3_v1/pins_arduino.h b/variants/tlora_t3s3_v1/pins_arduino.h new file mode 100644 index 00000000..9b8eba7c --- /dev/null +++ b/variants/tlora_t3s3_v1/pins_arduino.h @@ -0,0 +1,34 @@ +#ifndef Pins_Arduino_h +#define Pins_Arduino_h + +#include + +#define USB_VID 0x303a +#define USB_PID 0x1001 + +#define EXTERNAL_NUM_INTERRUPTS 46 +#define NUM_DIGITAL_PINS 48 +#define NUM_ANALOG_INPUTS 20 + +#define analogInputToDigitalPin(p) (((p)<20)?(analogChannelToDigitalPin(p)):-1) +#define digitalPinToInterrupt(p) (((p)<48)?(p):-1) +#define digitalPinHasPWM(p) (p < 46) + +// The default Wire will be mapped to PMU and RTC +static const uint8_t SDA = 18; +static const uint8_t SCL = 17; + +// Default SPI will be mapped to Radio +static const uint8_t SS = 7; +static const uint8_t MOSI = 6; +static const uint8_t MISO = 3; +static const uint8_t SCK = 5; + +#define SPI_MOSI (11) +#define SPI_SCK (14) +#define SPI_MISO (2) +#define SPI_CS (13) + +#define SDCARD_CS SPI_CS + +#endif /* Pins_Arduino_h */ diff --git a/variants/tlora_t3s3_v1/platformio.ini b/variants/tlora_t3s3_v1/platformio.ini new file mode 100644 index 00000000..aa818919 --- /dev/null +++ b/variants/tlora_t3s3_v1/platformio.ini @@ -0,0 +1,9 @@ +[env:tlora-t3s3-v1] +extends = esp32s3_base +board = tlora-t3s3-v1 +lib_deps = + ${esp32_base.lib_deps} + caveman99/ESP32 Codec2@^1.0.1 + +build_flags = + ${esp32_base.build_flags} -D TLORA_T3S3_V1 -I variants/tlora_t3s3_v1 \ No newline at end of file diff --git a/variants/tlora_t3s3_v1/variant.h b/variants/tlora_t3s3_v1/variant.h new file mode 100644 index 00000000..64874dac --- /dev/null +++ b/variants/tlora_t3s3_v1/variant.h @@ -0,0 +1,54 @@ +#undef GPS_RX_PIN +#undef GPS_TX_PIN + +#define HAS_SDCARD +#define SDCARD_USE_SPI1 + +#define USE_SSD1306 + +#define BATTERY_PIN 1 // A battery voltage measurement pin, voltage divider connected here to measure battery voltage +// ratio of voltage divider = 2.0 (R42=100k, R43=100k) +#define ADC_MULTIPLIER 2.11 // 2.0 + 10% for correction of display undervoltage. + +#define I2C_SDA 18 // I2C pins for this board +#define I2C_SCL 17 + +#define LED_PIN 37 // If defined we will blink this LED +#define BUTTON_PIN 0 // If defined, this will be used for user button presses, + +#define BUTTON_NEED_PULLUP + +// TTGO uses a common pinout for their SX1262 vs RF95 modules - both can be enabled and we will probe at runtime for RF95 and if +// not found then probe for SX1262 +#define USE_RF95 // RFM95/SX127x +#define USE_SX1262 +#define USE_SX1280 + +#define RF95_SCK 5 +#define RF95_MISO 3 +#define RF95_MOSI 6 +#define RF95_NSS 7 + +#define LORA_RESET 8 +#define LORA_DIO0 9 +#define LORA_DIO1 9 +#define LORA_DIO2 33 // SX1262 BUSY +#define LORA_DIO3 34 // Not connected on PCB, but internally on the TTGO SX1262, if DIO3 is high the TXCO is enabled + +#ifdef USE_SX1262 +#define SX126X_CS RF95_NSS // FIXME - we really should define LORA_CS instead +#define SX126X_DIO1 LORA_DIO1 +#define SX126X_BUSY 36 +#define SX126X_RESET LORA_RESET +#define SX126X_RXEN 21 +#define SX126X_TXEN 10 +#endif + +#ifdef USE_SX1280 +#define SX128X_CS RF95_NSS +#define SX128X_DIO1 LORA_DIO1 +#define SX128X_BUSY 36 +#define SX128X_RESET LORA_RESET +#define SX128X_RXEN 21 +#define SX128X_TXEN 10 +#endif \ No newline at end of file