Expand description
RW007 SPI WiFi Module Driver
This crate provides a driver for the RW007 SPI WiFi module.
§Features
- Blocking SPI communication
- Two-phase transfer protocol (command + data)
- Hardware reset support
- Interrupt-based data ready detection
- WiFi operations: scan, join, disconnect
- Async driver (with
asyncfeature): Embassy-compatible async driver
§Blocking Example
ⓘ
use rw007::{Rw007, Security};
// Create driver with SPI, CS, RST, INT pins
let mut wifi = Rw007::new(spi, cs_pin, rst_pin, int_pin);
// Reset the module
wifi.reset(&mut delay)?;
// Scan for WiFi networks
let results = wifi.scan(&mut delay)?;
for ap in results.as_slice() {
println!("Found: {} ({}dBm)", ap.ssid.as_str().unwrap_or("?"), ap.rssi);
}
// Connect to WiFi
wifi.join("MyNetwork", "password123", Security::Wpa2Psk, &mut delay)?;§Async Example (with async feature)
ⓘ
use rw007::{new_async, State, Control, Runner, Security};
use static_cell::StaticCell;
static STATE: StaticCell<State> = StaticCell::new();
// Create driver
let state = STATE.init(State::new());
let (device, mut control, runner) = new_async(state, spi, rst);
// Spawn runner task
spawner.spawn(wifi_task(runner)).unwrap();
// Initialize and connect
control.init().await?;
control.connect("MyNetwork", "password123", Security::Wpa2Psk).await?;
// Use device with embassy_net::Stack
let stack = Stack::new(device, config, resources, seed);Re-exports§
pub use commands::Command;pub use commands::WifiEvent;pub use device::Rw007;pub use device::TransferResult;pub use error::Error;pub use protocol::DataPacketHeader;pub use protocol::DataType;pub use protocol::MasterRequest;pub use protocol::SlaveResponse;pub use protocol::MASTER_CMD_PHASE;pub use protocol::MASTER_DATA_PHASE;pub use protocol::MASTER_FLAG_MRDY;pub use protocol::MASTER_MAGIC1;pub use protocol::MASTER_MAGIC2;pub use protocol::MAX_SPI_PACKET_SIZE;pub use protocol::SLAVE_CMD_PHASE;pub use protocol::SLAVE_DATA_PHASE;pub use protocol::SLAVE_FLAG_SRDY;pub use protocol::SLAVE_MAGIC1;pub use protocol::SLAVE_MAGIC2;pub use protocol::SPI_MAX_DATA_LEN;pub use types::ApConfig;pub use types::ApInfo;pub use types::Band;pub use types::ScanResult;pub use types::ScanResults;pub use types::Security;pub use types::Ssid;pub use types::StaConfig;