Skip to content

Commit 28a38e6

Browse files
authored
Merge pull request #462 from seagull9000/Refactor-Heltec-Tracker-radiolib-init
Refactor radiolib for Heltec Wireless Tracker
2 parents eb4f81f + 1bfa3d3 commit 28a38e6

File tree

1 file changed

+3
-30
lines changed

1 file changed

+3
-30
lines changed

variants/heltec_tracker/target.cpp

Lines changed: 3 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -23,43 +23,16 @@ HWTSensorManager sensors = HWTSensorManager(nmea);
2323
DISPLAY_CLASS display(&board.periph_power); // peripheral power pin is shared
2424
#endif
2525

26-
#ifndef LORA_CR
27-
#define LORA_CR 5
28-
#endif
29-
3026
bool radio_init() {
3127
fallback_clock.begin();
3228
rtc_clock.begin(Wire);
3329

34-
#ifdef SX126X_DIO3_TCXO_VOLTAGE
35-
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
36-
#else
37-
float tcxo = 1.6f;
38-
#endif
39-
4030
#if defined(P_LORA_SCLK)
41-
spi.begin(P_LORA_SCLK, P_LORA_MISO, P_LORA_MOSI);
42-
#endif
43-
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, tcxo);
44-
if (status != RADIOLIB_ERR_NONE) {
45-
Serial.print("ERROR: radio init failed: ");
46-
Serial.println(status);
47-
return false; // fail
48-
}
49-
50-
radio.setCRC(1);
51-
52-
#ifdef SX126X_CURRENT_LIMIT
53-
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
54-
#endif
55-
#ifdef SX126X_DIO2_AS_RF_SWITCH
56-
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
57-
#endif
58-
#ifdef SX126X_RX_BOOSTED_GAIN
59-
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
31+
return radio.std_init(&spi);
32+
#else
33+
return radio.std_init();
6034
#endif
6135

62-
return true; // success
6336
}
6437

6538
uint32_t radio_get_rng_seed() {

0 commit comments

Comments
 (0)