Merge pull request #726 from recrof/xiao_rp2040_refactor

tidy up xiao rp2040 variant
This commit is contained in:
ripplebiz 2025-09-06 22:38:07 +10:00 committed by GitHub
commit 605210dd07
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 12 additions and 22 deletions

View file

@ -1,30 +0,0 @@
#include "XiaoRP2040Board.h"
#include <Arduino.h>
#include <Wire.h>
void XiaoRP2040Board::begin() {
// for future use, sub-classes SHOULD call this from their begin()
startup_reason = BD_STARTUP_NORMAL;
#ifdef P_LORA_TX_LED
pinMode(P_LORA_TX_LED, OUTPUT);
#endif
#ifdef PIN_VBAT_READ
pinMode(PIN_VBAT_READ, INPUT);
#endif
#if defined(PIN_BOARD_SDA) && defined(PIN_BOARD_SCL)
Wire.setSDA(PIN_BOARD_SDA);
Wire.setSCL(PIN_BOARD_SCL);
#endif
Wire.begin();
delay(10); // give sx1262 some time to power up
}
bool XiaoRP2040Board::startOTAUpdate(const char *id, char reply[]) {
return false;
}

View file

@ -1,75 +0,0 @@
#pragma once
#include <Arduino.h>
#include <MeshCore.h>
// LoRa radio module pins for the Xiao RP2040
// https://wiki.seeedstudio.com/XIAO-RP2040/
#define P_LORA_DIO_1 27 // D1
#define P_LORA_NSS 6 // D4
#define P_LORA_RESET 28 // D2
#define P_LORA_BUSY 29 // D3
#define P_LORA_TX_LED 17
#define SX126X_RXEN 7 // D5
#define SX126X_TXEN -1
#define SX126X_DIO2_AS_RF_SWITCH true
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
/*
* This board has no built-in way to read battery voltage.
* Nevertheless it's very easy to make it work, you only require two 1% resistors.
* If your using the WIO SX1262 Addon for xaio, make sure you dont connect D0!
*
* BAT+ -----+
* |
* VSYS --+ -/\/\/\/\- --+
* 200k |
* +-- D0
* |
* GND --+ -/\/\/\/\- --+
* | 100k
* BAT- -----+
*/
#define PIN_VBAT_READ 26 // D0
#define BATTERY_SAMPLES 8
#define ADC_MULTIPLIER (3.0f * 3.3f * 1000)
class XiaoRP2040Board : public mesh::MainBoard {
protected:
uint8_t startup_reason;
public:
void begin();
uint8_t getStartupReason() const override { return startup_reason; }
#ifdef P_LORA_TX_LED
void onBeforeTransmit() override { digitalWrite(P_LORA_TX_LED, HIGH); }
void onAfterTransmit() override { digitalWrite(P_LORA_TX_LED, LOW); }
#endif
uint16_t getBattMilliVolts() override {
#if defined(PIN_VBAT_READ) && defined(ADC_MULTIPLIER)
analogReadResolution(12);
uint32_t raw = 0;
for (int i = 0; i < BATTERY_SAMPLES; i++) {
raw += analogRead(PIN_VBAT_READ);
}
raw = raw / BATTERY_SAMPLES;
return (ADC_MULTIPLIER * raw) / 4096;
#else
return 0;
#endif
}
const char *getManufacturerName() const override { return "Xiao RP2040"; }
void reboot() override { rp2040.reboot(); }
bool startOTAUpdate(const char *id, char reply[]) override;
};