瀏覽代碼

* new target env: Xiao S3 WIO repeater

Scott Powell 1 年之前
父節點
當前提交
88f21d9aa4
共有 5 個文件被更改,包括 56 次插入14 次删除
  1. 5 0
      examples/simple_repeater/main.cpp
  2. 35 4
      platformio.ini
  3. 15 1
      src/helpers/ESP32Board.h
  4. 0 4
      src/helpers/HeltecV3Board.h
  5. 1 5
      src/helpers/XiaoC3Board.h

+ 5 - 0
examples/simple_repeater/main.cpp

@@ -50,6 +50,10 @@
   #include <helpers/CustomSX1262Wrapper.h>
   #include <helpers/CustomSX1268Wrapper.h>
   static XiaoC3Board board;
+#elif defined(SEEED_XIAO_S3)
+  #include <helpers/ESP32Board.h>
+  #include <helpers/CustomSX1262Wrapper.h>
+  static ESP32Board board;
 #else
   #error "need to provide a 'board' object"
 #endif
@@ -377,6 +381,7 @@ void setup() {
   int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
 #endif
   if (status != RADIOLIB_ERR_NONE) {
+    delay(5000);
     Serial.print("ERROR: radio init failed: ");
     Serial.println(status);
     halt();

+ 35 - 4
platformio.ini

@@ -118,6 +118,9 @@ build_flags =
   -D P_LORA_NSS=D4
   -D P_LORA_RESET=RADIOLIB_NC
   -D P_LORA_BUSY=D1
+  -D SX126X_DIO2_AS_RF_SWITCH=true
+  -D SX126X_DIO3_TCXO_VOLTAGE=1.8
+  -D SX126X_CURRENT_LIMIT=130.0f  ; for best TX power!
 
 [env:Xiao_C3_Repeater_sx1262]
 extends = Xiao_esp32_C3
@@ -130,9 +133,8 @@ build_flags =
   -D LORA_FREQ=915.0
   -D LORA_BW=250
   -D LORA_SF=10
-  -D REPEATER_NAME="\"Xiao Repeater1\""
-  -D MESH_PACKET_LOGGING=1
-  -D MESH_DEBUG=1
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1
 
 [env:Xiao_C3_Repeater_sx1268]
 extends = Xiao_esp32_C3
@@ -145,9 +147,38 @@ build_flags =
   -D LORA_FREQ=433.0
   -D LORA_BW=250
   -D LORA_SF=10
-  -D REPEATER_NAME="\"Xiao Repeater1\""
  ; -D MESH_PACKET_LOGGING=1
  ; -D MESH_DEBUG=1
 
 ; =============
+[Xiao_S3_WIO]
+extends = esp32_base
+board = seeed_xiao_esp32s3
+board_check = true
+board_build.mcu = esp32s3
+build_flags = ${esp32_base.build_flags}
+  -D SEEED_XIAO_S3
+  -D P_LORA_DIO_1=39
+  -D P_LORA_NSS=41
+  -D P_LORA_RESET=42   ; RADIOLIB_NC
+  -D P_LORA_BUSY=40   ;  DIO2 = 38
+  -D P_LORA_SCLK=7
+  -D P_LORA_MISO=8
+  -D P_LORA_MOSI=9
+  -D SX126X_DIO2_AS_RF_SWITCH=true
+  -D SX126X_DIO3_TCXO_VOLTAGE=1.8
+  -D SX126X_CURRENT_LIMIT=130
 
+[env:Xiao_S3_WIO_Repeater]
+extends = Xiao_S3_WIO
+build_src_filter = ${Xiao_S3_WIO.build_src_filter} +<../examples/simple_repeater/main.cpp>
+build_flags =
+  ${Xiao_S3_WIO.build_flags} 
+  -D RADIO_CLASS=CustomSX1262
+  -D WRAPPER_CLASS=CustomSX1262Wrapper
+  -D LORA_TX_POWER=22
+  -D LORA_FREQ=915.0
+  -D LORA_BW=250
+  -D LORA_SF=10
+;  -D MESH_PACKET_LOGGING=1
+;  -D MESH_DEBUG=1

+ 15 - 1
src/helpers/ESP32Board.h

@@ -8,10 +8,24 @@
 #include <rom/rtc.h>
 #include <sys/time.h>
 
-class ESP32Board : public mesh::MainBoard {  // abstract class
+class ESP32Board : public mesh::MainBoard {
+protected:
+  uint8_t startup_reason;
+
 public:
   void begin() {
     // for future use, sub-classes SHOULD call this from their begin()
+    startup_reason = BD_STARTUP_NORMAL;
+  }
+
+  uint8_t getStartupReason() const override { return startup_reason; }
+
+  uint16_t getBattMilliVolts() override {
+    return 0;  // not supported
+  }
+
+  const char* getManufacturerName() const override {
+    return "Generic ESP32";
   }
 
   void reboot() override {

+ 0 - 4
src/helpers/HeltecV3Board.h

@@ -22,10 +22,8 @@
 #include <driver/rtc_io.h>
 
 class HeltecV3Board : public ESP32Board {
-  uint8_t startup_reason;
 public:
   void begin() {
-    startup_reason = BD_STARTUP_NORMAL;
     ESP32Board::begin();
 
     esp_reset_reason_t reason = esp_reset_reason();
@@ -46,8 +44,6 @@ public:
     pinMode(PIN_ADC_CTRL, OUTPUT);
   }
 
-  uint8_t getStartupReason() const { return startup_reason; }
-
   void enterDeepSleep(uint32_t secs, int pin_wake_btn = -1) {
     esp_sleep_pd_config(ESP_PD_DOMAIN_RTC_PERIPH, ESP_PD_OPTION_ON);
 

+ 1 - 5
src/helpers/XiaoC3Board.h

@@ -12,10 +12,8 @@
 #include <driver/uart.h>
 
 class XiaoC3Board : public ESP32Board {
-  uint8_t startup_reason;
 public:
   void begin() {
-    startup_reason = BD_STARTUP_NORMAL;
     ESP32Board::begin();
 
     esp_reset_reason_t reason = esp_reset_reason();
@@ -47,8 +45,6 @@ public:
   #endif
   }
 
-  uint8_t getStartupReason() const { return startup_reason; }
-
   void enterDeepSleep(uint32_t secs, int8_t wake_pin = -1) {
     gpio_set_direction(gpio_num_t(P_LORA_DIO_1), GPIO_MODE_INPUT);
     if (wake_pin >= 0) {
@@ -111,7 +107,7 @@ public:
 
     return ((5.78 * raw) / 1024.0) * 1000;
   #else
-    return 0;
+    return 0;  // not supported
   #endif
   }