RIOT-OS / rust-riot-wrappers

The `riot-wrappers` crate, which enables high-level access to RIOT from the Rust programming language
13 stars 11 forks source link

Inconsistent safety description of peripheral initialization #59

Open chrysn opened 11 months ago

chrysn commented 11 months ago

Older peripheral wrappers have unsafe init functions, reasoning that this is equivalent to a Rust PAC's stealing function (which allows creating the same peripheral twice). Newer peripheral wrappers have safe init functions, reasoning that in RIOT initializers are idempotent.

I don't have a full conclusion yet, because while RIOT does make some of those things safe, peripheral drivers are also not thread safe. But given they don't access real RAM, maybe it's fine even under Rust's model for both to write to registers a the same time? (At least as in "not cause UB" -- the ADC readings are still likely garbage).