MeshtinyBoard.cpp 979 B

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. #include "MeshtinyBoard.h"
  2. #include <Arduino.h>
  3. #include <Wire.h>
  4. #include <bluefruit.h>
  5. static BLEDfu bledfu;
  6. static void connect_callback(uint16_t conn_handle) {
  7. (void)conn_handle;
  8. MESH_DEBUG_PRINTLN("BLE client connected");
  9. }
  10. static void disconnect_callback(uint16_t conn_handle, uint8_t reason) {
  11. (void)conn_handle;
  12. (void)reason;
  13. MESH_DEBUG_PRINTLN("BLE client disconnected");
  14. }
  15. void MeshtinyBoard::begin() {
  16. NRF52BoardDCDC::begin();
  17. btn_prev_state = HIGH;
  18. pinMode(PIN_VBAT_READ, INPUT); // VBAT ADC input
  19. // Set all button pins to INPUT_PULLUP
  20. pinMode(PIN_BUTTON1, INPUT_PULLUP);
  21. pinMode(PIN_BUTTON2, INPUT_PULLUP);
  22. pinMode(PIN_BUTTON3, INPUT_PULLUP);
  23. pinMode(PIN_BUTTON4, INPUT_PULLUP);
  24. #if defined(PIN_WIRE_SDA) && defined(PIN_WIRE_SCL)
  25. Wire.setPins(PIN_WIRE_SDA, PIN_WIRE_SCL);
  26. #endif
  27. Wire.begin();
  28. pinMode(SX126X_POWER_EN, OUTPUT);
  29. digitalWrite(SX126X_POWER_EN, HIGH);
  30. delay(10); // give sx1262 some time to power up
  31. }