diff --git a/Cargo.toml b/Cargo.toml index fd87f54..1840fc9 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,14 +1,14 @@ [package] name = "mcp2003a" -version = "0.0.12" -description = "Rust no_std LIN Bus communication using the MCP2003A LIN transceiver." +version = "0.0.13" +description = "MCP2003A LIN transceiver driver with embedded-hal traits for no-std environments." edition = "2021" license = "MIT" authors = ["Zach Grimaldi "] documentation = "https://docs.rs/mcp2003a" repository = "https://github.com/zpg6/mcp2003a" categories = ["embedded", "no-std"] -keywords = ["lin", "linbus", "mcp2003a", "automotive", "driver"] +keywords = ["lin", "linbus", "mcp2003a", "automotive", "no-std"] [dependencies] embedded-hal = "1.0.0" diff --git a/README.md b/README.md index e655dbb..28e23ce 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,7 @@ # mcp2003a +Embedded Rust Microchip MCP2003A LIN transceiver driver with embedded-hal traits for no-std environments. +
Crates.io @@ -12,7 +14,7 @@

-Rust crate for basic `no_std` LIN Bus communications with MCP2003A LIN Transceiver. Uses `embedded-hal` digital traits for GPIO and `embedded-hal-nb` Serial traits for UART. +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 using `nb` crate underneath. @@ -28,22 +30,33 @@ Full Documentation: [https://docs.rs/mcp2003a/latest/mcp2003a/](https://docs.rs/ ## Usage +Add the crate to your `Cargo.toml`: + ``` cargo add mcp2003a ``` -### Example +Configure like so: ```rust -let mut mcp2003a = Mcp2003a::new(uart2_driver, break_pin_driver, delay, lin_bus_config); -``` +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 +); -Then you can use the `mcp2003a` instance to send and receive LIN frames. - -```rust mcp2003a.send_wakeup(); -mc2003a.send_frame(0x01, &[0x02, 0x03], 0x05).unwrap(); +mcp2003a.send_frame(0x01, &[0x02, 0x03], 0x05).unwrap(); let mut read_buffer = [0u8; 11]; let len = mcp2003a.read_frame(0xC1, &mut read_buffer).unwrap();