pub struct Lr2021<O, SPI, M: BusyPin> { /* private fields */ }Expand description
LR2021 Device
Implementations§
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn get_status(&mut self) -> Result<(Status, Intr), Lr2021Error>
pub async fn get_status(&mut self) -> Result<(Status, Intr), Lr2021Error>
Read status and interrupt from the chip
Sourcepub async fn get_errors(&mut self) -> Result<ErrorsRsp, Lr2021Error>
pub async fn get_errors(&mut self) -> Result<ErrorsRsp, Lr2021Error>
Read status and interrupt from the chip
Sourcepub async fn get_version(&mut self) -> Result<VersionRsp, Lr2021Error>
pub async fn get_version(&mut self) -> Result<VersionRsp, Lr2021Error>
Read status and interrupt from the chip
Sourcepub async fn get_and_clear_irq(&mut self) -> Result<Intr, Lr2021Error>
pub async fn get_and_clear_irq(&mut self) -> Result<Intr, Lr2021Error>
Read interrupt from the chip and clear them all
Sourcepub async fn clear_irqs(&mut self, intr: Intr) -> Result<(), Lr2021Error>
pub async fn clear_irqs(&mut self, intr: Intr) -> Result<(), Lr2021Error>
Set the RF channel (in Hz)
Sourcepub async fn calib_fe(&mut self, freqs_4m: &[u16]) -> Result<(), Lr2021Error>
pub async fn calib_fe(&mut self, freqs_4m: &[u16]) -> Result<(), Lr2021Error>
Run calibration on up to 3 frequencies on 16b (MSB encode RX Path) If none, use current frequency
Sourcepub async fn set_chip_mode(
&mut self,
chip_mode: ChipMode,
) -> Result<(), Lr2021Error>
pub async fn set_chip_mode( &mut self, chip_mode: ChipMode, ) -> Result<(), Lr2021Error>
Set Tx power and ramp time
Sourcepub async fn set_dio_irq(
&mut self,
dio: u8,
intr_en: Intr,
) -> Result<(), Lr2021Error>
pub async fn set_dio_irq( &mut self, dio: u8, intr_en: Intr, ) -> Result<(), Lr2021Error>
Configure a pin as IRQ and enable interrupts for this pin
Sourcepub async fn wr_tx_fifo_from(
&mut self,
buffer: &[u8],
) -> Result<(), Lr2021Error>
pub async fn wr_tx_fifo_from( &mut self, buffer: &[u8], ) -> Result<(), Lr2021Error>
Write data to the TX FIFO Check number of bytes available with get_tx_fifo_lvl()
Sourcepub async fn wr_tx_fifo(&mut self, len: usize) -> Result<(), Lr2021Error>
pub async fn wr_tx_fifo(&mut self, len: usize) -> Result<(), Lr2021Error>
Write data to the TX FIFO Check number of bytes available with get_tx_fifo_lvl()
Sourcepub async fn clear_tx_fifo(&mut self) -> Result<(), Lr2021Error>
pub async fn clear_tx_fifo(&mut self) -> Result<(), Lr2021Error>
Clear TX Fifo
Sourcepub async fn get_tx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>
pub async fn get_tx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>
Return number of byte in TX FIFO
Sourcepub async fn rd_rx_fifo_to(
&mut self,
buffer: &mut [u8],
) -> Result<(), Lr2021Error>
pub async fn rd_rx_fifo_to( &mut self, buffer: &mut [u8], ) -> Result<(), Lr2021Error>
Read data from the RX FIFO
Sourcepub async fn rd_rx_fifo(&mut self, len: usize) -> Result<(), Lr2021Error>
pub async fn rd_rx_fifo(&mut self, len: usize) -> Result<(), Lr2021Error>
Read data from the RX FIFO to the local buffer
Sourcepub async fn get_rx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>
pub async fn get_rx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>
Return number of byte in RX FIFO
Sourcepub async fn clear_rx_fifo(&mut self) -> Result<(), Lr2021Error>
pub async fn clear_rx_fifo(&mut self) -> Result<(), Lr2021Error>
Clear RX Fifo
Sourcepub async fn get_pram_info(&mut self) -> Result<Option<(u8, u8)>, Lr2021Error>
pub async fn get_pram_info(&mut self) -> Result<Option<(u8, u8)>, Lr2021Error>
Return type/version of the Patch Ram if loaded. None if no Patch Ram available
Sourcepub async fn rd_mem(&mut self, addr: u32, nb32: u8) -> Result<(), Lr2021Error>
pub async fn rd_mem(&mut self, addr: u32, nb32: u8) -> Result<(), Lr2021Error>
Read nb32 qword (max 40) from memory and save them inside local buffer
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_rf(&mut self, freq: u32) -> Result<(), Lr2021Error>
pub async fn set_rf(&mut self, freq: u32) -> Result<(), Lr2021Error>
Set the RF channel (in Hz)
Sourcepub async fn set_rx_path(
&mut self,
rx_path: RxPath,
rx_boost: u8,
) -> Result<(), Lr2021Error>
pub async fn set_rx_path( &mut self, rx_path: RxPath, rx_boost: u8, ) -> Result<(), Lr2021Error>
Set the RX Path (LF/HF)
Sourcepub async fn set_packet_type(
&mut self,
packet_type: PacketType,
) -> Result<(), Lr2021Error>
pub async fn set_packet_type( &mut self, packet_type: PacketType, ) -> Result<(), Lr2021Error>
Set the packet type
Sourcepub async fn set_tx_params(
&mut self,
tx_power: u8,
ramp_time: RampTime,
) -> Result<(), Lr2021Error>
pub async fn set_tx_params( &mut self, tx_power: u8, ramp_time: RampTime, ) -> Result<(), Lr2021Error>
Set Tx power and ramp time
Sourcepub async fn set_pa_lf(
&mut self,
pa_lf_mode: PaLfMode,
pa_lf_duty_cycle: u8,
pa_lf_slices: u8,
) -> Result<(), Lr2021Error>
pub async fn set_pa_lf( &mut self, pa_lf_mode: PaLfMode, pa_lf_duty_cycle: u8, pa_lf_slices: u8, ) -> Result<(), Lr2021Error>
Configure LF Power Amplifier
Sourcepub async fn set_pa_hf(&mut self) -> Result<(), Lr2021Error>
pub async fn set_pa_hf(&mut self) -> Result<(), Lr2021Error>
Configure HF Power Amplifier
Sourcepub async fn set_fallback(
&mut self,
fallback_mode: FallbackMode,
) -> Result<(), Lr2021Error>
pub async fn set_fallback( &mut self, fallback_mode: FallbackMode, ) -> Result<(), Lr2021Error>
Set the Fallback mode after TX/RX
Sourcepub async fn set_tx(&mut self, tx_timeout: u32) -> Result<(), Lr2021Error>
pub async fn set_tx(&mut self, tx_timeout: u32) -> Result<(), Lr2021Error>
Set chip in TX mode. Set timeout to 0 or to a value longer than the packet duration.
Sourcepub async fn set_rx(
&mut self,
rx_timeout: u32,
wait_ready: bool,
) -> Result<(), Lr2021Error>
pub async fn set_rx( &mut self, rx_timeout: u32, wait_ready: bool, ) -> Result<(), Lr2021Error>
Set chip in RX mode. A timeout equal to 0 means a single reception, the value 0xFFFFFF is for continuous RX (i.e. always restart reception) and any other value, the chip will go back to its fallback mode if a reception does not occur before the timeout is elapsed
Sourcepub async fn set_cad_params(
&mut self,
cad_timeout: u32,
threshold: u8,
exit_mode: ExitMode,
trx_timeout: u32,
) -> Result<(), Lr2021Error>
pub async fn set_cad_params( &mut self, cad_timeout: u32, threshold: u8, exit_mode: ExitMode, trx_timeout: u32, ) -> Result<(), Lr2021Error>
Configure parameters for Channel Activity Detection
- CAD Timeout is the maximum time spent measuring RSSI in 31.25ns step
- Threshold in -dBm to determine if a signal is present
- Exit Mode: controls what happens after CAD (nothing, TX if nothing, RX if something)
- TRX Timeout is the timeout used in case the exit_mode triggers a TX or RX
Sourcepub async fn set_cad(&mut self) -> Result<(), Lr2021Error>
pub async fn set_cad(&mut self) -> Result<(), Lr2021Error>
Set chip in Channel activity Detection mode CAD is configured with set_cad_params
Sourcepub async fn set_cca(&mut self, duration: u32) -> Result<(), Lr2021Error>
pub async fn set_cca(&mut self, duration: u32) -> Result<(), Lr2021Error>
Set chip in CCA (Clear Channel Assesment) for duration (31.25ns)
Sourcepub async fn get_cca_result(&mut self) -> Result<CcaResultRsp, Lr2021Error>
pub async fn get_cca_result(&mut self) -> Result<CcaResultRsp, Lr2021Error>
Set chip in CCA (Clear Channel Assesment) for duration (31.25ns)
Sourcepub async fn set_rx_gain(&mut self, gain: u8) -> Result<(), Lr2021Error>
pub async fn set_rx_gain(&mut self, gain: u8) -> Result<(), Lr2021Error>
Configure the radio gain manually:
- Gain 0 enable the automatic gain selection (default setting)
- Max gain is 13
Sourcepub async fn clear_rx_stats(&mut self) -> Result<(), Lr2021Error>
pub async fn clear_rx_stats(&mut self) -> Result<(), Lr2021Error>
Clear RX stats
Sourcepub async fn get_rx_pkt_len(&mut self) -> Result<u16, Lr2021Error>
pub async fn get_rx_pkt_len(&mut self) -> Result<u16, Lr2021Error>
Return length of last packet received
Sourcepub async fn force_crc_out(&mut self) -> Result<(), Lr2021Error>
pub async fn force_crc_out(&mut self) -> Result<(), Lr2021Error>
Output CRC to the FIFO even when already checked by hardware
Sourcepub async fn get_rssi_inst(&mut self) -> Result<u16, Lr2021Error>
pub async fn get_rssi_inst(&mut self) -> Result<u16, Lr2021Error>
Measure RSSI instantaneous
Sourcepub async fn get_rssi_avg(
&mut self,
duration: Duration,
) -> Result<u16, Lr2021Error>
pub async fn get_rssi_avg( &mut self, duration: Duration, ) -> Result<u16, Lr2021Error>
Measure an average RSSI Note: Digital Front-End settings are changed for the time of the measurement
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_lora_modulation(
&mut self,
sf: Sf,
bw: LoraBw,
cr: LoraCr,
ldro: Ldro,
) -> Result<(), Lr2021Error>
pub async fn set_lora_modulation( &mut self, sf: Sf, bw: LoraBw, cr: LoraCr, ldro: Ldro, ) -> Result<(), Lr2021Error>
Set LoRa Modulation parameters
Sourcepub async fn set_lora_packet(
&mut self,
pbl_len: u16,
payload_len: u8,
header_type: HeaderType,
crc_en: bool,
invert_iq: bool,
) -> Result<(), Lr2021Error>
pub async fn set_lora_packet( &mut self, pbl_len: u16, payload_len: u8, header_type: HeaderType, crc_en: bool, invert_iq: bool, ) -> Result<(), Lr2021Error>
Set LoRa Packet parameters
Sourcepub async fn set_lora_syncword(
&mut self,
syncword: u8,
) -> Result<(), Lr2021Error>
pub async fn set_lora_syncword( &mut self, syncword: u8, ) -> Result<(), Lr2021Error>
Set LoRa Syncword using legacy (SX127x) 1B notation: 0x34 for public network, 0x12 for private
Sourcepub async fn set_lora_syncword_ext(
&mut self,
s1: u8,
s2: u8,
) -> Result<(), Lr2021Error>
pub async fn set_lora_syncword_ext( &mut self, s1: u8, s2: u8, ) -> Result<(), Lr2021Error>
Set LoRa Syncword, using 2B notation (2 values on 5b each) Public network is (6,8) and private network is (2,4)
Sourcepub async fn set_lora_synch_timeout(
&mut self,
timeout: u8,
format: TimeoutFormat,
) -> Result<(), Lr2021Error>
pub async fn set_lora_synch_timeout( &mut self, timeout: u8, format: TimeoutFormat, ) -> Result<(), Lr2021Error>
Set synchronisation timeout Timeout is given in number of symbol: either the direct value or with mantissa/exponent (like SX126x)
Sourcepub async fn set_lora_address(
&mut self,
len: AddrLen,
pos: u8,
addr: u64,
) -> Result<(), Lr2021Error>
pub async fn set_lora_address( &mut self, len: AddrLen, pos: u8, addr: u64, ) -> Result<(), Lr2021Error>
Set address for address filtering Length is the address length in number of byte 0 (no address filtering, default) up to 8 Pos is the first byte in the payload the address appears
Sourcepub async fn get_lora_packet_status(
&mut self,
) -> Result<LoraPacketStatusRsp, Lr2021Error>
pub async fn get_lora_packet_status( &mut self, ) -> Result<LoraPacketStatusRsp, Lr2021Error>
Return Information about last packet received
Sourcepub async fn get_lora_packet_status_adv(
&mut self,
) -> Result<LoraPacketStatusRspAdv, Lr2021Error>
pub async fn get_lora_packet_status_adv( &mut self, ) -> Result<LoraPacketStatusRspAdv, Lr2021Error>
Return extended Information about last packet received
Sourcepub async fn get_lora_rx_stats(&mut self) -> Result<LoraRxStatsRsp, Lr2021Error>
pub async fn get_lora_rx_stats(&mut self) -> Result<LoraRxStatsRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn set_lora_cad_params(
&mut self,
nb_symbols: u8,
pbl_any: bool,
pnr_delta: u8,
exit_mode: ExitMode,
timeout: u32,
det_peak: Option<u8>,
) -> Result<(), Lr2021Error>
pub async fn set_lora_cad_params( &mut self, nb_symbols: u8, pbl_any: bool, pnr_delta: u8, exit_mode: ExitMode, timeout: u32, det_peak: Option<u8>, ) -> Result<(), Lr2021Error>
Set LoRa Channel Activity Detection parameters
- nb_symbols is the number of symbols for detection: between 1 and 15, use 4 for ideal performances.
- pbl_any: set to false when explicitly searching for preamble, and 1 for any LoRa activity. Note that even when set to 0, CAD can still detect non-preamble, just less likely.
- pnr_delta: Value between 0 and 15 to shorten the CAD time when there is obvisouly no LoRa activity. Set to 0 to always listen for the full duration, set to ~10 for optimal performances. Higher value increase the chance to miss activity, while lower value will limit the chance to stop CAD early
- exit_mode: Choose what happens after the CAD: fallback mode, RX or TX (for Listen-Before-Talk)
- timeout: defines the timeout for the following RX or TX if exit mode is not CAD_ONLY
- det_peak: control the detection threshold. Use None to let firmware automatically decide the threshold based on the SF/BW/nb_symbols/pnr_delta
Sourcepub async fn set_lora_cad(&mut self) -> Result<(), Lr2021Error>
pub async fn set_lora_cad(&mut self) -> Result<(), Lr2021Error>
Start a LoRa Channel Activity Detection (CAD)
Sourcepub async fn comp_sx127x_en(
&mut self,
ret_en: Option<u8>,
) -> Result<(), Lr2021Error>
pub async fn comp_sx127x_en( &mut self, ret_en: Option<u8>, ) -> Result<(), Lr2021Error>
Enable compatibility with SX127x for SF6 communication and syncword format Must be called after each SetLoraModulation The retention enable allows to define a register slot to save this copatibility mode in retention
Sourcepub async fn set_lora_sidedet_cfg(
&mut self,
cfg: &[SidedetCfg],
) -> Result<(), Lr2021Error>
pub async fn set_lora_sidedet_cfg( &mut self, cfg: &[SidedetCfg], ) -> Result<(), Lr2021Error>
Configure Side-Detector allowing multiple SF to be detected Must be called after set_lora_modulation If cfg is an empty slice, this disabled all side-detector
Sourcepub async fn set_lora_sidedet_syncword(
&mut self,
sw: &[u8],
) -> Result<(), Lr2021Error>
pub async fn set_lora_sidedet_syncword( &mut self, sw: &[u8], ) -> Result<(), Lr2021Error>
Configure Side-Detector Syncword using basic syncword format
Sourcepub async fn set_lora_preamble_modulation(
&mut self,
en: bool,
dram_ret: u8,
wakeup_time: u16,
min_sleep_time: u32,
) -> Result<(), Lr2021Error>
pub async fn set_lora_preamble_modulation( &mut self, en: bool, dram_ret: u8, wakeup_time: u16, min_sleep_time: u32, ) -> Result<(), Lr2021Error>
Long preamble can be modulated in phase in order to provide information about how many symbols are left This allows a receiver to go back to sleep if beginning of the frame starts in a long time
Sourcepub async fn set_ranging_dev_addr(
&mut self,
addr: u32,
length: Option<CheckLength>,
) -> Result<(), Lr2021Error>
pub async fn set_ranging_dev_addr( &mut self, addr: u32, length: Option<CheckLength>, ) -> Result<(), Lr2021Error>
Set the device address for ranging operation The device will answer to ranging request only if the request address matches the device address The length allows to define how many bytes from the address are checked (starting from LSB)
Sourcepub async fn set_ranging_req_addr(
&mut self,
addr: u32,
) -> Result<(), Lr2021Error>
pub async fn set_ranging_req_addr( &mut self, addr: u32, ) -> Result<(), Lr2021Error>
Set the request address for ranging operation
Sourcepub async fn set_ranging_txrx_delay(
&mut self,
delay: u32,
) -> Result<(), Lr2021Error>
pub async fn set_ranging_txrx_delay( &mut self, delay: u32, ) -> Result<(), Lr2021Error>
Set the ranging calibration value
Sourcepub async fn set_ranging_params(
&mut self,
extended: bool,
spy_mode: bool,
nb_symbols: u8,
) -> Result<(), Lr2021Error>
pub async fn set_ranging_params( &mut self, extended: bool, spy_mode: bool, nb_symbols: u8, ) -> Result<(), Lr2021Error>
Set the ranging parameters: Extended/Spy and number of symbols Extended mode initiate a second exchange with an inverted direction to improve accuracy and provide some relative speed indication Spy mode allows to estimate distance between two device while they are performing a ranging exchange. Number of symbols should typically be between 8 to 16 symbols, with 12 being close to optimal performances
Sourcepub async fn get_ranging_status(&mut self) -> Result<RangingStatus, Lr2021Error>
pub async fn get_ranging_status(&mut self) -> Result<RangingStatus, Lr2021Error>
Return info if last ranging exchange was valid
Sourcepub async fn get_ranging_result(
&mut self,
) -> Result<RangingResultRsp, Lr2021Error>
pub async fn get_ranging_result( &mut self, ) -> Result<RangingResultRsp, Lr2021Error>
Return the result of last ranging exchange (round-trip time of flight and RSSI) The distance is provided
Sourcepub async fn get_ranging_ext_result(
&mut self,
) -> Result<RangingExtResultRsp, Lr2021Error>
pub async fn get_ranging_ext_result( &mut self, ) -> Result<RangingExtResultRsp, Lr2021Error>
Return the result of last extended ranging exchange (round-trip time of flight and RSSI for both exchange) The round-trip time of flight can be converted in meter with the formula: rng150/(2^12Bandwidth)
Sourcepub async fn get_ranging_gain(
&mut self,
) -> Result<RangingGainStepRsp, Lr2021Error>
pub async fn get_ranging_gain( &mut self, ) -> Result<RangingGainStepRsp, Lr2021Error>
Return the gain step used during ranging (the second gain step is only valid for extended ranging) This is mainly for debug, since gain can influence very slightly the results
Sourcepub async fn get_ranging_stats(
&mut self,
) -> Result<RangingStatsRsp, Lr2021Error>
pub async fn get_ranging_stats( &mut self, ) -> Result<RangingStatsRsp, Lr2021Error>
Return statistics about ranging exchanges
Sourcepub async fn set_lora_timing_sync(
&mut self,
mode: TimingSyncMode,
dio_num: u8,
) -> Result<(), Lr2021Error>
pub async fn set_lora_timing_sync( &mut self, mode: TimingSyncMode, dio_num: u8, ) -> Result<(), Lr2021Error>
Set Lora in Timing Synchronisation mode The initiator sends a special frame when the dio is asserted The responder is in reception mode and will assert the DIO a known delay after reception of the TimingSync packet
Sourcepub async fn set_lora_timing_sync_pulse(
&mut self,
delay: u32,
width: TimingSyncPulseWidth,
) -> Result<(), Lr2021Error>
pub async fn set_lora_timing_sync_pulse( &mut self, delay: u32, width: TimingSyncPulseWidth, ) -> Result<(), Lr2021Error>
Configure the LoRa TimingSync Pulse for the initiator (delay and width)
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_ble_modulation(
&mut self,
mode: BleMode,
) -> Result<(), Lr2021Error>
pub async fn set_ble_modulation( &mut self, mode: BleMode, ) -> Result<(), Lr2021Error>
Set BLE Mode (1M, 2M, 500k, 125k)
Sourcepub async fn set_ble_params(
&mut self,
crc_in_fifo: bool,
channel_type: ChannelType,
whit_init: u8,
crc_init: u32,
syncword: u32,
) -> Result<(), Lr2021Error>
pub async fn set_ble_params( &mut self, crc_in_fifo: bool, channel_type: ChannelType, whit_init: u8, crc_init: u32, syncword: u32, ) -> Result<(), Lr2021Error>
Set BLE parameters: Channel type (advertising, Header16/24b), Whitening & CRC init, SyncWord/AccessCode
Sourcepub async fn set_ble_tx(&mut self, len: u8) -> Result<(), Lr2021Error>
pub async fn set_ble_tx(&mut self, len: u8) -> Result<(), Lr2021Error>
Set the PDU length and send the packet PDU must be ready in FIFO
Sourcepub async fn set_ble_tx_pdu_len(&mut self, len: u8) -> Result<(), Lr2021Error>
pub async fn set_ble_tx_pdu_len(&mut self, len: u8) -> Result<(), Lr2021Error>
Set the PDU length Useful compare to set_ble_tx when using a pin trigger to control the exact transmit time
Sourcepub async fn get_ble_packet_status(
&mut self,
) -> Result<BlePacketStatusRsp, Lr2021Error>
pub async fn get_ble_packet_status( &mut self, ) -> Result<BlePacketStatusRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn get_ble_rx_stats(&mut self) -> Result<BleRxStatsRsp, Lr2021Error>
pub async fn get_ble_rx_stats(&mut self) -> Result<BleRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_ble_rx_stats_adv(
&mut self,
) -> Result<BleRxStatsRspAdv, Lr2021Error>
pub async fn get_ble_rx_stats_adv( &mut self, ) -> Result<BleRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_flrc_modulation(
&mut self,
bitrate: FlrcBitrate,
cr: FlrcCr,
pulse_shape: PulseShape,
) -> Result<(), Lr2021Error>
pub async fn set_flrc_modulation( &mut self, bitrate: FlrcBitrate, cr: FlrcCr, pulse_shape: PulseShape, ) -> Result<(), Lr2021Error>
Set Modulation parameters: raw bitrate, coding rate and pulse shaping
Sourcepub async fn set_flrc_packet(
&mut self,
params: &FlrcPacketParams,
) -> Result<(), Lr2021Error>
pub async fn set_flrc_packet( &mut self, params: &FlrcPacketParams, ) -> Result<(), Lr2021Error>
Set FLRC packet parameters: preamble, syncword, header implicit/explicit, CRC and packet length (max 511)
Sourcepub async fn set_flrc_syncword(
&mut self,
sw_num: u8,
syncword: u32,
is_16b: bool,
) -> Result<(), Lr2021Error>
pub async fn set_flrc_syncword( &mut self, sw_num: u8, syncword: u32, is_16b: bool, ) -> Result<(), Lr2021Error>
Configure one of the three possible syncword
Sourcepub async fn get_flrc_packet_status(
&mut self,
) -> Result<FlrcPacketStatusRsp, Lr2021Error>
pub async fn get_flrc_packet_status( &mut self, ) -> Result<FlrcPacketStatusRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn get_flrc_rx_stats(&mut self) -> Result<FlrcRxStatsRsp, Lr2021Error>
pub async fn get_flrc_rx_stats(&mut self) -> Result<FlrcRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_flrc_rx_stats_adv(
&mut self,
) -> Result<FlrcRxStatsRspAdv, Lr2021Error>
pub async fn get_flrc_rx_stats_adv( &mut self, ) -> Result<FlrcRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_ook_modulation(
&mut self,
bitrate: u32,
rx_bw: RxBw,
pulse_shape: PulseShape,
) -> Result<(), Lr2021Error>
pub async fn set_ook_modulation( &mut self, bitrate: u32, rx_bw: RxBw, pulse_shape: PulseShape, ) -> Result<(), Lr2021Error>
Set Modulation parameters: raw bitrate, bandwidth and pulse shaping
Sourcepub async fn set_ook_packet(
&mut self,
pre_len_tx: u16,
addr_comp: AddrComp,
pkt_format: PktFormat,
pld_len: u16,
crc: Crc,
encoding: Encoding,
) -> Result<(), Lr2021Error>
pub async fn set_ook_packet( &mut self, pre_len_tx: u16, addr_comp: AddrComp, pkt_format: PktFormat, pld_len: u16, crc: Crc, encoding: Encoding, ) -> Result<(), Lr2021Error>
Set OOK packet parameter: preamble length (TX), Address filtering, header implicit/explicit, payload length, CRC and encoding
Sourcepub async fn set_ook_detector(
&mut self,
preamble_pattern: u16,
pattern_length: u8,
pattern_num_repeats: u8,
sw_is_raw: bool,
sfd_kind: SfdKind,
sfd_length: u8,
) -> Result<(), Lr2021Error>
pub async fn set_ook_detector( &mut self, preamble_pattern: u16, pattern_length: u8, pattern_num_repeats: u8, sw_is_raw: bool, sfd_kind: SfdKind, sfd_length: u8, ) -> Result<(), Lr2021Error>
Set OOK detector: Preamble (pattern/length/repetition), Sync encoding, Start of Frame delimiter
Sourcepub async fn set_ook_syncword(
&mut self,
syncword: u32,
bit_order: BitOrder,
nb_bits: u8,
) -> Result<(), Lr2021Error>
pub async fn set_ook_syncword( &mut self, syncword: u32, bit_order: BitOrder, nb_bits: u8, ) -> Result<(), Lr2021Error>
Configure syncword (value, length and bit order)
Sourcepub async fn set_ook_crc(
&mut self,
polynom: u32,
init: u32,
) -> Result<(), Lr2021Error>
pub async fn set_ook_crc( &mut self, polynom: u32, init: u32, ) -> Result<(), Lr2021Error>
Configure OOK polynom and init value
Sourcepub async fn set_ook_thr(&mut self, threshold: i8) -> Result<(), Lr2021Error>
pub async fn set_ook_thr(&mut self, threshold: i8) -> Result<(), Lr2021Error>
Configure OOK Detection absolute threshold Typically add a few dB above the ambiant noise level
Sourcepub async fn set_ook_adsb(&mut self) -> Result<(), Lr2021Error>
pub async fn set_ook_adsb(&mut self) -> Result<(), Lr2021Error>
Configure OOK receiver for ADS-B:
- Modulation = 2Mb/s with 3MHz bandwidth
- Packet: Fixed payload 11B + 3B CRC with inverted manchester encoding
- Detector: Pattern 15b 0x285 and no SFD
Sourcepub async fn get_ook_packet_status(
&mut self,
) -> Result<OokPacketStatusRsp, Lr2021Error>
pub async fn get_ook_packet_status( &mut self, ) -> Result<OokPacketStatusRsp, Lr2021Error>
Return stats about last packet received: length, RSSI, LQI
Sourcepub async fn get_ook_rx_stats(&mut self) -> Result<OokRxStatsRsp, Lr2021Error>
pub async fn get_ook_rx_stats(&mut self) -> Result<OokRxStatsRsp, Lr2021Error>
Return basic RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_fsk_modulation(
&mut self,
bitrate: u32,
pulse_shape: PulseShape,
rx_bw: RxBw,
fdev: u32,
) -> Result<(), Lr2021Error>
pub async fn set_fsk_modulation( &mut self, bitrate: u32, pulse_shape: PulseShape, rx_bw: RxBw, fdev: u32, ) -> Result<(), Lr2021Error>
Set Modulation parameters: raw bitrate, pulse shaping, Bandwidth and fdev
Sourcepub async fn set_fsk_packet(
&mut self,
pbl_len_tx: u16,
pbl_len_detect: PblLenDetect,
pbl_long: bool,
pld_len_unit: PldLenUnit,
addr_comp: AddrComp,
fsk_pkt_format: FskPktFormat,
pld_len: u16,
crc: Crc,
dc_free: bool,
) -> Result<(), Lr2021Error>
pub async fn set_fsk_packet( &mut self, pbl_len_tx: u16, pbl_len_detect: PblLenDetect, pbl_long: bool, pld_len_unit: PldLenUnit, addr_comp: AddrComp, fsk_pkt_format: FskPktFormat, pld_len: u16, crc: Crc, dc_free: bool, ) -> Result<(), Lr2021Error>
Set FLRC packet parameters: preamble, syncword, header implicit/explicit, CRC and packet length (max 511)
Sourcepub async fn set_fsk_syncword(
&mut self,
syncword: u64,
bit_order: BitOrder,
nb_bits: u8,
) -> Result<(), Lr2021Error>
pub async fn set_fsk_syncword( &mut self, syncword: u64, bit_order: BitOrder, nb_bits: u8, ) -> Result<(), Lr2021Error>
Configure syncword
Sourcepub async fn get_fsk_packet_status(
&mut self,
) -> Result<FskPacketStatusRsp, Lr2021Error>
pub async fn get_fsk_packet_status( &mut self, ) -> Result<FskPacketStatusRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn get_fsk_rx_stats(&mut self) -> Result<FskRxStatsRsp, Lr2021Error>
pub async fn get_fsk_rx_stats(&mut self) -> Result<FskRxStatsRsp, Lr2021Error>
Return basic RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_zigbee_packet(
&mut self,
mode: ZigbeeMode,
rx_bw: RxBw,
pld_len: u8,
pbl_len_tx: u16,
addr_filt_en: bool,
fcs_mode: FcsMode,
) -> Result<(), Lr2021Error>
pub async fn set_zigbee_packet( &mut self, mode: ZigbeeMode, rx_bw: RxBw, pld_len: u8, pbl_len_tx: u16, addr_filt_en: bool, fcs_mode: FcsMode, ) -> Result<(), Lr2021Error>
Set Zigbee packet parameters: preamble, Bandwidth, Payload length, Address filtering, FCS handling (software/Hardware)
Sourcepub async fn set_zigbee_packet_len(
&mut self,
pld_len: u8,
) -> Result<(), Lr2021Error>
pub async fn set_zigbee_packet_len( &mut self, pld_len: u8, ) -> Result<(), Lr2021Error>
Sets the zigbee packet length without calling set_zigbee_packet which takes longer The function set_zigbee_packet must have been called once before !
Sourcepub async fn set_zigbee_address(
&mut self,
long_dest_addr: u64,
short_dest_addr: u16,
pan_id: u16,
trans_id: u8,
) -> Result<(), Lr2021Error>
pub async fn set_zigbee_address( &mut self, long_dest_addr: u64, short_dest_addr: u16, pan_id: u16, trans_id: u8, ) -> Result<(), Lr2021Error>
Configure the different Zigbee addresses for filtering in RX. Frames that don’t match the addresses raise an address error IRQ and reception is aborted. When a packet is received, the destination address and PAN ID are both checked. Multi-cast is not supported or filtered and must be handled by the host
Sourcepub async fn get_zigbee_packet_status(
&mut self,
) -> Result<ZigbeePacketStatusRsp, Lr2021Error>
pub async fn get_zigbee_packet_status( &mut self, ) -> Result<ZigbeePacketStatusRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn get_zigbee_rx_stats(
&mut self,
) -> Result<ZigbeeRxStatsRsp, Lr2021Error>
pub async fn get_zigbee_rx_stats( &mut self, ) -> Result<ZigbeeRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_zigbee_rx_stats_adv(
&mut self,
) -> Result<ZigbeeRxStatsRspAdv, Lr2021Error>
pub async fn get_zigbee_rx_stats_adv( &mut self, ) -> Result<ZigbeeRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_zwave_packet(
&mut self,
params: &ZwavePacketParams,
) -> Result<(), Lr2021Error>
pub async fn set_zwave_packet( &mut self, params: &ZwavePacketParams, ) -> Result<(), Lr2021Error>
Set ZWave packet parameters: preamble, syncword, header implicit/explicit, CRC and packet length (max 511)
Sourcepub async fn set_zwave_home_id(&mut self, id: u32) -> Result<(), Lr2021Error>
pub async fn set_zwave_home_id(&mut self, id: u32) -> Result<(), Lr2021Error>
Sets the zwave Home ID, used as address filter in RX
Sourcepub async fn set_zwave_beam_filt(
&mut self,
beam_tag: u8,
addr_len: AddrLen,
node_id: u16,
id_hash: u8,
) -> Result<(), Lr2021Error>
pub async fn set_zwave_beam_filt( &mut self, beam_tag: u8, addr_len: AddrLen, node_id: u16, id_hash: u8, ) -> Result<(), Lr2021Error>
Sets the zwave Beam frame filtering
Sourcepub async fn set_zwave_scan_config(
&mut self,
cfg: &ZwaveScanCfg,
) -> Result<(), Lr2021Error>
pub async fn set_zwave_scan_config( &mut self, cfg: &ZwaveScanCfg, ) -> Result<(), Lr2021Error>
Configure scan: number of active channel, their mode and frequency
Sourcepub async fn start_zwave_scan(&mut self) -> Result<(), Lr2021Error>
pub async fn start_zwave_scan(&mut self) -> Result<(), Lr2021Error>
Start the ZWave Scan: it will alternate between up to 4 channels to find an incoming packet
Sourcepub async fn get_zwave_packet_status(
&mut self,
) -> Result<ZwavePacketStatusRsp, Lr2021Error>
pub async fn get_zwave_packet_status( &mut self, ) -> Result<ZwavePacketStatusRsp, Lr2021Error>
Return length of last packet received
Sourcepub async fn get_zwave_rx_stats(
&mut self,
) -> Result<ZwaveRxStatsRsp, Lr2021Error>
pub async fn get_zwave_rx_stats( &mut self, ) -> Result<ZwaveRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_zwave_rx_stats_adv(
&mut self,
) -> Result<ZwaveRxStatsRspAdv, Lr2021Error>
pub async fn get_zwave_rx_stats_adv( &mut self, ) -> Result<ZwaveRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn lrfhss_build_packet(
&mut self,
sync_header_cnt: u8,
cr: LrfhssCr,
grid: Grid,
hopping: Hopping,
bw: u8,
sequence: u16,
offset: i8,
pld: &[u8],
) -> Result<(), Lr2021Error>
pub async fn lrfhss_build_packet( &mut self, sync_header_cnt: u8, cr: LrfhssCr, grid: Grid, hopping: Hopping, bw: u8, sequence: u16, offset: i8, pld: &[u8], ) -> Result<(), Lr2021Error>
Prepare the LR-FHSS packet
Sourcepub async fn set_lrfhss_syncword(
&mut self,
syncword: u32,
) -> Result<(), Lr2021Error>
pub async fn set_lrfhss_syncword( &mut self, syncword: u32, ) -> Result<(), Lr2021Error>
Configure Syncword of LRFHSS packet Default value is 0x2C0F7995
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_wmbus_packet(
&mut self,
mode: WmbusMode,
rx_bw: RxBw,
pkt_format_tx: PktFormatTx,
addr_filt_en: bool,
pld_len: u8,
pbl_len_tx: u16,
pbl_len_detect: Option<u8>,
) -> Result<(), Lr2021Error>
pub async fn set_wmbus_packet( &mut self, mode: WmbusMode, rx_bw: RxBw, pkt_format_tx: PktFormatTx, addr_filt_en: bool, pld_len: u8, pbl_len_tx: u16, pbl_len_detect: Option<u8>, ) -> Result<(), Lr2021Error>
Set Wmbus packet parameters: preamble, Bandwidth, Payload length, Address filtering
Sourcepub async fn set_wmbus_address(&mut self, addr: u64) -> Result<(), Lr2021Error>
pub async fn set_wmbus_address(&mut self, addr: u64) -> Result<(), Lr2021Error>
Configure the node address for address filtering
Sourcepub async fn get_wmbus_packet_status(
&mut self,
) -> Result<WmbusPacketStatusRsp, Lr2021Error>
pub async fn get_wmbus_packet_status( &mut self, ) -> Result<WmbusPacketStatusRsp, Lr2021Error>
Return info about last packet received: length, CRC error per block, RSSI, LQI
Sourcepub async fn get_wmbus_rx_stats(
&mut self,
) -> Result<WmbusRxStatsRsp, Lr2021Error>
pub async fn get_wmbus_rx_stats( &mut self, ) -> Result<WmbusRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_wmbus_rx_stats_adv(
&mut self,
) -> Result<WmbusRxStatsRspAdv, Lr2021Error>
pub async fn get_wmbus_rx_stats_adv( &mut self, ) -> Result<WmbusRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_wisun_modulation(
&mut self,
mode: WisunMode,
rx_bw: RxBw,
) -> Result<(), Lr2021Error>
pub async fn set_wisun_modulation( &mut self, mode: WisunMode, rx_bw: RxBw, ) -> Result<(), Lr2021Error>
Set Wisun packet parameters: preamble, Bandwidth, Payload length, Address filtering
Sourcepub async fn set_wisun_packet(
&mut self,
fcs_tx: FcsTx,
whitening: Whitening,
crc_on: CrcOn,
mode_switch_tx: ModeSwitchTx,
fec_tx: FecTx,
frame_len_tx: u16,
pbl_len_tx: u8,
pbl_detect: Option<u8>,
) -> Result<(), Lr2021Error>
pub async fn set_wisun_packet( &mut self, fcs_tx: FcsTx, whitening: Whitening, crc_on: CrcOn, mode_switch_tx: ModeSwitchTx, fec_tx: FecTx, frame_len_tx: u16, pbl_len_tx: u8, pbl_detect: Option<u8>, ) -> Result<(), Lr2021Error>
Set Wisun packet parameters: preamble, Bandwidth, Payload length, Address filtering
Sourcepub async fn get_wisun_packet_status(
&mut self,
) -> Result<WisunPacketStatusRsp, Lr2021Error>
pub async fn get_wisun_packet_status( &mut self, ) -> Result<WisunPacketStatusRsp, Lr2021Error>
Return info about last packet received: length, CRC error per block, RSSI, LQI
Sourcepub async fn get_wisun_rx_stats(
&mut self,
) -> Result<WisunRxStatsRsp, Lr2021Error>
pub async fn get_wisun_rx_stats( &mut self, ) -> Result<WisunRxStatsRsp, Lr2021Error>
Return basic RX stats
Sourcepub async fn get_wisun_rx_stats_adv(
&mut self,
) -> Result<WisunRxStatsRspAdv, Lr2021Error>
pub async fn get_wisun_rx_stats_adv( &mut self, ) -> Result<WisunRxStatsRspAdv, Lr2021Error>
Return advanced RX stats
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn set_bpsk_modulation(
&mut self,
bitrate: u32,
pulse_shape: PulseShape,
diff_mode_en: DiffModeEn,
diff_mode_init: bool,
diff_mode_parity: bool,
) -> Result<(), Lr2021Error>
pub async fn set_bpsk_modulation( &mut self, bitrate: u32, pulse_shape: PulseShape, diff_mode_en: DiffModeEn, diff_mode_init: bool, diff_mode_parity: bool, ) -> Result<(), Lr2021Error>
Set Modulation parameters: raw bitrate, pulse shaping, Bandwidth and fdev
Sourcepub async fn set_bpsk_packet(
&mut self,
pld_len: u8,
bpsk_mode: BpskMode,
sigfox_msg: SigfoxMsg,
sigfox_rank: SigfoxRank,
) -> Result<(), Lr2021Error>
pub async fn set_bpsk_packet( &mut self, pld_len: u8, bpsk_mode: BpskMode, sigfox_msg: SigfoxMsg, sigfox_rank: SigfoxRank, ) -> Result<(), Lr2021Error>
Set FLRC packet parameters: preamble, syncword, header implicit/explicit, CRC and packet length (max 511)
Source§impl<I, O, SPI> Lr2021<O, SPI, BusyBlocking<I>>
impl<I, O, SPI> Lr2021<O, SPI, BusyBlocking<I>>
Sourcepub fn new_blocking(nreset: O, busy: I, spi: SPI, nss: O) -> Self
pub fn new_blocking(nreset: O, busy: I, spi: SPI, nss: O) -> Self
Create a LR2021 Device with blocking access on the busy pin
Source§impl<O, SPI, M> Lr2021<O, SPI, M>
impl<O, SPI, M> Lr2021<O, SPI, M>
Sourcepub async fn reset(&mut self) -> Result<(), Lr2021Error>
pub async fn reset(&mut self) -> Result<(), Lr2021Error>
Reset the chip
Sourcepub fn buffer_mut(&mut self) -> &mut [u8]
pub fn buffer_mut(&mut self) -> &mut [u8]
Read/Write access to internal buffer
Sourcepub fn last_intr(&self) -> Intr
pub fn last_intr(&self) -> Intr
Last captured interrupt status Note: might be incomplete if last command was less than 6 bytes
Sourcepub async fn wait_ready(&mut self, timeout: Duration) -> Result<(), Lr2021Error>
pub async fn wait_ready(&mut self, timeout: Duration) -> Result<(), Lr2021Error>
Wait for LR2021 to be ready for a command, i.e. busy pin low
Sourcepub async fn cmd_wr_begin(&mut self, req: &[u8]) -> Result<(), Lr2021Error>
pub async fn cmd_wr_begin(&mut self, req: &[u8]) -> Result<(), Lr2021Error>
Write the beginning of a command, allowing to fill with variable length fields
Sourcepub async fn cmd_rd(
&mut self,
req: &[u8],
rsp: &mut [u8],
) -> Result<(), Lr2021Error>
pub async fn cmd_rd( &mut self, req: &[u8], rsp: &mut [u8], ) -> Result<(), Lr2021Error>
Write a command and read response Rsp must be n bytes where n is the number of expected byte
Sourcepub async fn cmd_data_wr(
&mut self,
opcode: &[u8],
data: &[u8],
) -> Result<(), Lr2021Error>
pub async fn cmd_data_wr( &mut self, opcode: &[u8], data: &[u8], ) -> Result<(), Lr2021Error>
Write a command with vairable length payload Any feedback data will be available in side the local buffer
Sourcepub async fn cmd_data_rw(
&mut self,
opcode: &[u8],
data: &mut [u8],
) -> Result<(), Lr2021Error>
pub async fn cmd_data_rw( &mut self, opcode: &[u8], data: &mut [u8], ) -> Result<(), Lr2021Error>
Write a command with variable length payload, and save result provided buffer
Sourcepub async fn cmd_buf_wr(&mut self, len: usize) -> Result<(), Lr2021Error>
pub async fn cmd_buf_wr(&mut self, len: usize) -> Result<(), Lr2021Error>
Send content of the local buffer as a command
Sourcepub async fn cmd_buf_rd(
&mut self,
len: usize,
rsp: &mut [u8],
) -> Result<(), Lr2021Error>
pub async fn cmd_buf_rd( &mut self, len: usize, rsp: &mut [u8], ) -> Result<(), Lr2021Error>
Send content of the local buffer as a command and read a response
Sourcepub async fn wake_up(&mut self) -> Result<(), Lr2021Error>
pub async fn wake_up(&mut self) -> Result<(), Lr2021Error>
Wake-up the chip from a sleep mode (Set NSS low until busy goes low)