Crates.io | embedded_cylinder |
lib.rs | embedded_cylinder |
version | 1.0.5 |
source | src |
created_at | 2023-04-27 01:29:10.627247 |
updated_at | 2023-04-28 00:01:07.112252 |
description | Cylinder is a library for embedded rust that provides type-safe inter MCU/MPU communication with common protocols like I2C, SPI, and CAN |
homepage | |
repository | https://github.com/maxall41/cylinder |
max_upload_size | |
id | 849952 |
size | 16,608 |
Cylinder is an embedded rust library for type-safe inter MCU/MPU communication
that supports #![no_std]
. I created it because handling
complex inter-MCU communication without type-safety
is extremely difficult, but with Cylinder you don't have
to worry about defining unique u8
values for
commands, conflicts, and other issues with non type-safe communication.
Cylinder allows for type-safe communication by providing a procedural macro that runs at build time that you can apply to enum types. e.g:
use embedded_cylinder::CylinerBuildU8;
#[derive(CylinerBuildU8)]
enum Test {
MyEnum1,
MyEnum2,
MyEnum3,
MyEnum4
}
At build time an implementation is added for the enum that maps each variant of the enum to a unique value. Which you can get like this:
let val : u8 = Test::get_u8(Test::MyEnum2);
To use Cylinder across multiple binaries you can define a local library that contains your type interface and then import that library into your binaries.
You can find examples in the examples/
directory in the git repo
You can install it with:
cargo add embedded_cylinder
If you have any ideas to improve the library create a PR or issue and i will be happy to review it!