Lr2021

Struct Lr2021 

Source
pub struct Lr2021<O, SPI, M: BusyPin> { /* private fields */ }
Expand description

LR2021 Device

Implementations§

Source§

impl<O, SPI, M> Lr2021<O, SPI, M>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

pub async fn get_status(&mut self) -> Result<(Status, Intr), Lr2021Error>

Read status and interrupt from the chip

Source

pub async fn get_errors(&mut self) -> Result<ErrorsRsp, Lr2021Error>

Read status and interrupt from the chip

Source

pub async fn get_version(&mut self) -> Result<VersionRsp, Lr2021Error>

Read status and interrupt from the chip

Source

pub async fn get_and_clear_irq(&mut self) -> Result<Intr, Lr2021Error>

Read interrupt from the chip and clear them all

Source

pub async fn clear_irqs(&mut self, intr: Intr) -> Result<(), Lr2021Error>

Set the RF channel (in Hz)

Source

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

Source

pub async fn set_chip_mode( &mut self, chip_mode: ChipMode, ) -> Result<(), Lr2021Error>

Set Tx power and ramp time

Source

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

Source

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()

Source

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()

Source

pub async fn clear_tx_fifo(&mut self) -> Result<(), Lr2021Error>

Clear TX Fifo

Source

pub async fn get_tx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>

Return number of byte in TX FIFO

Source

pub async fn rd_rx_fifo_to( &mut self, buffer: &mut [u8], ) -> Result<(), Lr2021Error>

Read data from the RX FIFO

Source

pub async fn rd_rx_fifo(&mut self, len: usize) -> Result<(), Lr2021Error>

Read data from the RX FIFO to the local buffer

Source

pub async fn get_rx_fifo_lvl(&mut self) -> Result<u16, Lr2021Error>

Return number of byte in RX FIFO

Source

pub async fn clear_rx_fifo(&mut self) -> Result<(), Lr2021Error>

Clear RX Fifo

Source

pub async fn load_pram(&mut self, patch: &[u8]) -> Result<(), Lr2021Error>

Load a patch in ram

Source

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

Source

pub async fn rd_reg(&mut self, addr: u32) -> Result<u32, Lr2021Error>

Read a register value

Source

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

pub async fn wr_reg(&mut self, addr: u32, value: u32) -> Result<(), Lr2021Error>

Write a register value

Source

pub async fn wr_field( &mut self, addr: u32, value: u32, pos: u8, width: u8, ) -> Result<(), Lr2021Error>

Write a field value

Source§

impl<O, SPI, M> Lr2021<O, SPI, M>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

pub async fn set_rf(&mut self, freq: u32) -> Result<(), Lr2021Error>

Set the RF channel (in Hz)

Source

pub async fn set_rx_path( &mut self, rx_path: RxPath, rx_boost: u8, ) -> Result<(), Lr2021Error>

Set the RX Path (LF/HF)

Source

pub async fn set_packet_type( &mut self, packet_type: PacketType, ) -> Result<(), Lr2021Error>

Set the packet type

Source

pub async fn set_tx_params( &mut self, tx_power: u8, ramp_time: RampTime, ) -> Result<(), Lr2021Error>

Set Tx power and ramp time

Source

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

Source

pub async fn set_pa_hf(&mut self) -> Result<(), Lr2021Error>

Configure HF Power Amplifier

Source

pub async fn set_fallback( &mut self, fallback_mode: FallbackMode, ) -> Result<(), Lr2021Error>

Set the Fallback mode after TX/RX

Source

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.

Source

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

Source

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
Source

pub async fn set_cad(&mut self) -> Result<(), Lr2021Error>

Set chip in Channel activity Detection mode CAD is configured with set_cad_params

Source

pub async fn set_cca(&mut self, duration: u32) -> Result<(), Lr2021Error>

Set chip in CCA (Clear Channel Assesment) for duration (31.25ns)

Source

pub async fn get_cca_result(&mut self) -> Result<CcaResultRsp, Lr2021Error>

Set chip in CCA (Clear Channel Assesment) for duration (31.25ns)

Source

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
Source

pub async fn clear_rx_stats(&mut self) -> Result<(), Lr2021Error>

Clear RX stats

Source

