Expand description
SX126x Radio Driver
This crate provides a type-safe interface for the Semtech SX1261/2 sub-GHz radio transceivers. The SX1261/2 are highly integrated, long range, low power radio transceivers designed for use in ISM band applications.
§Features
- Frequency range: 150-960 MHz
- Modulation support:
- LoRa: SF5-12, BW 7.8-500kHz
- (G)FSK: BR 0.6-300kbps
- Output power:
- SX1261: -17 to +15 dBm
- SX1262: -9 to +22 dBm
- Receive sensitivity down to -148 dBm
- Integrated voltage regulation (DC-DC or LDO)
- Programmable DIO pins for interrupts and control
§Architecture
The driver is organized into several modules:
-
device: Main device interface for hardware interaction- Provides high-level API for register access and command execution
- Manages SPI communication with the radio
-
registers: Register definitions for direct hardware access- [
registers::rf]: RF-related registers (frequency, power, etc) - [
registers::packet]: Packet handling registers - [
registers::dio]: Digital I/O configuration registers - [
registers::system]: System configuration registers
- [
-
commands: Command interface for radio control- [
commands::rf]: RF and modulation configuration - [
commands::dio]: DIO and interrupt control - [
commands::operational]: Operating mode control - [
commands::status]: Status monitoring and statistics
- [
§Usage
The driver uses the regiface crate to provide a type-safe interface
for register access and command execution. The main entry point is the
Device struct which wraps an SPI interface and provides methods for
interacting with the radio.
Configuration follows a specific sequence:
- Create a new
Deviceinstance with your SPI interface - Set operating mode (STDBY_RC for configuration)
- Configure packet type (LoRa/FSK)
- Set RF frequency and modulation parameters
- Configure packet format and processing
- Set up DIO pins and interrupts
- Enter RX/TX mode for operation
§Important Notes
- Most configuration must be done in STDBY_RC mode
- Packet type must be set before other RF configuration
- PA configuration depends on device type (SX1261/2)
- TCXO configuration requires special handling
- Some registers have interdependencies
§Example
use embedded_hal::spi::SpiDevice;
use sx1262::{Device, commands::{SetStandby, StandbyConfig}, Error};
fn configure_radio<SPI: SpiDevice>(spi: SPI) -> Result<Device<SPI>, Error> {
let mut device = Device::new(spi);
// Set to STDBY_RC mode for configuration
device.execute_command( SetStandby { config: StandbyConfig::Rc})?;
Ok(device)
}Re-exports§
Modules§
- commands
- Radio command implementations
- device
- SX126x Radio Device Interface
- registers
- Register definitions for the SX126x radio Generated from DS_SX1261-2_V1.2.pdf datasheet
Enums§
- Error
- A simplified error type that represents any error that can occur during register operations.