MinewsemiME25LS01Board.h 2.1 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #include <helpers/NRF52Board.h>
  5. // LoRa and SPI pins
  6. #define P_LORA_DIO_1 (32 + 12) // P1.12
  7. #define P_LORA_NSS (32 + 13) // P1.13
  8. #define P_LORA_RESET (32 + 11) // P1.11
  9. #define P_LORA_BUSY (32 + 10) // P1.10
  10. #define P_LORA_SCLK (32 + 15) // P1.15
  11. #define P_LORA_MISO (0 + 29) // P0.29
  12. #define P_LORA_MOSI (0 + 2) // P0.2
  13. #define LR11X0_DIO_AS_RF_SWITCH true
  14. #define LR11X0_DIO3_TCXO_VOLTAGE 1.6
  15. #define PIN_VBAT_READ BATTERY_PIN
  16. #define ADC_MULTIPLIER (1.815f) // dependent on voltage divider resistors. TODO: more accurate battery tracking
  17. class MinewsemiME25LS01Board : public NRF52BoardDCDC {
  18. protected:
  19. uint8_t btn_prev_state;
  20. public:
  21. MinewsemiME25LS01Board() : NRF52Board("Minewsemi_OTA") {}
  22. void begin();
  23. #define BATTERY_SAMPLES 8
  24. uint16_t getBattMilliVolts() override {
  25. analogReadResolution(12);
  26. uint32_t raw = 0;
  27. for (int i = 0; i < BATTERY_SAMPLES; i++) {
  28. raw += analogRead(PIN_VBAT_READ);
  29. }
  30. raw = raw / BATTERY_SAMPLES;
  31. return (ADC_MULTIPLIER * raw);
  32. }
  33. const char* getManufacturerName() const override {
  34. return "Minewsemi";
  35. }
  36. void powerOff() override {
  37. #ifdef HAS_GPS
  38. digitalWrite(GPS_VRTC_EN, LOW);
  39. digitalWrite(GPS_RESET, LOW);
  40. digitalWrite(GPS_SLEEP_INT, LOW);
  41. digitalWrite(GPS_RTC_INT, LOW);
  42. pinMode(GPS_RESETB, OUTPUT);
  43. digitalWrite(GPS_RESETB, LOW);
  44. #endif
  45. #ifdef BUZZER_EN
  46. digitalWrite(BUZZER_EN, LOW);
  47. #endif
  48. #ifdef LED_PIN
  49. digitalWrite(LED_PIN, LOW);
  50. #endif
  51. #ifdef BUTTON_PIN
  52. nrf_gpio_cfg_sense_input(digitalPinToInterrupt(BUTTON_PIN), NRF_GPIO_PIN_PULLUP, NRF_GPIO_PIN_SENSE_LOW);
  53. #endif
  54. sd_power_system_off();
  55. }
  56. #if defined(P_LORA_TX_LED)
  57. void onBeforeTransmit() override {
  58. digitalWrite(P_LORA_TX_LED, HIGH);// turn TX LED on
  59. }
  60. void onAfterTransmit() override {
  61. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED off
  62. }
  63. #endif
  64. };