aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/ppi
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2022-07-23 14:00:19 +0200
committerDario Nieuwenhuis <[email protected]>2022-07-23 14:00:19 +0200
commit4901c34d9c4cd326ab9bca02dd099a663da2567f (patch)
tree8225afebb595fb10c1d67148c0d19b7b732853da /embassy-nrf/src/ppi
parent8a9d2f59af004902d3978a2922843833b98bcce0 (diff)
Rename Unborrowed -> PeripheralRef, Unborrow -> Peripheral
Diffstat (limited to 'embassy-nrf/src/ppi')
-rw-r--r--embassy-nrf/src/ppi/dppi.rs12
-rw-r--r--embassy-nrf/src/ppi/mod.rs14
-rw-r--r--embassy-nrf/src/ppi/ppi.rs16
3 files changed, 21 insertions, 21 deletions
diff --git a/embassy-nrf/src/ppi/dppi.rs b/embassy-nrf/src/ppi/dppi.rs
index 87ebb7084..de856c0ca 100644
--- a/embassy-nrf/src/ppi/dppi.rs
+++ b/embassy-nrf/src/ppi/dppi.rs
@@ -1,7 +1,7 @@
1use embassy_hal_common::unborrow; 1use embassy_hal_common::into_ref;
2 2
3use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; 3use super::{Channel, ConfigurableChannel, Event, Ppi, Task};
4use crate::{pac, Unborrow}; 4use crate::{pac, Peripheral};
5 5
6const DPPI_ENABLE_BIT: u32 = 0x8000_0000; 6const DPPI_ENABLE_BIT: u32 = 0x8000_0000;
7const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF; 7const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF;
@@ -11,13 +11,13 @@ fn regs() -> &'static pac::dppic::RegisterBlock {
11} 11}
12 12
13impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { 13impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
14 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self { 14 pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self {
15 Ppi::new_many_to_many(ch, [event], [task]) 15 Ppi::new_many_to_many(ch, [event], [task])
16 } 16 }
17} 17}
18 18
19impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { 19impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> {
20 pub fn new_one_to_two(ch: impl Unborrow<Target = C> + 'd, event: Event, task1: Task, task2: Task) -> Self { 20 pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self {
21 Ppi::new_many_to_many(ch, [event], [task1, task2]) 21 Ppi::new_many_to_many(ch, [event], [task1, task2])
22 } 22 }
23} 23}
@@ -26,11 +26,11 @@ impl<'d, C: ConfigurableChannel, const EVENT_COUNT: usize, const TASK_COUNT: usi
26 Ppi<'d, C, EVENT_COUNT, TASK_COUNT> 26 Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
27{ 27{
28 pub fn new_many_to_many( 28 pub fn new_many_to_many(
29 ch: impl Unborrow<Target = C> + 'd, 29 ch: impl Peripheral<P = C> + 'd,
30 events: [Event; EVENT_COUNT], 30 events: [Event; EVENT_COUNT],
31 tasks: [Task; TASK_COUNT], 31 tasks: [Task; TASK_COUNT],
32 ) -> Self { 32 ) -> Self {
33 unborrow!(ch); 33 into_ref!(ch);
34 34
35 let val = DPPI_ENABLE_BIT | (ch.number() as u32 & DPPI_CHANNEL_MASK); 35 let val = DPPI_ENABLE_BIT | (ch.number() as u32 & DPPI_CHANNEL_MASK);
36 for task in tasks { 36 for task in tasks {
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs
index fd1d0cf8c..796de2170 100644
--- a/embassy-nrf/src/ppi/mod.rs
+++ b/embassy-nrf/src/ppi/mod.rs
@@ -17,9 +17,9 @@
17 17
18use core::ptr::NonNull; 18use core::ptr::NonNull;
19 19
20use embassy_hal_common::{impl_unborrow, Unborrowed}; 20use embassy_hal_common::{impl_peripheral, PeripheralRef};
21 21
22use crate::{peripherals, Unborrow}; 22use crate::{peripherals, Peripheral};
23 23
24#[cfg(feature = "_dppi")] 24#[cfg(feature = "_dppi")]
25mod dppi; 25mod dppi;
@@ -27,7 +27,7 @@ mod dppi;
27mod ppi; 27mod ppi;
28 28
29pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> { 29pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> {
30 ch: Unborrowed<'d, C>, 30 ch: PeripheralRef<'d, C>,
31 #[cfg(feature = "_dppi")] 31 #[cfg(feature = "_dppi")]
32 events: [Event; EVENT_COUNT], 32 events: [Event; EVENT_COUNT],
33 #[cfg(feature = "_dppi")] 33 #[cfg(feature = "_dppi")]
@@ -87,7 +87,7 @@ pub(crate) mod sealed {
87 pub trait Group {} 87 pub trait Group {}
88} 88}
89 89
90pub trait Channel: sealed::Channel + Unborrow<Target = Self> + Sized { 90pub trait Channel: sealed::Channel + Peripheral<P = Self> + Sized {
91 /// Returns the number of the channel 91 /// Returns the number of the channel
92 fn number(&self) -> usize; 92 fn number(&self) -> usize;
93} 93}
@@ -117,7 +117,7 @@ pub trait Group: sealed::Group + Sized {
117pub struct AnyStaticChannel { 117pub struct AnyStaticChannel {
118 pub(crate) number: u8, 118 pub(crate) number: u8,
119} 119}
120impl_unborrow!(AnyStaticChannel); 120impl_peripheral!(AnyStaticChannel);
121impl sealed::Channel for AnyStaticChannel {} 121impl sealed::Channel for AnyStaticChannel {}
122impl Channel for AnyStaticChannel { 122impl Channel for AnyStaticChannel {
123 fn number(&self) -> usize { 123 fn number(&self) -> usize {
@@ -135,7 +135,7 @@ impl StaticChannel for AnyStaticChannel {
135pub struct AnyConfigurableChannel { 135pub struct AnyConfigurableChannel {
136 pub(crate) number: u8, 136 pub(crate) number: u8,
137} 137}
138impl_unborrow!(AnyConfigurableChannel); 138impl_peripheral!(AnyConfigurableChannel);
139impl sealed::Channel for AnyConfigurableChannel {} 139impl sealed::Channel for AnyConfigurableChannel {}
140impl Channel for AnyConfigurableChannel { 140impl Channel for AnyConfigurableChannel {
141 fn number(&self) -> usize { 141 fn number(&self) -> usize {
@@ -187,7 +187,7 @@ macro_rules! impl_ppi_channel {
187pub struct AnyGroup { 187pub struct AnyGroup {
188 number: u8, 188 number: u8,
189} 189}
190impl_unborrow!(AnyGroup); 190impl_peripheral!(AnyGroup);
191impl sealed::Group for AnyGroup {} 191impl sealed::Group for AnyGroup {}
192impl Group for AnyGroup { 192impl Group for AnyGroup {
193 fn number(&self) -> usize { 193 fn number(&self) -> usize {
diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs
index 3b8f44da8..450a290a2 100644
--- a/embassy-nrf/src/ppi/ppi.rs
+++ b/embassy-nrf/src/ppi/ppi.rs
@@ -1,7 +1,7 @@
1use embassy_hal_common::unborrow; 1use embassy_hal_common::into_ref;
2 2
3use super::{Channel, ConfigurableChannel, Event, Ppi, StaticChannel, Task}; 3use super::{Channel, ConfigurableChannel, Event, Ppi, StaticChannel, Task};
4use crate::{pac, Unborrow}; 4use crate::{pac, Peripheral};
5 5
6impl Task { 6impl Task {
7 fn reg_val(&self) -> u32 { 7 fn reg_val(&self) -> u32 {
@@ -20,8 +20,8 @@ fn regs() -> &'static pac::ppi::RegisterBlock {
20 20
21#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task 21#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
22impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> { 22impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> {
23 pub fn new_zero_to_one(ch: impl Unborrow<Target = C> + 'd, task: Task) -> Self { 23 pub fn new_zero_to_one(ch: impl Peripheral<P = C> + 'd, task: Task) -> Self {
24 unborrow!(ch); 24 into_ref!(ch);
25 25
26 let r = regs(); 26 let r = regs();
27 let n = ch.number(); 27 let n = ch.number();
@@ -32,8 +32,8 @@ impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> {
32} 32}
33 33
34impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { 34impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
35 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self { 35 pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self {
36 unborrow!(ch); 36 into_ref!(ch);
37 37
38 let r = regs(); 38 let r = regs();
39 let n = ch.number(); 39 let n = ch.number();
@@ -46,8 +46,8 @@ impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
46 46
47#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task 47#[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task
48impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { 48impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> {
49 pub fn new_one_to_two(ch: impl Unborrow<Target = C> + 'd, event: Event, task1: Task, task2: Task) -> Self { 49 pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self {
50 unborrow!(ch); 50 into_ref!(ch);
51 51
52 let r = regs(); 52 let r = regs();
53 let n = ch.number(); 53 let n = ch.number();