Skip to content

Building a generic driver (INA219/INA3221) across ESP + other hals #372

Answered by chvllad
ewrogers asked this question in Q&A
Discussion options

You must be logged in to vote

Well, embedded_hal is the way to write platform agnostic drivers. But note, currently there are a lot of variants of embedded_hal, including:

  1. Stable 0.2 blocking version.
  2. Stable async version via nb crate (but seems like i2c is not supported in this variant).
  3. Unstable 1.0 blocking version.
  4. Unstable async version using rust's native async.

In my new projects (like max31855 driver) I use only 3 and 4 variants (because all platforms I have already support 1.0 version of embedded_hal). But using 0.2 and 1.0 blocking traits probably will be the most universal way to support most of the platforms.

For your driver you could use I2C trait (blocking 0.2, blocking 1.0, unstable async). esp-hal al…

Replies: 4 comments

Comment options

You must be logged in to vote
0 replies
Answer selected by ewrogers
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Comment options

You must be logged in to vote
0 replies
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
3 participants