logoalt Hacker News

bschwindHNtoday at 3:46 AM0 repliesview on HN

> a cool way to work with rust on the RP2040/2350

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/