2025-01-20 20:22:40 +11:00
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <MeshCore.h>
|
|
|
|
|
#include <Arduino.h>
|
|
|
|
|
|
|
|
|
|
// LoRa radio module pins for RAK4631
|
|
|
|
|
#define P_LORA_DIO_1 47
|
|
|
|
|
#define P_LORA_NSS 42
|
|
|
|
|
#define P_LORA_RESET RADIOLIB_NC // 38
|
|
|
|
|
#define P_LORA_BUSY 46
|
|
|
|
|
#define P_LORA_SCLK 43
|
|
|
|
|
#define P_LORA_MISO 45
|
|
|
|
|
#define P_LORA_MOSI 44
|
|
|
|
|
#define SX126X_POWER_EN 37
|
2025-05-25 22:48:04 -07:00
|
|
|
|
2025-07-16 19:04:50 -07:00
|
|
|
//#define PIN_GPS_SDA 13 //GPS SDA pin (output option)
|
|
|
|
|
//#define PIN_GPS_SCL 14 //GPS SCL pin (output option)
|
|
|
|
|
//#define PIN_GPS_TX 16 //GPS TX pin
|
|
|
|
|
//#define PIN_GPS_RX 15 //GPS RX pin
|
|
|
|
|
#define PIN_GPS_1PPS 17 //GPS PPS pin
|
2025-05-25 22:48:04 -07:00
|
|
|
#define GPS_BAUD_RATE 9600
|
|
|
|
|
#define GPS_ADDRESS 0x42 //i2c address for GPS
|
2025-01-20 20:22:40 +11:00
|
|
|
|
|
|
|
|
#define SX126X_DIO2_AS_RF_SWITCH true
|
|
|
|
|
#define SX126X_DIO3_TCXO_VOLTAGE 1.8
|
|
|
|
|
|
|
|
|
|
// built-ins
|
2025-02-02 09:44:59 +11:00
|
|
|
#define PIN_VBAT_READ 5
|
2025-02-06 08:44:06 +11:00
|
|
|
#define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
|
2025-01-20 20:22:40 +11:00
|
|
|
|
|
|
|
|
class RAK4631Board : public mesh::MainBoard {
|
|
|
|
|
protected:
|
|
|
|
|
uint8_t startup_reason;
|
|
|
|
|
|
|
|
|
|
public:
|
2025-02-25 19:00:07 +11:00
|
|
|
void begin();
|
2025-01-20 20:22:40 +11:00
|
|
|
uint8_t getStartupReason() const override { return startup_reason; }
|
|
|
|
|
|
2025-02-02 09:44:59 +11:00
|
|
|
#define BATTERY_SAMPLES 8
|
2025-01-20 20:22:40 +11:00
|
|
|
|
|
|
|
|
uint16_t getBattMilliVolts() override {
|
|
|
|
|
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;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
const char* getManufacturerName() const override {
|
|
|
|
|
return "RAK 4631";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void reboot() override {
|
|
|
|
|
NVIC_SystemReset();
|
|
|
|
|
}
|
|
|
|
|
|
2025-03-22 23:51:44 +11:00
|
|
|
bool startOTAUpdate(const char* id, char reply[]) override;
|
2025-02-03 12:53:38 +11:00
|
|
|
};
|