Skip to content

Commit 3875799

Browse files
committed
rak3x72: support variations in platformio.ini
1 parent 816f3f8 commit 3875799

File tree

3 files changed

+18
-5
lines changed

3 files changed

+18
-5
lines changed

variants/rak3x72/platformio.ini

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,14 +7,15 @@ build_flags = ${stm32_base.build_flags}
77
-D WRAPPER_CLASS=CustomSTM32WLxWrapper
88
-D SPI_INTERFACES_COUNT=0
99
-D RX_BOOSTED_GAIN=true
10+
; -D STM32WL_TCXO_VOLTAGE=1.6 ; defaults to 0 if undef
11+
; -D LORA_TX_POWER=14 ; Defaults to 22 for HP, 14 is for LP version
1012
-I variants/rak3x72
1113
build_src_filter = ${stm32_base.build_src_filter}
1214
+<../variants/rak3x72>
1315

1416
[env:rak3x72-repeater]
1517
extends = rak3x72
1618
build_flags = ${rak3x72.build_flags}
17-
-D LORA_TX_POWER=22
1819
-D ADVERT_NAME='"RAK3x72 Repeater"'
1920
-D ADMIN_PASSWORD='"password"'
2021
build_src_filter = ${rak3x72.build_src_filter}
@@ -24,7 +25,6 @@ build_src_filter = ${rak3x72.build_src_filter}
2425
extends = rak3x72
2526
build_flags = ${rak3x72.build_flags}
2627
; -D FORMAT_FS=true
27-
-D LORA_TX_POWER=22
2828
-D MAX_CONTACTS=100
2929
-D MAX_GROUP_CHANNELS=8
3030
build_src_filter = ${rak3x72.build_src_filter}

variants/rak3x72/target.cpp

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,12 +24,21 @@ SensorManager sensors;
2424
#define LORA_CR 5
2525
#endif
2626

27+
#ifndef STM32WL_TCXO_VOLTAGE
28+
// TCXO set to 0 for RAK3172
29+
#define STM32WL_TCXO_VOLTAGE 0
30+
#endif
31+
32+
#ifndef LORA_TX_POWER
33+
#define LORA_TX_POWER 22
34+
#endif
35+
2736
bool radio_init() {
2837
// rtc_clock.begin(Wire);
2938

3039
radio.setRfSwitchTable(rfswitch_pins, rfswitch_table);
3140

32-
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, 0, 0); // TCXO set to 0 for RAK3172
41+
int status = radio.begin(LORA_FREQ, LORA_BW, LORA_SF, LORA_CR, RADIOLIB_SX126X_SYNC_WORD_PRIVATE, LORA_TX_POWER, 8, STM32WL_TCXO_VOLTAGE, 0);
3342

3443
if (status != RADIOLIB_ERR_NONE) {
3544
Serial.print("ERROR: radio init failed: ");

variants/rak3x72/target.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,12 @@ class RAK3x72Board : public STM32Board {
1818
}
1919

2020
uint16_t getBattMilliVolts() override {
21-
uint32_t raw = analogRead(PIN_VBAT_READ);
22-
return (ADC_MULTIPLIER * raw) / 1024;
21+
analogReadResolution(12);
22+
uint32_t raw = 0;
23+
for (int i=0; i<8;i++) {
24+
raw += analogRead(PIN_VBAT_READ);
25+
}
26+
return ((double)raw) * ADC_MULTIPLIER / 8 / 4096;
2327
}
2428
};
2529

0 commit comments

Comments
 (0)