| Crates.io | st25r95 |
| lib.rs | st25r95 |
| version | 0.1.0 |
| created_at | 2025-12-15 11:01:58.478011+00 |
| updated_at | 2025-12-15 11:01:58.478011+00 |
| description | Driver for ST25R95 integrated transceiver for contactless applications (NFC) |
| homepage | |
| repository | https://github.com/Foundation-Devices/st25r95 |
| max_upload_size | |
| id | 1985861 |
| size | 236,192 |
A Rust embedded driver for the ST25R95 NFC transceiver chip, providing a safe and ergonomic interface for NFC communication protocols.
#![no_std]Add this to your Cargo.toml:
[dependencies]
st25r95 = "0.1.0"
use st25r95::{St25r95, St25r95Spi, St25r95Gpio};
// Implement the SPI interface
struct NfcSpi;
impl St25r95Spi for NfcSpi {
...
}
let spi = NfcSpi::default();
// Implement the GPIOs interface
struct NfcGpio;
impl St25r95Gpio for NfcGpio {
...
}
let gpio = NfcGpio::default();
// Create driver instance
let mut nfc = St25r95::new(spi, gpio)?;
// Perform Calibration
let _ = nfc.calibrate_tag_detector()?;
The driver is organized into several layers:
The driver uses Rust's type system to ensure correct usage:
// Driver starts in FieldOff state
let mut nfc = St25r95::new(spi, gpio)?;
// Protocol-specific operations are available
let iso14443a = nfc.protocol_select_iso14443a(params)?;
All operations return Result<T, Error> with comprehensive error types:
use st25r95::Error;
match nfc.send_command(command) {
Ok(response) => println!("Success: {:?}", response),
Err(Error::SpiError(e)) => eprintln!("SPI communication failed"),
Err(Error::CrcError) => eprintln!("CRC check failed"),
Err(e) => eprintln!("Other error: {:?}", e),
}
The ST25R95 can be configured through register settings:
use st25r95::register::{AccA, ArcB};
// Configure antenna A settings
nfc.register_modify(AccA::new().with_amplitude(0x7F))?;
// Configure antenna B settings
nfc.register_modify(ArcB::new().with_resonance_frequency(0x4B))?;
Run the test suite:
cargo test
This crate requires Rust 1.86.0 or later.
This project is licensed under GPL-v3-or-newer (LICENSE-GPL).
Contributions are welcome! Please open an issue or submit a pull request.
Full API documentation is available on docs.rs.