Skip to content

Commit 56cbdac

Browse files
Merge pull request #259 from jonas-schievink/sealant
Seal public PPI traits
2 parents a47e883 + c160e1a commit 56cbdac

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
- Seal the `timer::Instance` trait ([#214]).
3838
- Make GPIOs start in a `Disconnected` state instead of `Input<Floating>` ([#220] [#245]).
3939
- 🦭 all `Instance` traits ([#255]).
40+
- 🦭 PPI traits ([#259]).
4041
- Various TWIM fixes and improvements - removes automatic transfer splitting ([#242]).
4142
- Remove typestate from RTC to make it easier to use ([#252]).
4243

@@ -79,6 +80,7 @@
7980
[#250]: https://github.com/nrf-rs/nrf-hal/pull/250
8081
[#252]: https://github.com/nrf-rs/nrf-hal/pull/252
8182
[#255]: https://github.com/nrf-rs/nrf-hal/pull/255
83+
[#259]: https://github.com/nrf-rs/nrf-hal/pull/259
8284
[`cargo-xtask`]: https://github.com/matklad/cargo-xtask
8385

8486
## [0.11.1]

nrf-hal-common/src/ppi/mod.rs

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,17 @@ mod sealed {
6161
pub trait ChannelGroup {
6262
const CHG: usize;
6363
}
64+
65+
pub trait PpiSealed {}
66+
pub trait PpiChannelGroupSealed {}
6467
}
65-
use sealed::{Channel, ChannelGroup, Event, NotFixed, Task};
68+
use sealed::{Channel, ChannelGroup, Event, NotFixed, PpiChannelGroupSealed, PpiSealed, Task};
6669

6770
pub struct TaskAddr(pub(crate) u32);
6871
pub struct EventAddr(pub(crate) u32);
6972

7073
/// Trait to represent a Programmable Peripheral Interconnect channel.
71-
pub trait Ppi {
74+
pub trait Ppi: PpiSealed {
7275
/// Enables the channel.
7376
fn enable(&mut self);
7477

@@ -93,7 +96,7 @@ pub trait ConfigurablePpi: Ppi {
9396
}
9497

9598
/// Trait for a PPI channel group.
96-
pub trait PpiChannelGroup {
99+
pub trait PpiChannelGroup: PpiChannelGroupSealed {
97100
/// Returns reference to `tasks_chg[x].en` endpoint for enabling channel group.
98101
fn task_enable(&self) -> &Reg<u32, _EN>;
99102
/// Returns reference to `tasks_chg[x].dis` endpoint for disabling channel group.
@@ -108,6 +111,7 @@ pub trait PpiChannelGroup {
108111

109112
// All unsafe `ptr` calls only uses registers atomically, and only changes the resources owned by
110113
// the type (guaranteed by the abstraction).
114+
impl<P: Channel> PpiSealed for P {}
111115
impl<P: Channel> Ppi for P {
112116
#[inline(always)]
113117
fn enable(&mut self) {
@@ -151,6 +155,7 @@ impl<P: Channel + NotFixed> ConfigurablePpi for P {
151155
}
152156
}
153157

158+
impl<G: ChannelGroup> PpiChannelGroupSealed for G {}
154159
impl<G: ChannelGroup> PpiChannelGroup for G {
155160
#[inline(always)]
156161
fn task_enable(&self) -> &Reg<u32, _EN> {

0 commit comments

Comments
 (0)