st25r95
A Rust embedded driver for the ST25R95 NFC transceiver chip, providing a safe and ergonomic interface for NFC communication protocols.
Features
- Memory Safe: Written in Rust with comprehensive error handling
- No Std Compatible: Designed for embedded systems with
#![no_std] - Type State Pattern: Compile-time guarantees for correct usage
- Protocol Support: ISO14443A/B, ISO15693, and FeliCa protocols
- Reader & Card Emulation: Full support for both operating modes
- Async Ready: Compatible with embedded-hal-async
Supported Protocols
- ISO14443A: MIFARE Classic, MIFARE Ultralight, NTAG, etc.
- ISO14443B: Various Type B cards and tags
- ISO15693: Vicinity cards (VCD/ICC)
- FeliCa: Sony's contactless smart card system
Quick Start
Add this to your Cargo.toml:
[]
= "0.1.0"
Basic Example
use ;
// Implement the SPI interface
;
let spi = default;
// Implement the GPIOs interface
;
let gpio = default;
// Create driver instance
let mut nfc = new?;
// Perform Calibration
let _ = nfc.calibrate_tag_detector?;
Architecture
The driver is organized into several layers:
- Core: Low-level SPI communication and register access
- Protocols: High-level protocol implementations (ISO14443A/B, ISO15693, FeliCa)
- Commands: Command building and response parsing
- Registers: Memory-mapped register interface
- GPIO: GPIO pin management
Type State Pattern
The driver uses Rust's type system to ensure correct usage:
// Driver starts in FieldOff state
let mut nfc = new?;
// Protocol-specific operations are available
let iso14443a = nfc.protocol_select_iso14443a?;
Error Handling
All operations return Result<T, Error> with comprehensive error types:
use Error;
match nfc.send_command
Configuration
The ST25R95 can be configured through register settings:
use ;
// Configure antenna A settings
nfc.register_modify?;
// Configure antenna B settings
nfc.register_modify?;
Testing
Run the test suite:
Minimum Supported Rust Version
This crate requires Rust 1.86.0 or later.
License
This project is licensed under GPL-v3-or-newer (LICENSE-GPL).
Contributing
Contributions are welcome! Please open an issue or submit a pull request.
- Fork the repository
- Create a feature branch
- Make your changes
- Add tests if applicable
- Submit a pull request
Documentation
Full API documentation is available on docs.rs.