top | item 41460519

(no title)

oll3 | 1 year ago

Yes, on hal level there will be a bunch of unsafe. On firmware application level it's not often I find the need to reach for unsafe though. It would typically be if the hal is lacking in some sense.

discuss

order

jsheard|1 year ago

I was a bit taken aback when I realized that Embassy's low-level PAC crates expose all of the devices raw registers through "safe" interfaces though. I'm pretty sure that letting you configure DMA engines arbitrarily at any time is not in the spirit of safe Rust. AFAIK their high-level HAL crates do aim to be properly safe but their PAC approach makes me nervous.

https://docs.embassy.dev/rp-pac/git/default/dma/struct.Chann...

bacon_waffle|1 year ago

Usually the HAL is between the main firmware and the PAC, so whether the PAC methods are marked as unsafe could almost be considered an implementation detail.

But yes, there has been a lot of discussion around how to handle DMA peripherals - the embedded_dma crate offers some abstractions that I've found handy.

nicce|1 year ago

But firmware is kinda generic term that usually includes the hal. I am not sure what it meant in this blog post.