Skip to content

Commit 00ebb09

Browse files
committed
Migrate Meshadventurer to std_init()
1 parent c913560 commit 00ebb09

File tree

1 file changed

+5
-38
lines changed

1 file changed

+5
-38
lines changed

variants/meshadventurer/target.cpp

Lines changed: 5 additions & 38 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,8 @@
55

66
MeshadventurerBoard board;
77

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

1712
ESP32RTCClock fallback_clock;
@@ -30,40 +25,12 @@ MASensorManager sensors = MASensorManager(nmea);
3025
bool radio_init() {
3126
fallback_clock.begin();
3227
rtc_clock.begin(Wire);
33-
34-
#ifdef SX126X_DIO3_TCXO_VOLTAGE
35-
float tcxo = SX126X_DIO3_TCXO_VOLTAGE;
36-
#else
37-
float tcxo = 1.6f;
38-
#endif
3928

4029
#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-
#if defined(SX126X_RXEN) && defined(SX126X_TXEN)
53-
radio.setRfSwitchPins(SX126X_RXEN, SX126X_TXEN);
54-
#endif
55-
56-
#ifdef SX126X_CURRENT_LIMIT
57-
radio.setCurrentLimit(SX126X_CURRENT_LIMIT);
58-
#endif
59-
#ifdef SX126X_DIO2_AS_RF_SWITCH
60-
radio.setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH);
61-
#endif
62-
#ifdef SX126X_RX_BOOSTED_GAIN
63-
radio.setRxBoostedGainMode(SX126X_RX_BOOSTED_GAIN);
30+
return radio.std_init(&spi);
31+
#else
32+
return radio.std_init();
6433
#endif
65-
66-
return true; // success
6734
}
6835

6936
uint32_t radio_get_rng_seed() {

0 commit comments

Comments
 (0)