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

The usage of take() and critical-section should be added #679

Closed
duskmoon314 opened this issue Oct 24, 2022 · 0 comments · Fixed by #680
Closed

The usage of take() and critical-section should be added #679

duskmoon314 opened this issue Oct 24, 2022 · 0 comments · Fixed by #680

Comments

@duskmoon314
Copy link
Contributor

After merging #651, Peripherals::take() is not callable unless the user of pac provides an implementation. So we should add how to use it in the document.


Usage I have tried

The following part is mentioned in the matrix chatting room.

I have tried some ways and found two ways of using take():

1 User provide implementation

Users can add implement on their own or use the implementation provided by the target or hal crate. An example will be like this:

# Cargo.toml
# version and other info are ignored
some-pac = { features = ["critical-section"] }
riscv = { features = ["critical-section-single-hart"] }

Then adding a dummy use:

use rust as _;

2 Provide implementation in PAC

We can also provide the implementation in PAC through the target crate.

// lib.rs
#[cfg(feature = "critical-section-single-hart")]
use riscv as _;
# Cargo.toml
[features]
critical-section-single-hart = ["critical-section", "riscv/critical-section-single-hart"]

Then users can add pac like this:

some-pac = { features = ["critical-section-single-hart"] }

Discussion

There may be other usages that I haven't found out. I think it may not be PAC's purpose to provide the implementation. So there should have a section of this in the documentation.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants