RAK3401Board.h 974 B

12345678910111213141516171819202122232425262728293031323334353637383940414243
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. // built-ins
  6. #define PIN_VBAT_READ 5
  7. #define ADC_MULTIPLIER (3 * 1.73 * 1.187 * 1000)
  8. #define PIN_3V3_EN (34)
  9. #define WB_IO2 PIN_3V3_EN
  10. class RAK3401Board : public NRF52BoardDCDC {
  11. protected:
  12. #ifdef NRF52_POWER_MANAGEMENT
  13. void initiateShutdown(uint8_t reason) override;
  14. #endif
  15. public:
  16. RAK3401Board() : NRF52Board("RAK3401_OTA") {}
  17. void begin();
  18. #define BATTERY_SAMPLES 8
  19. uint16_t getBattMilliVolts() override {
  20. analogReadResolution(12);
  21. uint32_t raw = 0;
  22. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  23. raw += analogRead(PIN_VBAT_READ);
  24. }
  25. raw = raw / BATTERY_SAMPLES;
  26. return (ADC_MULTIPLIER * raw) / 4096;
  27. }
  28. const char* getManufacturerName() const override {
  29. return "RAK 3401";
  30. }
  31. // TX/RX switching is handled by SX1262 DIO2 -> SKY66122 CTX (hardware-timed).
  32. // No onBeforeTransmit/onAfterTransmit overrides needed.
  33. };