aboutsummaryrefslogtreecommitdiff
path: root/embassy-nrf/src/ppi/dppi.rs
diff options
context:
space:
mode:
authorDario Nieuwenhuis <[email protected]>2021-10-28 03:07:06 +0200
committerDario Nieuwenhuis <[email protected]>2021-10-28 03:36:25 +0200
commit663141b4e456bbfacaaff8decdba6840c76a136b (patch)
tree8d151a795b008ab0791a6faa5dbd36e5b83522b5 /embassy-nrf/src/ppi/dppi.rs
parentc995a97f2032d329c2955c79054b7e466b0b423b (diff)
nrf: add initial nrf5340 support
Diffstat (limited to 'embassy-nrf/src/ppi/dppi.rs')
-rw-r--r--embassy-nrf/src/ppi/dppi.rs22
1 files changed, 22 insertions, 0 deletions
diff --git a/embassy-nrf/src/ppi/dppi.rs b/embassy-nrf/src/ppi/dppi.rs
index b3676fca4..1842590b4 100644
--- a/embassy-nrf/src/ppi/dppi.rs
+++ b/embassy-nrf/src/ppi/dppi.rs
@@ -3,11 +3,17 @@ use core::marker::PhantomData;
3use embassy::util::Unborrow; 3use embassy::util::Unborrow;
4use embassy_hal_common::unborrow; 4use embassy_hal_common::unborrow;
5 5
6use crate::pac;
7
6use super::{Channel, ConfigurableChannel, Event, Ppi, Task}; 8use super::{Channel, ConfigurableChannel, Event, Ppi, Task};
7 9
8const DPPI_ENABLE_BIT: u32 = 0x8000_0000; 10const DPPI_ENABLE_BIT: u32 = 0x8000_0000;
9const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF; 11const DPPI_CHANNEL_MASK: u32 = 0x0000_00FF;
10 12
13fn regs() -> &'static pac::dppic::RegisterBlock {
14 unsafe { &*pac::DPPIC::ptr() }
15}
16
11impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { 17impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> {
12 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self { 18 pub fn new_one_to_one(ch: impl Unborrow<Target = C> + 'd, event: Event, task: Task) -> Self {
13 Ppi::new_many_to_many(ch, [event], [task]) 19 Ppi::new_many_to_many(ch, [event], [task])
@@ -58,6 +64,22 @@ impl<'d, C: ConfigurableChannel, const EVENT_COUNT: usize, const TASK_COUNT: usi
58 } 64 }
59} 65}
60 66
67impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize>
68 Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
69{
70 /// Enables the channel.
71 pub fn enable(&mut self) {
72 let n = self.ch.number();
73 regs().chenset.write(|w| unsafe { w.bits(1 << n) });
74 }
75
76 /// Disables the channel.
77 pub fn disable(&mut self) {
78 let n = self.ch.number();
79 regs().chenclr.write(|w| unsafe { w.bits(1 << n) });
80 }
81}
82
61impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop 83impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop
62 for Ppi<'d, C, EVENT_COUNT, TASK_COUNT> 84 for Ppi<'d, C, EVENT_COUNT, TASK_COUNT>
63{ 85{