Browse Source
Calibrate configured frequency for AGC reset
pull/1743/head
Wessel Nieboer
3 months ago
No known key found for this signature in database
GPG Key ID: 27BB1C3D63DEEFFF
4 changed files with
12 additions and
2 deletions
-
src/helpers/radiolib/CustomLR1110.h
-
src/helpers/radiolib/CustomLR1110Wrapper.h
-
src/helpers/radiolib/LR11x0Reset.h
-
src/helpers/radiolib/SX126xReset.h
|
|
|
@ -20,6 +20,8 @@ class CustomLR1110 : public LR1110 { |
|
|
|
return len; |
|
|
|
} |
|
|
|
|
|
|
|
float getFreqMHz() const { return freqMHz; } |
|
|
|
|
|
|
|
bool isReceiving() { |
|
|
|
uint16_t irq = getIrqStatus(); |
|
|
|
bool detected = ((irq & RADIOLIB_LR11X0_IRQ_SYNC_WORD_HEADER_VALID) || (irq & RADIOLIB_LR11X0_IRQ_PREAMBLE_DETECTED)); |
|
|
|
|
|
|
|
@ -7,7 +7,7 @@ |
|
|
|
class CustomLR1110Wrapper : public RadioLibWrapper { |
|
|
|
public: |
|
|
|
CustomLR1110Wrapper(CustomLR1110& radio, mesh::MainBoard& board) : RadioLibWrapper(radio, board) { } |
|
|
|
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio); } |
|
|
|
void doResetAGC() override { lr11x0ResetAGC((LR11x0 *)_radio, ((CustomLR1110 *)_radio)->getFreqMHz()); } |
|
|
|
bool isReceivingPacket() override { |
|
|
|
return ((CustomLR1110 *)_radio)->isReceiving(); |
|
|
|
} |
|
|
|
|
|
|
|
@ -5,12 +5,16 @@ |
|
|
|
// Full receiver reset for LR11x0-family chips (LR1110, LR1120, LR1121).
|
|
|
|
// Warm sleep powers down analog, calibrate(0x3F) refreshes all calibration blocks,
|
|
|
|
// then re-applies RX settings that calibration may reset.
|
|
|
|
inline void lr11x0ResetAGC(LR11x0* radio) { |
|
|
|
inline void lr11x0ResetAGC(LR11x0* radio, float freqMHz) { |
|
|
|
radio->sleep(true, 0); |
|
|
|
radio->standby(RADIOLIB_LR11X0_STANDBY_RC, true); |
|
|
|
|
|
|
|
radio->calibrate(RADIOLIB_LR11X0_CALIBRATE_ALL); |
|
|
|
|
|
|
|
// calibrate(0x3F) defaults image calibration to an unknown band.
|
|
|
|
// Re-calibrate for the actual operating frequency (band=4MHz matches RadioLib default).
|
|
|
|
radio->calibrateImageRejection(freqMHz - 4.0f, freqMHz + 4.0f); |
|
|
|
|
|
|
|
#ifdef RX_BOOSTED_GAIN |
|
|
|
radio->setRxBoostedGainMode(RX_BOOSTED_GAIN); |
|
|
|
#endif |
|
|
|
|
|
|
|
@ -18,6 +18,10 @@ inline void sx126xResetAGC(SX126x* radio) { |
|
|
|
radio->mod->hal->yield(); |
|
|
|
} |
|
|
|
|
|
|
|
// Calibrate(0x7F) defaults image calibration to 902-928MHz band.
|
|
|
|
// Re-calibrate for the actual operating frequency.
|
|
|
|
radio->calibrateImage(radio->freqMHz); |
|
|
|
|
|
|
|
#ifdef SX126X_DIO2_AS_RF_SWITCH |
|
|
|
radio->setDio2AsRfSwitch(SX126X_DIO2_AS_RF_SWITCH); |
|
|
|
#endif |
|
|
|
|