#can-bus #convenience

macro no-std can-bit-timings-proc-macro

This package is a common dependency for can-bit-timings and can-bit-timings-proc-macro

3 stable releases

1.1.0 Feb 22, 2021
1.0.1 Feb 22, 2021
1.0.0 Feb 21, 2021

#13 in #can-bus

42 downloads per month
Used in can-bit-timings

MPL-2.0 license

17KB
228 lines

can_bit_timings

CI Crates.io

This is a procedural macro (originally a constexpr function (const fn)) to calculate CAN bus timings for different STM32 MCUs bxcan module. It can be useful to calculate timings for different MCUs, but one should write a function formatting the calculated values into appropriate register value.

This project is based on a similar piece of code from modm project. You can find out more on bit timings here

Example:

#[no-std]
use can_bus_timings::can_timings_bxcan;

const fn can0_timings() -> u32{
    can_timings_bxcan!(10.mhz(), 1.mhz())
}

fn main(){
    // ... CAN hardware initialization
    can0_timings();
}

Dependencies

~1.5MB
~33K SLoC