Expand description
§API related to FSK operations
This module provides an API for configuring and operating the LR2021 chip for FSK (Frequency Shift Keying) modulation. This API is for a generic FSK modulation using a packet structure compatible with previous Semtech chips (SX126x, SX127x, LR11xx). It supports fixed or dynamic length packets up to 511 bytes, with configurable CRC, address filtering, and whitening.
§Quick Start
Here’s a typical sequence to initialize the chip for FSK operations:
use lr2021::radio::PacketType;
use lr2021::fsk::{PblLenDetect, PldLenUnit, AddrComp, FskPktFormat, Crc, BitOrder};
use lr2021::{PulseShape, RxBw};
// Set packet type to FSK Legacy (compatible with SX126x/SX127x/LR11xx)
lr2021.set_packet_type(PacketType::FskLegacy).await.expect("Setting packet type");
// Configure FSK modulation (250kbps, BT=0.5 pulse shaping, 444kHz bandwidth, 62.5kHz deviation)
lr2021.set_fsk_modulation(
250_000, // Bitrate: 250 kbps
PulseShape::Bt0p5, // Pulse shaping: BT=0.5 Gaussian filter
RxBw::Bw444, // RX bandwidth: 444 kHz
62500 // Frequency deviation: 62.5 kHz
).await.expect("Setting FSK modulation");
// Configure syncword (32-bit, LSB first)
lr2021.set_fsk_syncword(
0xCD05DEAD, // Syncword value
BitOrder::LsbFirst, // Bit order: LSB first
32 // Syncword length: 32 bits
).await.expect("Setting syncword");
// Configure packet parameters
lr2021.set_fsk_packet(
8, // TX preamble length: 8 bits
PblLenDetect::None, // No specific preamble detection length
false, // No long preamble
PldLenUnit::Bytes, // Payload length unit: bytes
AddrComp::Off, // No address filtering
FskPktFormat::Variable8bit, // Variable length with 8-bit length field
10, // Maximum payload length: 10 bytes
Crc::Crc2Byte, // 2-byte CRC
true // DC-free encoding enabled (whitening)
).await.expect("Setting packet parameters");§Available Methods
§Core Configuration
set_fsk_modulation- Configure bitrate, pulse shaping, bandwidth, and frequency deviationset_fsk_packet- Set packet parameters (preamble, length format, CRC, addressing, whitening)set_fsk_syncword- Configure synchronization word (value, bit order, length)
§Status and Statistics
get_fsk_packet_status- Get packet status information (length, RSSI, LQI)get_fsk_rx_stats- Get reception statistics (packets received, errors, sync failures)
Re-exports§
pub use super::cmd::cmd_fsk::*;