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-timefor 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-halandembedded-hal-asynctraits 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:
§Async Mode (Recommended)
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 commandsstatus- Status and interrupt handlingsystem- 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 failedSpi- SPI communication errorCmdFail- LR1120 command execution failedCmdErr- Invalid command sent to LR1120BusyTimeout- Timeout waiting for busy pinInvalidSize- 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§
- Busy
Async - Zero-Size marker structure for Busy pin supporting async operations (implements Wait trait)
- Busy
Blocking - Zero-Size marker structure for Busy pin supporting only blocking operations (polling)
- CmdBuffer
- Command Buffer:
- Lr1120
- LR1120 Device
Enums§
- Lr1120
Error - 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