Expand description
§ask433
A portable, no_std Rust driver for Amplitude Shift Keying (ASK/OOK) 433 MHz RF transceivers, compatible with cheap modules like the FS1000A and XY-MK-5V.
This driver implements a software-based ASK modem using:
embedded-hal
traits for digital I/O and timing- a software PLL for reception and demodulation
- interrupt-safe buffer access with
critical-section
- optional tick sources using either timer interrupts or blocking delay
§Crate features
Feature | Description |
---|---|
std | Disables #![no_std] support and replaces healpess::Vec s with |
std::vec::Vec s | |
delay-loop | Uses embedded_hal::blocking::delay::DelayUs for bit timing |
timer-isr (default) | Uses critical_section::with for bit timing |
defmt | Uses defmt logging |
log | Uses log logging |
§Software Features
- Transmitter and receiver in pure software (no UART or DMA)
- Bit-level protocol compatible with RadioHead RH_ASK
- Supports training preamble, 4b6b encoding, and CRC16 validation
- Fully portable across AVR (e.g., Arduino Uno) and ARM Cortex-M targets
- Feature flags for interrupt-driven or blocking tick scheduling
§Usage
use ask433::driver::AskDriver;
fn main() {
// ...
let mut driver: AskDriver<Pin, Pin, Pin> = AskDriver::new(tx_pin, rx_pin, None, 8, None, None);
// ^ this is the number of interrupts per bit
loop {
driver.tick(); // Call at ~62.5 µs intervals
}
}
Or, use run_tick_loop()
with a DelayUs
implementation:
use ask433::driver::AskDriver;
#[cfg(feature = "delay-loop")]
use ask433::timer::run_ask_tick_loop;
fn main() {
// ...
let mut driver: AskDriver<Pin, Pin, Pin> = AskDriver::new(tx_pin, rx_pin, None, 8, None, None);
run_ask_tick_loop(&mut driver, &mut delay, 63);
}
§Feature Flags
timer-isr
: Use a hardware timer ISR to calltick()
(requires platform-specific ISR setup)delay-loop
: Use a blocking loop to drivetick()
withembedded_hal::blocking::delay::DelayUs
§Integration Notes
- Transmit and receive timing are based on ~2 kbps bit rate (~62.5 µs per tick)
- Timing precision is critical; hardware timer configuration is recommended for reliability
- Only one driver instance should be active at a time in interrupt-driven mode
§Status
This crate is in early development. Contributions welcome!
–
Designed for #![no_std]
use in resource-constrained embedded environments.
Re-exports§
pub use critical_section;
pub use heapless;
Modules§
- consts
- Constants used across the ASK protocol implementation.
- driver
- ASK/OOK modem driver for 433 MHz RF transceivers.
- encoding
- 4b6b symbol encoding and decoding for ASK/OOK message framing.
- pll
- Software PLL for ASK/OOK signal demodulation.
- timer
- Timer and tick-loop utilities for ASK driver.
Macros§
- init_
ask_ driver - Declares a static global
ASK_DRIVER
instance protected by acritical_section
mutex. - receive_
from_ ask - Attempts to receive a completed message from the global ASK driver instance.
- send_
from_ ask - Sends a message from the global ASK driver using a heapless
Vec<u8>
. - setup_
ask_ driver - Initializes the global
ASK_DRIVER
singleton with a new driver instance. - tick_
ask_ timer - Calls
tick()
on the globalASK_DRIVER
if it has been initialized.