Merge branch 'dev' into lora-longer-preamble

This commit is contained in:
OverkillFPV
2026-04-16 20:43:46 +10:00
committed by GitHub
315 changed files with 7641 additions and 1800 deletions

View File

@@ -3,8 +3,43 @@
#include "SenseCapSolarBoard.h"
#ifdef NRF52_POWER_MANAGEMENT
const PowerMgtConfig power_config = {
.lpcomp_ain_channel = PWRMGT_LPCOMP_AIN,
.lpcomp_refsel = PWRMGT_LPCOMP_REFSEL,
.voltage_bootlock = PWRMGT_VOLTAGE_BOOTLOCK
};
void SenseCapSolarBoard::initiateShutdown(uint8_t reason) {
bool enable_lpcomp = (reason == SHUTDOWN_REASON_LOW_VOLTAGE ||
reason == SHUTDOWN_REASON_BOOT_PROTECT);
pinMode(VBAT_ENABLE, OUTPUT);
digitalWrite(VBAT_ENABLE, enable_lpcomp ? LOW : HIGH);
if (enable_lpcomp) {
configureVoltageWake(power_config.lpcomp_ain_channel, power_config.lpcomp_refsel);
}
enterSystemOff(reason);
}
#endif // NRF52_POWER_MANAGEMENT
void SenseCapSolarBoard::begin() {
NRF52Board::begin();
NRF52BoardDCDC::begin();
pinMode(BATTERY_PIN, INPUT);
pinMode(VBAT_ENABLE, OUTPUT);
digitalWrite(VBAT_ENABLE, LOW);
analogReadResolution(12);
analogReference(AR_INTERNAL_3_0);
delay(50);
#ifdef PIN_USER_BTN
pinMode(PIN_USER_BTN, INPUT_PULLUP);
#elif defined(PIN_BUTTON1)
pinMode(PIN_BUTTON1, INPUT_PULLUP);
#endif
#if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
@@ -12,10 +47,23 @@ void SenseCapSolarBoard::begin() {
Wire.begin();
#ifdef LED_WHITE
pinMode(LED_WHITE, OUTPUT);
digitalWrite(LED_WHITE, HIGH);
#endif
#ifdef LED_BLUE
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, LOW);
#endif
#ifdef P_LORA_TX_LED
pinMode(P_LORA_TX_LED, OUTPUT);
digitalWrite(P_LORA_TX_LED, LOW);
#endif
#ifdef NRF52_POWER_MANAGEMENT
checkBootVoltage(&power_config);
#endif
delay(10); // give sx1262 some time to power up
}
}

View File

@@ -5,6 +5,11 @@
#include <helpers/NRF52Board.h>
class SenseCapSolarBoard : public NRF52BoardDCDC {
protected:
#ifdef NRF52_POWER_MANAGEMENT
void initiateShutdown(uint8_t reason) override;
#endif
public:
SenseCapSolarBoard() : NRF52Board("SENSECAP_SOLAR_OTA") {}
void begin();
@@ -31,4 +36,25 @@ public:
const char* getManufacturerName() const override {
return "Seeed SenseCap Solar";
}
void powerOff() override {
digitalWrite(LED_WHITE, LOW);
digitalWrite(LED_BLUE, LOW);
#ifdef PIN_USER_BTN
while (digitalRead(PIN_USER_BTN) == LOW);
// Keep pull-up enabled in system-off so the wake line doesn't float low.
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_USER_BTN]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
#elif defined(PIN_BUTTON1)
while (digitalRead(PIN_BUTTON1) == LOW);
// Keep pull-up enabled in system-off so the wake line doesn't float low.
nrf_gpio_cfg_sense_input(digitalPinToInterrupt(g_ADigitalPinMap[PIN_BUTTON1]), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
#endif
#ifdef NRF52_POWER_MANAGEMENT
initiateShutdown(SHUTDOWN_REASON_USER);
#else
sd_power_system_off();
#endif
}
};

View File

