embedded_cylinder

Crates.ioembedded_cylinder
lib.rsembedded_cylinder
version1.0.5
sourcesrc
created_at2023-04-27 01:29:10.627247
updated_at2023-04-28 00:01:07.112252
descriptionCylinder is a library for embedded rust that provides type-safe inter MCU/MPU communication with common protocols like I2C, SPI, and CAN
homepage
repositoryhttps://github.com/maxall41/cylinder
max_upload_size
id849952
size16,608
Max Campbell (maxall41)

documentation

README

Cylinder

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.


Table Of Contents:

  1. Overview
  2. Usage Across Binaries
  3. Installation
  4. Examples
  5. Contribution

Overview:

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);

Usage across binaries:

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.


Examples:

You can find examples in the examples/ directory in the git repo


Installation:

You can install it with:

cargo add embedded_cylinder

Contribution:

If you have any ideas to improve the library create a PR or issue and i will be happy to review it!

Commit count: 20

cargo fmt