target.cpp 721 B

1234567891011121314151617181920212223242526272829303132333435
  1. #include "target.h"
  2. #include <Arduino.h>
  3. #include <helpers/ArduinoHelpers.h>
  4. XiaoRP2040Board board;
  5. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
  6. WRAPPER_CLASS radio_driver(radio, board);
  7. VolatileRTCClock fallback_clock;
  8. AutoDiscoverRTCClock rtc_clock(fallback_clock);
  9. SensorManager sensors;
  10. #ifndef LORA_CR
  11. #define LORA_CR 5
  12. #endif
  13. bool radio_init() {
  14. rtc_clock.begin(Wire);
  15. #if defined(P_LORA_SCLK)
  16. spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
  17. return radio.std_init(&spi);
  18. #else
  19. return radio.std_init();
  20. #endif
  21. }
  22. mesh::LocalIdentity radio_new_identity() {
  23. RadioNoiseListener rng(radio);
  24. return mesh::LocalIdentity(&rng); // create new random identity
  25. }