IkokaNrf52Board.h 1.3 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152
  1. #pragma once
  2. #include <MeshCore.h>
  3. #include <Arduino.h>
  4. #ifdef IKOKA_NRF52
  5. class IkokaNrf52Board : public mesh::MainBoard {
  6. protected:
  7. uint8_t startup_reason;
  8. public:
  9. void begin();
  10. uint8_t getStartupReason() const override { return startup_reason; }
  11. #if defined(P_LORA_TX_LED)
  12. void onBeforeTransmit() override {
  13. digitalWrite(P_LORA_TX_LED, LOW); // turn TX LED on
  14. }
  15. void onAfterTransmit() override {
  16. digitalWrite(P_LORA_TX_LED, HIGH); // turn TX LED off
  17. }
  18. #endif
  19. uint16_t getBattMilliVolts() override {
  20. // Please read befor going further ;)
  21. // https://wiki.seeedstudio.com/XIAO_BLE#q3-what-are-the-considerations-when-using-xiao-nrf52840-sense-for-battery-charging
  22. // We can't drive VBAT_ENABLE to HIGH as long
  23. // as we don't know wether we are charging or not ...
  24. // this is a 3mA loss (4/1500)
  25. digitalWrite(VBAT_ENABLE, LOW);
  26. int adcvalue = 0;
  27. analogReadResolution(12);
  28. analogReference(AR_INTERNAL_3_0);
  29. delay(10);
  30. adcvalue = analogRead(PIN_VBAT);
  31. return (adcvalue * ADC_MULTIPLIER * AREF_VOLTAGE) / 4.096;
  32. }
  33. const char* getManufacturerName() const override {
  34. return "Ikoka Handheld E22 30dBm (Xiao_nrf52)";
  35. }
  36. void reboot() override {
  37. NVIC_SystemReset();
  38. }
  39. bool startOTAUpdate(const char* id, char reply[]) override;
  40. };
  41. #endif