target.cpp 616 B

12345678910111213141516171819202122232425
  1. #include <Arduino.h>
  2. #include "target.h"
  3. LilyGoTLoraBoard board;
  4. static SPIClass spi;
  5. RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_0, P_LORA_RESET, P_LORA_DIO_1, spi);
  6. #ifndef LORA_CR
  7. #define LORA_CR 5
  8. #endif
  9. bool radio_init() {
  10. spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
  11. int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8);
  12. if (status != RADIOLIB_ERR_NONE) {
  13. Serial.print("ERROR: radio init failed: ");
  14. Serial.println(status);
  15. return false; // fail
  16. }
  17. radio.setCRC(1);
  18. return true; // success
  19. }