@@ -8,15 +8,17 @@ build_flags = ${nrf52_base.build_flags}
-I lib/nrf52/s140_nrf52_7.3.0_API/include/nrf52
-I variants/sensecap_solar
-I src/helpers/nrf52
-UENV_INCLUDE_GPS
-D NRF52_PLATFORM=1
-D USE_SX1262
-D NRF52_POWER_MANAGEMENT
-D RADIO_CLASS=CustomSX1262
-D WRAPPER_CLASS=CustomSX1262Wrapper
-D P_LORA_TX_LED=12
-D P_LORA_TX_LED=11
-D P_LORA_DIO_1=1
-D P_LORA_RESET=2
-D P_LORA_BUSY=3
-D P_LORA_NSS=4
-D PIN_USER_BTN=PIN_BUTTON1
-D LORA_TX_POWER=22
-D SX126X_RXEN=5
-D SX126X_TXEN=RADIOLIB_NC
@@ -24,6 +26,7 @@ build_flags = ${nrf52_base.build_flags}
-D SX126X_DIO3_TCXO_VOLTAGE=1.8
-D SX126X_CURRENT_LIMIT=140
-D SX126X_RX_BOOSTED_GAIN=1
-D ENV_INCLUDE_GPS=1
build_src_filter = ${nrf52_base.build_src_filter}
+<helpers/*.cpp>
+<helpers/sensors>
@@ -96,4 +99,4 @@ build_src_filter = ${SenseCap_Solar.build_src_filter}
+<../examples/companion_radio/*.cpp>
lib_deps =
${SenseCap_Solar.lib_deps}
densaugeo/base64 @ ~1.4.0
densaugeo/base64 @ ~1.4.0

View File

@@ -1,7 +1,9 @@
#include <Arduino.h>
#include "target.h"
#include <helpers/ArduinoHelpers.h>
#ifdef ENV_INCLUDE_GPS
#include <helpers/sensors/MicroNMEALocationProvider.h>
#endif
SenseCapSolarBoard board;
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, SPI);
@@ -10,7 +12,12 @@ WRAPPER_CLASS radio_driver(radio, board);
VolatileRTCClock fallback_clock;
AutoDiscoverRTCClock rtc_clock(fallback_clock);
EnvironmentSensorManager sensors;
#ifdef ENV_INCLUDE_GPS
MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
#else
EnvironmentSensorManager sensors = EnvironmentSensorManager();
#endif
bool radio_init() {
rtc_clock.begin(Wire);
@@ -38,3 +45,4 @@ mesh::LocalIdentity radio_new_identity() {
RadioNoiseListener rng(radio);
return mesh::LocalIdentity(&rng); // create new random identity
}

View File

@@ -19,3 +19,4 @@ uint32_t radio_get_rng_seed();
void radio_set_params(float freq, float bw, uint8_t sf, uint8_t cr);
void radio_set_tx_power(int8_t dbm);
mesh::LocalIdentity radio_new_identity();

View File

@@ -18,8 +18,8 @@ const uint32_t g_ADigitalPinMap[] = {
47, // D10 P1.15 (SPI_MOSI) LORA_MOSI
// D11-D12 - LED outputs
15, // D11 P0.15 User LED
19, // D12 P0.19 Breathing LED
15, // D11 P0.15 User LED (White LED)
19, // D12 P0.19 Breathing LED (Blue LED - LoRa TX)
// D13 - User input
33, // D13 P1.01 User Button
@@ -58,14 +58,9 @@ void initVariant() {
pinMode(PIN_QSPI_CS, OUTPUT);
digitalWrite(PIN_QSPI_CS, HIGH);
pinMode(LED_GREEN, OUTPUT);
digitalWrite(LED_GREEN, LOW);
pinMode(LED_WHITE, OUTPUT);
digitalWrite(LED_WHITE, LOW);
pinMode(LED_BLUE, OUTPUT);
digitalWrite(LED_BLUE, LOW);
/* disable gps until we actually support it.
pinMode(GPS_EN, OUTPUT);
digitalWrite(GPS_EN, HIGH);
*/
}

View File

@@ -24,14 +24,15 @@
#define LED_BUILTIN (PIN_LED)
#define LED_RED (PINS_COUNT)
#define LED_GREEN (12)
#define LED_BLUE (11)
#define LED_WHITE (11)
#define LED_BLUE (12) // LoRa TX indicator
#define LED_STATE_ON (1) // State when LED is litted
// Buttons
#define PIN_BUTTON1 (13)
#define PIN_BUTTON2 (20)
#define PIN_USER_BTN PIN_BUTTON1
#define VBAT_ENABLE (19) // Output LOW to enable reading of the BAT voltage.
@@ -41,6 +42,11 @@
#define ADC_MULTIPLIER (3.0F) // 1M, 512k divider bridge
#define ADC_RESOLUTION (12)
// nRF52 power management settings
#define PWRMGT_VOLTAGE_BOOTLOCK (3300) // Won't boot below this voltage (mV)
#define PWRMGT_LPCOMP_AIN (7) // AIN7 = P0.31 = BATTERY_PIN
#define PWRMGT_LPCOMP_REFSEL (2) // 3/8 VDD (~3.38-3.71V)
// Serial interfaces
#define PIN_SERIAL1_RX (7)
#define PIN_SERIAL1_TX (6)
@@ -82,4 +88,4 @@
#define EXTERNAL_FLASH_DEVICES P25Q16H
#define EXTERNAL_FLASH_USE_QSPI
#endif
#endif