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 _;
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.
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
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:
Then adding a dummy use:
2 Provide implementation in PAC
We can also provide the implementation in PAC through the target crate.
Then users can add pac like this:
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.