pub async fn get_rx_pkt_len(&mut self) -> Result<u16, Lr2021Error>

Return length of last packet received

Source

pub async fn force_crc_out(&mut self) -> Result<(), Lr2021Error>

Output CRC to the FIFO even when already checked by hardware

Source

pub async fn get_rssi_inst(&mut self) -> Result<u16, Lr2021Error>

Measure RSSI instantaneous

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

pub async fn set_lora_modulation( &mut self, sf: Sf, bw: LoraBw, cr: LoraCr, ldro: Ldro, ) -> Result<(), Lr2021Error>

Set LoRa Modulation parameters

Source

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

Source

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

Source

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)

Source

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)

Source

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

Source

pub async fn get_lora_packet_status( &mut self, ) -> Result<LoraPacketStatusRsp, Lr2021Error>

Return Information about last packet received

Source

pub async fn get_lora_packet_status_adv( &mut self, ) -> Result<LoraPacketStatusRspAdv, Lr2021Error>

Return extended Information about last packet received

Source

pub async fn get_lora_rx_stats(&mut self) -> Result<LoraRxStatsRsp, Lr2021Error>

Return length of last packet received

Source

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
Source

pub async fn set_lora_cad(&mut self) -> Result<(), Lr2021Error>

Start a LoRa Channel Activity Detection (CAD)

Source

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

Source

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

Source

pub async fn set_lora_sidedet_syncword( &mut self, sw: &[u8], ) -> Result<(), Lr2021Error>

Configure Side-Detector Syncword using basic syncword format

Source

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

Source

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)

Source

pub async fn set_ranging_req_addr( &mut self, addr: u32, ) -> Result<(), Lr2021Error>

Set the request address for ranging operation

Source

pub async fn set_ranging_txrx_delay( &mut self, delay: u32, ) -> Result<(), Lr2021Error>

Set the ranging calibration value

Source

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

Source

pub async fn get_ranging_status(&mut self) -> Result<RangingStatus, Lr2021Error>

Return info if last ranging exchange was valid

Source

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

Source

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)

Source

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

Source

pub async fn get_ranging_stats( &mut self, ) -> Result<RangingStatsRsp, Lr2021Error>

Return statistics about ranging exchanges

Source

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

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

pub async fn set_ble_modulation( &mut self, mode: BleMode, ) -> Result<(), Lr2021Error>

Set BLE Mode (1M, 2M, 500k, 125k)

Source

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

Source

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

Source

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

Source

pub async fn get_ble_packet_status( &mut self, ) -> Result<BlePacketStatusRsp, Lr2021Error>

Return length of last packet received

Source

pub async fn get_ble_rx_stats(&mut self) -> Result<BleRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

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)

Source

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

Source

pub async fn get_flrc_packet_status( &mut self, ) -> Result<FlrcPacketStatusRsp, Lr2021Error>

Return length of last packet received

Source

pub async fn get_flrc_rx_stats(&mut self) -> Result<FlrcRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

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

Source

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

Source

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)

Source

pub async fn set_ook_crc( &mut self, polynom: u32, init: u32, ) -> Result<(), Lr2021Error>

Configure OOK polynom and init value

Source

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

Source

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
Source

pub async fn get_ook_packet_status( &mut self, ) -> Result<OokPacketStatusRsp, Lr2021Error>

Return stats about last packet received: length, RSSI, LQI

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

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)

Source

pub async fn set_fsk_syncword( &mut self, syncword: u64, bit_order: BitOrder, nb_bits: u8, ) -> Result<(), Lr2021Error>

Configure syncword

Source

pub async fn get_fsk_packet_status( &mut self, ) -> Result<FskPacketStatusRsp, Lr2021Error>

Return length of last packet received

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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)

Source

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 !

Source

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

Source

pub async fn get_zigbee_packet_status( &mut self, ) -> Result<ZigbeePacketStatusRsp, Lr2021Error>

Return length of last packet received

Source

pub async fn get_zigbee_rx_stats( &mut self, ) -> Result<ZigbeeRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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)

Source

pub async fn set_zwave_home_id(&mut self, id: u32) -> Result<(), Lr2021Error>

Sets the zwave Home ID, used as address filter in RX

Source

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

Source

