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

Use abstract critical sections for thumbv6 #98

Closed
wants to merge 2 commits into from

Conversation

Sizurka
Copy link

@Sizurka Sizurka commented Apr 9, 2023

This changes the critical sections required for thumbv6 to use the abstraction provided by the critical_section crate. The context here is the RP2040 micocontroller, which is a two core Cortex-M0+ device, so just disabling interrupts on the current core is not sufficient when a bbqueue is used to communicate between cores. However, the HAL provides an implementation of a critical section hooking into the abstraction above to handle this kind of case.

With this change, using bbqueue on single core thumbv6 target (equivalent to the current behavior) looks like:

[dependencies]
bbqueue = { version = "0.5", features = ["thumbv6"] }
cortex-m =  { version = "0.7.6", features = ["critical-section-single-core"] }

Or for a RP2040 in multi-core mode:

[dependencies]
bbqueue = { version = "0.5", features = ["thumbv6"] }
rp2040-hal = { version = "0.8.0", features=["critical-section-impl"] }

Instead of implementing critical sections directly, use the
critical_section crate for abstraction.  A simple implementation that
disables interrupts is available in cortex-m with a feature switch
that preserves existing behavior.
@ithinuel ithinuel mentioned this pull request Nov 9, 2023
Copy link
Collaborator

@ithinuel ithinuel left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The change seems good to me. This change makes it portable to any target.

@jamesmunns is it ok to do breaking change before next release?

If so, I think the thumbv6 feature could be removed in favor of the default critical-section feature introduced by the optional flag since it is no longer thumbv6m specific.

@jamesmunns
Copy link
Owner

@ithinuel please feel free to make any breaking changes! I'm open to either using the critical-section crate, or moving to portable-atomic, which can use critical-section as necessary for targets which don't support atomics natively.

@ithinuel
Copy link
Collaborator

Migration to portable-atomic (plus a few other tiny changes) in #103

@Sympatron
Copy link
Collaborator

Closing in favor of #103.

@Sympatron Sympatron closed this Dec 9, 2024
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

Successfully merging this pull request may close these issues.

4 participants