* BIG refactor: 'board' and 'radio' objects now defined in 'target.h/.cpp'

* mesh::RTCClock class moved to MeshCore.h
This commit is contained in:
Scott Powell
2025-03-21 18:57:12 +11:00
parent 0a5a115875
commit bfb4b1c496
48 changed files with 726 additions and 407 deletions

View File

@@ -3,6 +3,7 @@ extends = esp32_base
board = station-g2
build_flags =
${esp32_base.build_flags}
-I variants/station_g2
-D STATION_G2
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
@@ -16,8 +17,8 @@ build_flags =
-D SX126X_CURRENT_LIMIT=130.0f ; for best TX power!
; -D SX126X_RX_BOOSTED_GAIN=1 - DO NOT ENABLE THIS!
; https://wiki.uniteng.com/en/meshtastic/station-g2#impact-of-lora-node-dense-areashigh-noise-environments-on-rf-performance
build_src_filter = ${esp32_base.build_src_filter}
+<../variants/station_g2>
lib_deps =
${esp32_base.lib_deps}

View File

@@ -0,0 +1,47 @@
#include <Arduino.h>
#include "target.h"
StationG2Board board;
#if defined(P_LORA_SCLK)
static SPIClass spi;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
#else
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
#endif
#ifndef LORA_CR
#define LORA_CR 5
#endif
bool radio_init() {
#ifdef SX126X_DIO3_TCXO_VOLTAGE
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
#else
float tcxo = 1.6f;
#endif
#if defined(P_LORA_SCLK)
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
#endif
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
if (status != RADIOLIB_ERR_NONE) {
Serial.print("ERROR: radio init failed: ");
Serial.println(status);
return false; // fail
}
radio.setCRC(1);
#ifdef SX126X_CURRENT_LIMIT
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
#endif
#ifdef SX126X_DIO2_AS_RF_SWITCH
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
#endif
#ifdef SX126X_RX_BOOSTED_GAIN
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
#endif
return true; // success
}

View File

@@ -0,0 +1,9 @@
#pragma once
#include <helpers/StationG2Board.h>
#include <helpers/CustomSX1262Wrapper.h>
extern StationG2Board board;
extern RADIO_CLASS radio;
bool radio_init();