target.cpp 899 B

123456789101112131415161718192021222324252627282930313233343536373839
  1. #include "target.h"
  2. #include <Arduino.h>
  3. HeltecE290Board board;
  4. #if defined(P_LORA_SCLK)
  5. static SPIClass spi(FSPI);
  6. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
  7. #else
  8. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
  9. #endif
  10. WRAPPER_CLASS radio_driver(radio, board);
  11. ESP32RTCClock fallback_clock;
  12. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  13. SensorManager sensors;
  14. #ifdef DISPLAY_CLASS
  15. DISPLAY_CLASS display(&board.periph_power);
  16. MomentaryButton user_btn(PIN_USER_BTN, 1000, true);
  17. #endif
  18. bool radio_init() {
  19. fallback_clock.begin();
  20. rtc_clock.begin(Wire);
  21. #if defined(P_LORA_SCLK)
  22. return radio.std_init(&spi);
  23. #else
  24. return radio.std_init();
  25. #endif
  26. }
  27. mesh::LocalIdentity radio_new_identity() {
  28. RadioNoiseListener rng(radio);
  29. return mesh::LocalIdentity(&rng); // create new random identity
  30. }