rust-embedded / svd2rust

Generate Rust register maps (`struct`s) from SVD files
Apache License 2.0
682 stars 149 forks source link

Fix generated code for MSP430 atomics #688

Closed YuhanLiin closed 1 year ago

YuhanLiin commented 1 year ago

Rebased from #685

rust-highfive commented 1 year ago

r? @adamgreig

(rust-highfive has picked a reviewer for you, use r? to override)

burrbull commented 1 year ago

SVD link 404 error

burrbull commented 1 year ago

bors r+

bors[bot] commented 1 year ago

Build succeeded:

YuhanLiin commented 1 year ago

Note: Now that I've switched the atomic library over to portable-atomic, we might be able to port this feature over to other targets.

burrbull commented 1 year ago

Note: Now that I've switched the atomic library over to portable-atomic, we might be able to port this feature over to other targets.

it sounds interesting

adamgreig commented 1 year ago

I haven't compared them in detail, but for other targets it might make more sense to use atomic-polyfill which builds on critical-section and is quite widely used in other embedded Rust projects. portable-atomic can only use a global disable-interrupts to simulate CAS operations (when enabled with --cfg portable_atomic_unsafe_assume_single_core), while atomic-polyfill uses critical-section which allows pluggable implementations (and is used in svd2rust for Peripherals::take()).

At the moment I don't think atomic-polyfill supports MSP430 at all, so it's not an option here (yet?).