pub async fn set_zwave_scan_config( &mut self, cfg: &ZwaveScanCfg, ) -> Result<(), Lr2021Error>

Configure scan: number of active channel, their mode and frequency

Source

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

Source

pub async fn get_zwave_packet_status( &mut self, ) -> Result<ZwavePacketStatusRsp, Lr2021Error>

Return length of last packet received

Source

pub async fn get_zwave_rx_stats( &mut self, ) -> Result<ZwaveRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

pub async fn set_lrfhss_syncword( &mut self, syncword: u32, ) -> Result<(), Lr2021Error>

Configure Syncword of LRFHSS packet Default value is 0x2C0F7995

Source

pub async fn set_lrfhss_hopping( &mut self, hop_en: bool, freq_hz: bool, pkt_length: u16, nb_used_freqs: u8, nb_hopping_blocks: u8, hops: &[LrfhssHop], ) -> Result<(), Lr2021Error>

Set the LRFHSS hopping table The data parameter should be up to 40 pairs (freq (4B), Nb_symbols (2B))

Source§

impl<O, SPI, M> Lr2021<O, SPI, M>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

pub async fn set_wmbus_address(&mut self, addr: u64) -> Result<(), Lr2021Error>

Configure the node address for address filtering

Source

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

Source

pub async fn get_wmbus_rx_stats( &mut self, ) -> Result<WmbusRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

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

Source

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

Source

pub async fn get_wisun_rx_stats( &mut self, ) -> Result<WisunRxStatsRsp, Lr2021Error>

Return basic RX stats

Source

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>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

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

Source

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>>
where I: InputPin, O: OutputPin, SPI: SpiBus<u8>,

Source

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<I, O, SPI> Lr2021<O, SPI, BusyAsync<I>>
where I: InputPin + Wait, O: OutputPin, SPI: SpiBus<u8>,

Source

pub fn new(nreset: O, busy: I, spi: SPI, nss: O) -> Self

Create a LR2021 Device with async busy pin

Source§

impl<O, SPI, M> Lr2021<O, SPI, M>
where O: OutputPin, SPI: SpiBus<u8>, M: BusyPin,

Source

pub async fn reset(&mut self) -> Result<(), Lr2021Error>

Reset the chip

Source

pub fn is_busy(&self) -> bool

Check if the busy pin is high (debug)

Source

pub fn status(&self) -> Status

Last status (command status, chip mode, interrupt, …)

Source

pub fn buffer(&self) -> &[u8]

Read access to internal buffer

Source

pub fn buffer_mut(&mut self) -> &mut [u8]

Read/Write access to internal buffer

Source

pub fn last_intr(&self) -> Intr

Last captured interrupt status Note: might be incomplete if last command was less than 6 bytes

Source

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

Source

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

Source

pub async fn cmd_wr(&mut self, req: &[u8]) -> Result<(), Lr2021Error>

Write a command

Source

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

Source

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

Source

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

Source

pub async fn cmd_buf_wr(&mut self, len: usize) -> Result<(), Lr2021Error>

Send content of the local buffer as a command

Source

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

Source

pub async fn wake_up(&mut self) -> Result<(), Lr2021Error>

Wake-up the chip from a sleep mode (Set NSS low until busy goes low)

Auto Trait Implementations§

§

impl<O, SPI, M> Freeze for Lr2021<O, SPI, M>
where O: Freeze, <M as BusyPin>::Pin: Freeze, SPI: Freeze,

§

impl<O, SPI, M> RefUnwindSafe for Lr2021<O, SPI, M>

§

impl<O, SPI, M> Send for Lr2021<O, SPI, M>
where O: Send, <M as BusyPin>::Pin: Send, SPI: Send,

§

impl<O, SPI, M> Sync for Lr2021<O, SPI, M>
where O: Sync, <M as BusyPin>::Pin: Sync, SPI: Sync,

§

impl<O, SPI, M> Unpin for Lr2021<O, SPI, M>
where O: Unpin, <M as BusyPin>::Pin: Unpin, SPI: Unpin,

§

impl<O, SPI, M> UnwindSafe for Lr2021<O, SPI, M>
where O: UnwindSafe, <M as BusyPin>::Pin: UnwindSafe, SPI: UnwindSafe,

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.