use the new rx gain setting in lora

This commit is contained in:
2026-02-26 19:52:40 +01:00
parent da308fe23e
commit 62e586a776

View File

@@ -3,7 +3,7 @@ use embedded_hal::digital::OutputPin;
use embedded_hal_async::spi::SpiDevice; use embedded_hal_async::spi::SpiDevice;
use crate::error::RadioError; use crate::error::RadioError;
use crate::radio::{PaSelection, PacketType, Radio, RampTime, irq}; use crate::radio::{PaSelection, PacketType, Radio, RampTime, RxGain, irq};
use crate::traits::{Configure, Receive, Transmit}; use crate::traits::{Configure, Receive, Transmit};
#[derive(Clone, Copy, defmt::Format)] #[derive(Clone, Copy, defmt::Format)]
@@ -57,6 +57,7 @@ pub struct LoraConfig {
pub crc_on: bool, pub crc_on: bool,
pub iq_inverted: bool, pub iq_inverted: bool,
pub sync_word: u16, pub sync_word: u16,
pub rx_gain: RxGain,
pub pa: PaSelection, pub pa: PaSelection,
pub power_dbm: i8, pub power_dbm: i8,
pub ramp: RampTime, pub ramp: RampTime,
@@ -75,6 +76,7 @@ impl Default for LoraConfig {
crc_on: true, crc_on: true,
iq_inverted: false, iq_inverted: false,
sync_word: 0x1424, // private LoRa network sync_word: 0x1424, // private LoRa network
rx_gain: RxGain::PowerSaving,
pa: PaSelection::LowPower, pa: PaSelection::LowPower,
power_dbm: 14, power_dbm: 14,
ramp: RampTime::Us40, ramp: RampTime::Us40,
@@ -235,8 +237,10 @@ impl<SPI: SpiDevice, TX: OutputPin, RX: OutputPin, EN: OutputPin> Receive
// Stop RX timer on preamble detection (required for proper RX behavior) // Stop RX timer on preamble detection (required for proper RX behavior)
self.radio.set_stop_rx_timer_on_preamble(true).await?; self.radio.set_stop_rx_timer_on_preamble(true).await?;
// Set RX gain (0x94 = normal, 0x96 = boosted) // Set RX gain
self.radio.write_register(0x08AC, &[0x94]).await?; self.radio
.write_register(0x08AC, &[self.config.rx_gain as u8])
.await?;
// Convert ms to 15.625µs steps (ms * 64), 0 = single mode, 0xFFFFFF = continuous // Convert ms to 15.625µs steps (ms * 64), 0 = single mode, 0xFFFFFF = continuous
let timeout_steps = if timeout_ms == 0 { let timeout_steps = if timeout_ms == 0 {