target.cpp 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142
  1. #include <Arduino.h>
  2. #include "target.h"
  3. XiaoC3Board board;
  4. #if defined(P_LORA_SCLK)
  5. static SPIClass spi;
  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. #if ENV_INCLUDE_GPS
  14. #include <helpers/sensors/MicroNMEALocationProvider.h>
  15. MicroNMEALocationProvider nmea = MicroNMEALocationProvider(Serial1, &rtc_clock);
  16. EnvironmentSensorManager sensors = EnvironmentSensorManager(nmea);
  17. #else
  18. EnvironmentSensorManager sensors;
  19. #endif
  20. bool radio_init() {
  21. fallback_clock.begin();
  22. rtc_clock.begin(Wire);
  23. #if defined(P_LORA_SCLK)
  24. spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
  25. return radio.std_init(&spi);
  26. #else
  27. return radio.std_init();
  28. #endif
  29. }
  30. mesh::LocalIdentity radio_new_identity() {
  31. RadioNoiseListener rng(radio);
  32. return mesh::LocalIdentity(&rng); // create new random identity
  33. }