embedded-hal icon indicating copy to clipboard operation
embedded-hal copied to clipboard

Usage of embedded-hal to support bindgen'ed OpenThread

Open markushx opened this issue 5 years ago • 1 comments
trafficstars

I am currently bindgen'ing OpenThread and want to create an idiomatic wrapper around it.

Among other things (e.g. radio-hal), OpenThread needs support for a MilliSecond timer API:

pub unsafe extern "C" fn otPlatAlarmMilliStop(_aInstance: *mut otInstance) {};
pub unsafe extern "C" fn otPlatAlarmMilliStartAt(_aInstance: *mut otInstance, _aT0: u32, _aDt: u32) {};
pub unsafe extern "C" fn otPlatAlarmMilliGetNow() -> u32 {};

I am wondering what I should build this on. I see several (competing? complementing?) options:

  • rtic (https://rtic.rs/0.5/book/en/)
  • embedded_time (https://docs.rs/embedded-time)
  • nb (https://docs.rs/nb/1.0.0/nb/)
  • embedded_hal::timer (https://docs.rs/embedded-hal/1.0.0-alpha.1/embedded_hal/index.html)

Any recommendations?

markushx avatar Jul 15 '20 21:07 markushx

the current state is pretty well covered here i think, at the moment people are experimenting with embedded-time and hopefully we'll move hardware traits back to e-h and maybe maintenance to the wg when it stabilises / becomes well used.

so i would probably suggest looking there if it works for you? in the past (for extremely similar reasons) i have defined a Timer trait along with whatever network component but, they're functionally very similar to those in embedded-time. the only note i would make is you may benefit from abstracting over this so you can consume a read only timer and perform any adjustments in the wrapper (so others can consume the same timer object).

ryankurte avatar Jul 15 '20 23:07 ryankurte