Răsfoiți Sursa

* new target/envs: LilyGo_T3S3_sx1262, _repeater and _terminal_chat

Scott Powell 1 an în urmă
părinte
comite
16b81d2a6c

+ 45 - 0
boards/t3_s3_v1_x.json

@@ -0,0 +1,45 @@
+{
+    "build": {
+        "arduino": {
+            "ldscript": "esp32s3_out.ld",
+            "partitions": "default.csv",
+            "memory_type": "qio_qspi"
+        },
+        "core": "esp32",
+        "extra_flags": [
+            "-DARDUINO_LILYGO_T3_S3_V1_X",
+            "-DBOARD_HAS_PSRAM",
+            "-DARDUINO_USB_CDC_ON_BOOT=1",
+            "-DARDUINO_RUNNING_CORE=1",
+            "-DARDUINO_EVENT_RUNNING_CORE=1",
+            "-DARDUINO_USB_MODE=1"
+        ],
+        "f_cpu": "240000000L",
+        "f_flash": "80000000L",
+        "flash_mode": "qio",
+        "mcu": "esp32s3",
+        "variant": "esp32s3"
+    },
+    "connectivity": [
+        "wifi"
+    ],
+    "debug": {
+        "openocd_target": "esp32s3.cfg"
+    },
+    "frameworks": [
+        "arduino",
+        "espidf"
+    ],
+    "name": "LilyGo T3-S3 Radio",
+    "upload": {
+        "flash_size": "4MB",
+        "maximum_ram_size": 327680,
+        "maximum_size": 4194304,
+        "use_1200bps_touch": true,
+        "wait_for_upload_port": true,
+        "require_upload_port": true,
+        "speed": 460800
+    },
+    "url": "https://www.lilygo.cc",
+    "vendor": "LilyGo"
+}

+ 2 - 2
examples/simple_repeater/main.cpp

@@ -19,7 +19,7 @@
 
 /* ------------------------------ Config -------------------------------- */
 
-#define FIRMWARE_VER_TEXT   "v2 (build: 30 Jan 2025)"
+#define FIRMWARE_VER_TEXT   "v2 (build: 31 Jan 2025)"
 
 #ifndef LORA_FREQ
   #define LORA_FREQ   915.0
@@ -60,7 +60,7 @@
   #include <helpers/CustomSX1262Wrapper.h>
   #include <helpers/CustomSX1268Wrapper.h>
   static XiaoC3Board board;
-#elif defined(SEEED_XIAO_S3)
+#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
   #include <helpers/ESP32Board.h>
   #include <helpers/CustomSX1262Wrapper.h>
   static ESP32Board board;

+ 1 - 1
examples/simple_secure_chat/main.cpp

@@ -56,7 +56,7 @@
   #include <helpers/CustomSX1262Wrapper.h>
   #include <helpers/CustomSX1268Wrapper.h>
   static XiaoC3Board board;
-#elif defined(SEEED_XIAO_S3)
+#elif defined(SEEED_XIAO_S3) || defined(LILYGO_T3S3)
   #include <helpers/ESP32Board.h>
   #include <helpers/CustomSX1262Wrapper.h>
   static ESP32Board board;

+ 53 - 1
platformio.ini

@@ -17,7 +17,7 @@ lib_deps =
   jgromes/RadioLib @ ^6.3.0
   rweather/Crypto @ ^0.4.0
 build_flags = -w -DNDEBUG -DRADIOLIB_STATIC_ONLY=1
