Crate lr1120

Crate lr1120 

Source
Expand description

§LR1120 Driver

An async, no_std Rust driver for the Semtech LR1120 transceiver family.

The LR1120 is a dual band (sub-GHz and 2.4GHz) radio transceiver targetting LoRa and generic (G)-FSK protocols. It also includes a crypto engine and geo-location features (via GNSS or Wifi scanning)

§Features

  • Async/await support - Built on embassy-time for efficient async operations
  • no_std compatible - Suitable for embedded systems with minimal overhead
  • Flexible busy pin handling - Both blocking polling and async interrupt-based modes
  • HAL abstraction - Uses embedded-hal and embedded-hal-async traits for hardware portability
  • Comprehensive error handling - Detailed error types for robust error management

§Hardware Requirements

  • SPI interface - For command and data communication with the LR1120
  • Reset pin - GPIO output pin connected to the LR1120’s reset line (active low)
  • Busy pin - GPIO input pin connected to the LR1120’s busy signal
  • NSS pin - SPI chip select pin (GPIO output)

§Driver Modes

The driver supports two modes for handling the busy pin:

Uses the embedded-hal-async Wait trait for efficient interrupt-based waiting:

let radio = Lr1120::new(reset_pin, busy_pin, spi_device, nss_pin);

§Blocking Mode

Polls the busy pin in a loop (less efficient but works with any GPIO):

let radio = Lr1120::new_blocking(reset_pin, busy_pin, spi_device, nss_pin);

§Architecture

The driver is organized into several modules:

  • cmd - Low-level command interface and protocol-specific commands
  • status - Status and interrupt handling
  • system - System-level operations (reset, sleep, etc.)
  • radio - Common radio operations
  • Protocol modules: lora, fsk, lrfhss.

§Error Handling

The driver uses the Lr1120Error enum for error reporting:

  • Pin - GPIO pin operation failed
  • Spi - SPI communication error
  • CmdFail - LR1120 command execution failed
  • CmdErr - Invalid command sent to LR1120
  • BusyTimeout - Timeout waiting for busy pin
  • InvalidSize - Command size exceeds buffer limits

§Cargo Features

  • defmt - Enable defmt logging support for debugging

Modules§

cmd
Collection of functions to create SPI commands (byte arrays) and hold SPI responses
crypto
API related to Crypto-Engine
fsk
API related to FSK operations
gnss
API related to GNSS
lora
API related to LoRa operations
lrfhss
API related to LR-FHSS operations
radio
Radio control and RF management API
status
Device status and interrupts
system
System control and chip management API
wifi_scan
API related to WiFi Scanning

Structs§

BusyAsync
Zero-Size marker structure for Busy pin supporting async operations (implements Wait trait)
BusyBlocking
Zero-Size marker structure for Busy pin supporting only blocking operations (polling)
CmdBuffer
Command Buffer:
Lr1120
LR1120 Device

Enums§

Lr1120Error
Error using the LR1120

Traits§

BusyPin
Sealed trait to implement two flavor of the driver where the busy pin can be either a simple input or one implemeting the Wait trait