ZH version is available. Content is displayed in original English for accuracy.
Advertisement
Advertisement
⚡ Community Insights
Discussion Sentiment
100% Positive
Analyzed from 276 words in the discussion.
Trending Topics
#rust#safe#register#board#mcus#world#pac#https#half#cool

Discussion (3 Comments)Read Original on HackerNews
I thought, wow, this would be a cool way to work with rust on the RP2040/2350 but then the only books available are only for ESP devices.
A maker lab 99-projects-in-one PCB with a soldered on (or pluggable) RP2350 with companion text would scratch all the itches of my particular interest in rust and MCUs.
As someone who has a lot of C/C++ experience in the MCU world, the most mysterious part of rust on MCUs for me is the world of bit twiddling and register accesses from a safe language. I would love to have a playground to explore this kind of stuff.
And would strongly prefer open hardware like the RP2XXX family over a commercial chip like the ESP.
Pick up an RPi Pico (and one of their debugger probes) or a Xiao board with an RP2040 or RP2350, and try playing around with Embassy. It's super easy to get started and has been, by far, my favorite way to develop embedded projects.
> the most mysterious part of rust on MCUs for me is the world of bit twiddling and register accesses from a safe language
Rust mostly generates safe APIs to modify registers from things like SVD files. These are typically organized as a PAC (Peripheral Access Crate). Here's an example:
https://docs.rs/rp2040-pac/0.6.0/rp2040_pac/
This automation generates type-safe structs that you let you read and modify the various bits in a register, with volatile writes and all of that. You could probably have an LLM (or a google search) explain PACs and how they're typically used and I think you'll get it.
Then a HAL (Hardware Abstraction Layer) is usually built up using the register operations from the PAC in order to expose a safe Rust interface over a particular peripheral.
https://www.raspberrypi.com/products/debug-probe/
https://embassy.dev/