-  -D LORA_FREQ=867.5
+  -D LORA_FREQ=915.8
   -D LORA_BW=250
   -D LORA_SF=10
 build_src_filter = +<*.cpp> +<helpers/*.cpp>
@@ -246,6 +246,58 @@ lib_deps =
   adafruit/RTClib @ ^2.1.3
   densaugeo/base64 @ ~1.4.0
 
+; =============
+[LilyGo_T3S3_sx1262]
+extends = esp32_base
+board = t3_s3_v1_x
+build_flags = ${esp32_base.build_flags}
+  -D LILYGO_T3S3
+  -D P_LORA_DIO_1=33
+  -D P_LORA_NSS=7
+  -D P_LORA_RESET=8   ; RADIOLIB_NC
+  -D P_LORA_BUSY=34
+  -D P_LORA_SCLK=5
+  -D P_LORA_MISO=3
+  -D P_LORA_MOSI=6
+  -D P_LORA_TX_LED=37
+  -D PIN_VBAT_READ=1
+  -D SX126X_DIO2_AS_RF_SWITCH=true
+  -D SX126X_DIO3_TCXO_VOLTAGE=1.8
+  -D SX126X_CURRENT_LIMIT=130
+  -D RADIO_CLASS=CustomSX1262
+  -D WRAPPER_CLASS=CustomSX1262Wrapper
+  -D LORA_TX_POWER=22
+
+[env:LilyGo_T3S3_sx1262_Repeater]
+extends = LilyGo_T3S3_sx1262
+build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_repeater/main.cpp>
+build_flags =
+  ${LilyGo_T3S3_sx1262.build_flags} 
+  -D ADVERT_NAME="\"T3S3 Repeater\""
+  -D ADVERT_LAT=-37.0
+  -D ADVERT_LON=145.0
+  -D ADMIN_PASSWORD="\"password\""
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
+lib_deps =
+  ${LilyGo_T3S3_sx1262.lib_deps}
+  adafruit/RTClib @ ^2.1.3
+
+[env:LilyGo_T3S3_sx1262_terminal_chat]
+extends = LilyGo_T3S3_sx1262
+build_flags =
+  ${LilyGo_T3S3_sx1262.build_flags} 
+  -D MAX_CONTACTS=100
+  -D MAX_GROUP_CHANNELS=1
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
+build_src_filter = ${LilyGo_T3S3_sx1262.build_src_filter} +<../examples/simple_secure_chat/main.cpp>
+lib_deps =
+  ${LilyGo_T3S3_sx1262.lib_deps}
+  adafruit/RTClib @ ^2.1.3
+  densaugeo/base64 @ ~1.4.0
+
+
 ; ----------------- NRF52 ---------------------
 [nrf52_base]
 extends = arduino_base

+ 32 - 0
src/helpers/ESP32Board.h

@@ -16,12 +16,44 @@ public:
   void begin() {
     // for future use, sub-classes SHOULD call this from their begin()
     startup_reason = BD_STARTUP_NORMAL;
+
+  #ifdef PIN_VBAT_READ
+    // battery read support
+    pinMode(PIN_VBAT_READ, INPUT);
+    adcAttachPin(PIN_VBAT_READ);
+  #endif
+
+  #ifdef P_LORA_TX_LED
+    pinMode(P_LORA_TX_LED, OUTPUT);
+    digitalWrite(P_LORA_TX_LED, LOW);
+  #endif
   }
 
   uint8_t getStartupReason() const override { return startup_reason; }
 
+#if defined(P_LORA_TX_LED)
+  void onBeforeTransmit() override {
+    digitalWrite(P_LORA_TX_LED, HIGH);   // turn TX LED on
+  }
+  void onAfterTransmit() override {
+    digitalWrite(P_LORA_TX_LED, LOW);   // turn TX LED off
+  }
+#endif
+
   uint16_t getBattMilliVolts() override {
+  #ifdef PIN_VBAT_READ
+    analogReadResolution(12);
+
+    uint32_t raw = 0;
+    for (int i = 0; i < 4; i++) {
+      raw += analogReadMilliVolts(PIN_VBAT_READ);
+    }
+    raw = raw / 4;
+
+    return (2 * raw);
+  #else
     return 0;  // not supported
+  #endif
   }
 
   const char* getManufacturerName() const override {

+ 5 - 21
src/helpers/HeltecV3Board.h

@@ -1,6 +1,5 @@
 #pragma once
 
-#include "ESP32Board.h"
 #include <Arduino.h>
 
 // LoRa radio module pins for Heltec V3
@@ -19,6 +18,8 @@
 #define  PIN_ADC_CTRL_INACTIVE  HIGH
 #define  PIN_LED_BUILTIN 35
 
+#include "ESP32Board.h"
+
 #include <driver/rtc_io.h>
 
 class HeltecV3Board : public ESP32Board {
@@ -26,6 +27,8 @@ public:
   void begin() {
     ESP32Board::begin();
 
+    pinMode(PIN_ADC_CTRL, OUTPUT);
+
     esp_reset_reason_t reason = esp_reset_reason();
     if (reason == ESP_RST_DEEPSLEEP) {
       long wakeup_source = esp_sleep_get_ext1_wakeup_status();
@@ -36,17 +39,6 @@ public:
       rtc_gpio_hold_dis((gpio_num_t)P_LORA_NSS);
       rtc_gpio_deinit((gpio_num_t)P_LORA_DIO_1);
     }
-
-    // battery read support
-    pinMode(PIN_VBAT_READ, INPUT);
-    adcAttachPin(PIN_VBAT_READ);
-    analogReadResolution(10);
-    pinMode(PIN_ADC_CTRL, OUTPUT);
-
-  #ifdef P_LORA_TX_LED
-    pinMode(P_LORA_TX_LED, OUTPUT);
-    digitalWrite(P_LORA_TX_LED, LOW);
-  #endif
   }
 
   void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
@@ -72,16 +64,8 @@ public:
     esp_deep_sleep_start();   // CPU halts here and never returns!
   }
 
-#if defined(P_LORA_TX_LED)
-  void onBeforeTransmit() override {
-    digitalWrite(P_LORA_TX_LED, HIGH);   // turn TX LED on
-  }
-  void onAfterTransmit() override {
-    digitalWrite(P_LORA_TX_LED, LOW);   // turn TX LED off
-  }
-#endif
-
   uint16_t getBattMilliVolts() override {
+    analogReadResolution(10);
     digitalWrite(PIN_ADC_CTRL, PIN_ADC_CTRL_ACTIVE);
 
     uint32_t raw = 0;