4 ms·
I'm not sure what was available to the author at the time of writing, but it feels like abstractions have gotten better and writing embedded Rust has gotten eas
by bschwindHN 4y ago
I'm not sure what was available to the author at the time of writing, but it feels like abstractions have gotten better and writing embedded Rust has gotten easier.
I also wrote keyboard firmware in Rust and thought it was great! I leaned on embedded-hal and the chip HAL crates (one layer of abstraction higher than the author in your link) and was able to get the majority of the firmware done in a day or two. For example, here is my key matrix scanning function:
https://github.com/bschwind/key-ripper/blob/d33db6144bbb6f803f8a11f7a1ac8e83e5f54bcf/firmware/src/key_scan.rs#L22-L46 https://github.com/bschwind/key-ripper/blob/d33db6144bbb6f80...
I also gave a small talk on the subject (aimed more at beginners) at a Rust meetup in Tokyo:
https://www.youtube.com/watch?v=x7LQevYn7d0 https://www.youtube.com/watch?v=x7LQevYn7d0
And finally, a (somewhat) dated article I wrote about using Rust for embedded work:
https://blog.tonari.no/rust-simple-hardware-project https://blog.tonari.no/rust-simple-hardware-project
Overall, it feels totally usable to me, and I love how Rust's ownership and lifetime concepts prevent me from doing stupid things like reusing a pin for two peripherals or configuring a peripheral with pins it can't work with.