4 ms·
I've been ramping up on the embedded Rust ecosystem over the last few weeks. I'm pretty excited about it partly because it makes this aspect of embedded develop
by kaycebasques 2y ago
I've been ramping up on the embedded Rust ecosystem over the last few weeks. I'm pretty excited about it partly because it makes this aspect of embedded development much more approachable. On https://crates.io https://crates.io I can usually find a driver for whatever peripheral I want to use in my project. And the driver usually implements the embedded-hal [1] interface, so the more I get familiar with that interface, the easier it becomes to implement any arbitrary peripheral into my project. In the event that there does not already exist a crate for my peripheral, I have an extensive ecosystem [2] of open source driver code that I can refer to in order to figure out how to implement the driver.
I think this could help with the "dark art of reading datasheets" problem. E.g. last night I was curious about how the driver for a 28BYJ-48 stepper motor would work, so I looked at the code [3] for its driver and got a pretty good sense of what's going on. If I were to now attempt to read the datasheet, a lot of it would now make sense. In other words I think it's too daunting to read a datasheet and then try to implement code. The way to get comfortable with datasheets is to first look at code and then find the relevant parts of the datasheet. Previously it was hard to find and make sense of relevant code for a particular driver, now it's much easier.
[1] https://github.com/rust-embedded/embedded-hal https://github.com/rust-embedded/embedded-hal
[2] https://crates.io/keywords/embedded-hal-driver https://crates.io/keywords/embedded-hal-driver
[3] https://github.com/MnlPhlp/uln2003 https://github.com/MnlPhlp/uln2003
- the__alchemist 2y agoI hope not to dull your excitement, but I encourage you to validate this first impression later, if you stick with it. I came to a very different conclusion! Most of the driver libs (e.g. using Embedded Hal) are written by one person, and are impractical when applied to a non-toy application. I found flaws that made them unusable in every one I tried. Or, at least, totaled, in the sense that it would be easier to add a file to the drivers folder of my application that configures the peripherals and provides high-level fns, than to repair the Embedded Hal driver.
- kaycebasques 2y agoMakes sense. I also got the impression that the crates implementing embedded-hal aren't super robust. So maybe I should dial back the statement about not needing to roll your own drivers. However, I think it's just a matter of "when", not "if". I.e. Rust seems to have all the pieces in place for a rich and vibrant embedded development ecosystem (standardized HAL, easy to share HALs and tools with others, open source, a community that embraces docs and educational videos)
- rendaw 2y agoWere the authors responsive to reports?