Skip to content

Commit c56da5e

Browse files
committed
refactor: lilgo_t3s3 with CustomSX1262::std_init()
1 parent 165fb33 commit c56da5e

File tree

1 file changed

+3
-36
lines changed

1 file changed

+3
-36
lines changed

variants/lilygo_t3s3/target.cpp

Lines changed: 3 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -3,13 +3,8 @@
33

44
ESP32Board board;
55

6-
#if defined(P_LORA_SCLK)
7-
static SPIClass spi;
8-
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
9-
#else
10-
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY);
11-
#endif
12-
6+
static SPIClass spi;
7+
RADIO_CLASS radio = new Module(P_LORA_NSS, P_LORA_DIO_1, P_LORA_RESET, P_LORA_BUSY, spi);
138
WRAPPER_CLASS radio_driver(radio, board);
149

1510
ESP32RTCClock fallback_clock;
@@ -28,35 +23,7 @@ bool radio_init() {
2823
fallback_clock.begin();
2924
rtc_clock.begin(Wire);
3025

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

6229
uint32_t radio_get_rng_seed() {

0 commit comments

Comments
 (0)