nano-g2.h 1.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657
  1. #pragma once
  2. #include "variant.h"
  3. #include <Arduino.h>
  4. #include <MeshCore.h>
  5. #include <helpers/NRF52Board.h>
  6. // LoRa radio module pins
  7. #define P_LORA_DIO_1 (32 + 10)
  8. #define P_LORA_NSS (32 + 13)
  9. #define P_LORA_RESET (32 + 15)
  10. #define P_LORA_BUSY (32 + 11)
  11. #define P_LORA_SCLK (0 + 12)
  12. #define P_LORA_MISO (32 + 9)
  13. #define P_LORA_MOSI (0 + 11)
  14. #define SX126X_DIO2_AS_RF_SWITCH true
  15. #define SX126X_DIO3_TCXO_VOLTAGE 1.8
  16. #define SX126X_POWER_EN 37
  17. // buttons
  18. #define PIN_BUTTON1 (32 + 6)
  19. #define BUTTON_PIN PIN_BUTTON1
  20. #define PIN_USER_BTN BUTTON_PIN
  21. // GPS
  22. #define GPS_EN PIN_GPS_STANDBY
  23. // built-ins
  24. #define VBAT_MV_PER_LSB (0.73242188F) // 3.0V ADC range and 12-bit ADC resolution = 3000mV/4096
  25. #define VBAT_DIVIDER (0.5F) // 150K + 150K voltage divider on VBAT, actually 100K + 100K
  26. #define VBAT_DIVIDER_COMP (2.0F) // Compensation factor for the VBAT divider
  27. #define PIN_VBAT_READ (0 + 2)
  28. #define REAL_VBAT_MV_PER_LSB (VBAT_DIVIDER_COMP * VBAT_MV_PER_LSB)
  29. class NanoG2Ultra : public NRF52BoardOTA {
  30. public:
  31. NanoG2Ultra() : NRF52BoardOTA("NANO_G2_OTA") {}
  32. void begin();
  33. uint16_t getBattMilliVolts() override;
  34. const char *getManufacturerName() const override { return "Nano G2 Ultra"; }
  35. void powerOff() override {
  36. // put GPS chip to sleep
  37. digitalWrite(PIN_GPS_STANDBY, LOW);
  38. // TODO: unset buzzer to prevent notification circuit activating on hibernate
  39. // needs to be set as silent or somehow stop using macros for pins
  40. nrf_gpio_cfg_sense_input(digitalPinToInterrupt(PIN_USER_BTN), NRF_GPIO_PIN_NOPULL,
  41. NRF_GPIO_PIN_SENSE_LOW);
  42. sd_power_system_off();
  43. }
  44. };