14 releases
0.0.13 | Jul 6, 2024 |
---|---|
0.0.12 | Jul 6, 2024 |
0.0.4 | Jun 24, 2024 |
#322 in Embedded development
20KB
269 lines
mcp2003a
Embedded Rust Microchip MCP2003A LIN transceiver driver with embedded-hal traits for no-std environments.
Uses embedded-hal
digital traits for GPIO and embedded-hal-nb
Serial traits for UART.
embedded-hal = "1.0.0"
- Major breaking changes versus 0.2.x implementations.embedded-hal-nb = "1.0.0"
- Additional non-blocking traits usingnb
crate underneath.
⚠️ WORK IN PROGRESS
Full Documentation: https://docs.rs/mcp2003a/latest/mcp2003a/
References
Usage
Add the crate to your Cargo.toml
:
cargo add mcp2003a
Configure like so:
let lin_bus_config = LinBusConfig {
speed: LinBusSpeed::Baud19200,
break_duration: LinBreakDuration::Minimum13Bits,
wakeup_duration: LinWakeupDuration::Minimum250Microseconds,
read_device_response_timeout: LinReadDeviceResponseTimeout::DelayMilliseconds(2),
inter_frame_space: LinInterFrameSpace::DelayMilliseconds(1),
};
let mut mcp2003a = Mcp2003a::new(
uart2_driver,
break_pin_driver,
delay,
lin_bus_config
);
mcp2003a.send_wakeup();
mcp2003a.send_frame(0x01, &[0x02, 0x03], 0x05).unwrap();
let mut read_buffer = [0u8; 11];
let len = mcp2003a.read_frame(0xC1, &mut read_buffer).unwrap();
Full Examples
(More coming soon)
- ESP-32 via ESP-RS - Example using the MCP2003A with an ESP-32 microcontroller using the ESP-RS HAL.
Dependencies
~85KB