#communication #spi #i2c #type-safe #inter #cylinder #mcu-mpu

yanked embedded_cylinder

Cylinder is a library for embedded rust that provides type-safe inter MCU/MPU communication with common protocols like I2C, SPI, and CAN

1.0.5 Apr 28, 2023
1.0.4 Apr 27, 2023

#5 in #inter

45 downloads per month

Custom license

7KB

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!

Dependencies

~1.5MB
~38K SLoC