IkokaNrf52Board.h 1.2 KB

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