Skip to content

Commit f403b9c

Browse files
committed
[LR2021 Fix frequency calibration for LF band
1 parent 0d3a63c commit f403b9c

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

src/modules/LR2021/LR2021_commands.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -238,6 +238,7 @@
238238
#define RADIOLIB_LR2021_CALIBRATE_FE_LF_PATH (0x00UL << 15) // 15 15 calibration path: low-frequency
239239
#define RADIOLIB_LR2021_CALIBRATE_FE_HF_PATH (0x01UL << 15) // 15 15 high-frequency
240240
#define RADIOLIB_LR2021_CAL_IMG_FREQ_TRIG_MHZ (20.0f)
241+
#define RADIOLIB_LR2021_LF_CUTOFF_FREQ (1500.0f)
241242

242243
// RADIOLIB_LR2021_CMD_GET_V_BAT
243244
#define RADIOLIB_LR2021_VBAT_FORMAT_RAW (0x00UL << 3) // 3 3 readout format: raw

src/modules/LR2021/LR2021_config.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ int16_t LR2021::setFrequency(float freq, bool skipCalibration) {
3333
for(; i < RADIOLIB_LR2021_MAX_CAL_ATTEMPTS; i++) {
3434
// get the nearest multiple of 4 MHz
3535
uint16_t frequencies[3] = { (uint16_t)((freq / 4.0f) + 0.5f), 0, 0 };
36-
frequencies[0] |= (freq > 1000.0f) ? RADIOLIB_LR2021_CALIBRATE_FE_HF_PATH : RADIOLIB_LR2021_CALIBRATE_FE_LF_PATH;
36+
frequencies[0] |= (freq > RADIOLIB_LR2021_LF_CUTOFF_FREQ) ? RADIOLIB_LR2021_CALIBRATE_FE_HF_PATH : RADIOLIB_LR2021_CALIBRATE_FE_LF_PATH;
3737
state = calibrateFrontEnd(const_cast<const uint16_t*>(frequencies));
3838

3939
// if something failed, check the device errors
@@ -67,7 +67,7 @@ int16_t LR2021::setFrequency(float freq, bool skipCalibration) {
6767
state = setRfFrequency((uint32_t)(freq*1000000.0f));
6868
RADIOLIB_ASSERT(state);
6969
this->freqMHz = freq;
70-
this->highFreq = (freq > 1100.0f);
70+
this->highFreq = (freq > RADIOLIB_LR2021_LF_CUTOFF_FREQ);
7171
return(state);
7272
}
7373

0 commit comments

Comments
 (0)