Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Provide critical_section implementation. #13

Open
reitermarkus opened this issue Aug 24, 2022 · 1 comment
Open

Provide critical_section implementation. #13

reitermarkus opened this issue Aug 24, 2022 · 1 comment

Comments

@reitermarkus
Copy link
Member

The next version of svd2rust will depend on critical_section for Peripherals::take (see rust-embedded/svd2rust#651), so this crate should provide an implementation (see https://docs.rs/critical-section/latest/critical_section/#providing-an-implementation).

@cr1901
Copy link
Contributor

cr1901 commented Aug 24, 2022

This is already being worked on in the critical_section branch. There are a few optimization/codegen problems I'm looking at before deploying it/releasing a new version.

This version will be semver-compat with 0.3.0; a PAC that uses interrupt::free (msp430 0.3.0/0.3.1) for Peripherals::take can coexist w/ an application that uses the critical_section implementation that this crate will provide in 0.3.1. A PAC using critical_section can also coexist with msp430 0.3.0, though I don't see that happening often by accident :). In fact, it's probably better to mandate msp430 0.3.1 and above for PACs generated with the next version of svd2rust, just to avoid pulling in both bare_metal and critical_section types in the same application.

The semver-compat should be okay because interrupt::free and the critical_section impl provided are functionally identical. AFACIT, since interrupt::free disables interrupts and all msp430s are single core, interrupt::free can coexist with any other possible critical_section impls for msp430. This is because any critical section implementation will build upon disabling interrupts at some point as the lowest common denominator. interrupt::free is deprecated, however, and will be removed as part of semver-incompat changes.

bors bot added a commit to rust-embedded/svd2rust that referenced this issue Aug 24, 2022
651: Use `critical_section` for `Peripherals::take`. r=therealprof a=reitermarkus

- `cortex_m` rust-embedded/cortex-m#447
- `msp430` rust-embedded/msp430#13
- `riscv` rust-embedded/riscv#110
-  `xtensa_lx` esp-rs/xtensa-lx#20, esp-rs/esp-hal#151
- `mips_mcu` kiffie/pic32-rs#5


Co-authored-by: Markus Reiter <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants