diff options
| author | Dario Nieuwenhuis <[email protected]> | 2023-07-05 17:13:26 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2023-07-05 17:13:26 +0000 |
| commit | 8313b7315a960fc470d148fdb1410c00d1f75ed1 (patch) | |
| tree | 6b2c90e76b33c42dd6625683bdfb93ab9f6e8c2c /embassy-nrf | |
| parent | 46a46009520036cc4b4dd52e7e3bdc5191b67ea0 (diff) | |
| parent | d7ecf6f59394ff1ca322a096b7405c8f552d4c44 (diff) | |
Merge pull request #1600 from ilikepi63/main
feature(1354): Added lifetimes to Event + Tasks
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi/dppi.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi/mod.rs | 37 | ||||
| -rw-r--r-- | embassy-nrf/src/ppi/ppi.rs | 8 | ||||
| -rw-r--r-- | embassy-nrf/src/pwm.rs | 22 | ||||
| -rw-r--r-- | embassy-nrf/src/saadc.rs | 4 | ||||
| -rw-r--r-- | embassy-nrf/src/timer.rs | 12 |
7 files changed, 54 insertions, 45 deletions
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index 21d0d9564..6550f2abd 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -221,7 +221,7 @@ impl<'d, C: Channel, T: GpioPin> InputChannel<'d, C, T> { | |||
| 221 | } | 221 | } |
| 222 | 222 | ||
| 223 | /// Returns the IN event, for use with PPI. | 223 | /// Returns the IN event, for use with PPI. |
| 224 | pub fn event_in(&self) -> Event { | 224 | pub fn event_in(&self) -> Event<'d> { |
| 225 | let g = regs(); | 225 | let g = regs(); |
| 226 | Event::from_reg(&g.events_in[self.ch.number()]) | 226 | Event::from_reg(&g.events_in[self.ch.number()]) |
| 227 | } | 227 | } |
| @@ -292,21 +292,21 @@ impl<'d, C: Channel, T: GpioPin> OutputChannel<'d, C, T> { | |||
| 292 | } | 292 | } |
| 293 | 293 | ||
| 294 | /// Returns the OUT task, for use with PPI. | 294 | /// Returns the OUT task, for use with PPI. |
| 295 | pub fn task_out(&self) -> Task { | 295 | pub fn task_out(&self) -> Task<'d> { |
| 296 | let g = regs(); | 296 | let g = regs(); |
| 297 | Task::from_reg(&g.tasks_out[self.ch.number()]) | 297 | Task::from_reg(&g.tasks_out[self.ch.number()]) |
| 298 | } | 298 | } |
| 299 | 299 | ||
| 300 | /// Returns the CLR task, for use with PPI. | 300 | /// Returns the CLR task, for use with PPI. |
| 301 | #[cfg(not(feature = "nrf51"))] | 301 | #[cfg(not(feature = "nrf51"))] |
| 302 | pub fn task_clr(&self) -> Task { | 302 | pub fn task_clr(&self) -> Task<'d> { |
| 303 | let g = regs(); | 303 | let g = regs(); |
| 304 | Task::from_reg(&g.tasks_clr[self.ch.number()]) | 304 | Task::from_reg(&g.tasks_clr[self.ch.number()]) |
| 305 | } | 305 | } |
| 306 | 306 | ||
| 307 | /// Returns the SET task, for use with PPI. | 307 | /// Returns the SET task, for use with PPI. |
| 308 | #[cfg(not(feature = "nrf51"))] | 308 | #[cfg(not(feature = "nrf51"))] |
| 309 | pub fn task_set(&self) -> Task { | 309 | pub fn task_set(&self) -> Task<'d> { |
| 310 | let g = regs(); | 310 | let g = regs(); |
| 311 | Task::from_reg(&g.tasks_set[self.ch.number()]) | 311 | Task::from_reg(&g.tasks_set[self.ch.number()]) |
| 312 | } | 312 | } |
diff --git a/embassy-nrf/src/ppi/dppi.rs b/embassy-nrf/src/ppi/dppi.rs index 3a1e7f170..40ccb2f09 100644 --- a/embassy-nrf/src/ppi/dppi.rs +++ b/embassy-nrf/src/ppi/dppi.rs | |||
| @@ -12,14 +12,14 @@ pub(crate) fn regs() -> &'static pac::dppic::RegisterBlock { | |||
| 12 | 12 | ||
| 13 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { | 13 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { |
| 14 | /// Configure PPI channel to trigger `task` on `event`. | 14 | /// Configure PPI channel to trigger `task` on `event`. |
| 15 | pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self { | 15 | pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event<'d>, task: Task<'d>) -> Self { |
| 16 | Ppi::new_many_to_many(ch, [event], [task]) | 16 | Ppi::new_many_to_many(ch, [event], [task]) |
| 17 | } | 17 | } |
| 18 | } | 18 | } |
| 19 | 19 | ||
| 20 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { | 20 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { |
| 21 | /// Configure PPI channel to trigger both `task1` and `task2` on `event`. | 21 | /// Configure PPI channel to trigger both `task1` and `task2` on `event`. |
| 22 | pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self { | 22 | pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event<'d>, task1: Task<'d>, task2: Task<'d>) -> Self { |
| 23 | Ppi::new_many_to_many(ch, [event], [task1, task2]) | 23 | Ppi::new_many_to_many(ch, [event], [task1, task2]) |
| 24 | } | 24 | } |
| 25 | } | 25 | } |
| @@ -30,8 +30,8 @@ impl<'d, C: ConfigurableChannel, const EVENT_COUNT: usize, const TASK_COUNT: usi | |||
| 30 | /// Configure a DPPI channel to trigger all `tasks` when any of the `events` fires. | 30 | /// Configure a DPPI channel to trigger all `tasks` when any of the `events` fires. |
| 31 | pub fn new_many_to_many( | 31 | pub fn new_many_to_many( |
| 32 | ch: impl Peripheral<P = C> + 'd, | 32 | ch: impl Peripheral<P = C> + 'd, |
| 33 | events: [Event; EVENT_COUNT], | 33 | events: [Event<'d>; EVENT_COUNT], |
| 34 | tasks: [Task; TASK_COUNT], | 34 | tasks: [Task<'d>; TASK_COUNT], |
| 35 | ) -> Self { | 35 | ) -> Self { |
| 36 | into_ref!(ch); | 36 | into_ref!(ch); |
| 37 | 37 | ||
diff --git a/embassy-nrf/src/ppi/mod.rs b/embassy-nrf/src/ppi/mod.rs index 76757a248..ff6593bd5 100644 --- a/embassy-nrf/src/ppi/mod.rs +++ b/embassy-nrf/src/ppi/mod.rs | |||
| @@ -15,6 +15,7 @@ | |||
| 15 | //! many tasks and events, but any single task or event can only be coupled with one channel. | 15 | //! many tasks and events, but any single task or event can only be coupled with one channel. |
| 16 | //! | 16 | //! |
| 17 | 17 | ||
| 18 | use core::marker::PhantomData; | ||
| 18 | use core::ptr::NonNull; | 19 | use core::ptr::NonNull; |
| 19 | 20 | ||
| 20 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; | 21 | use embassy_hal_common::{impl_peripheral, into_ref, PeripheralRef}; |
| @@ -30,9 +31,9 @@ pub(crate) use _version::*; | |||
| 30 | pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> { | 31 | pub struct Ppi<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> { |
| 31 | ch: PeripheralRef<'d, C>, | 32 | ch: PeripheralRef<'d, C>, |
| 32 | #[cfg(feature = "_dppi")] | 33 | #[cfg(feature = "_dppi")] |
| 33 | events: [Event; EVENT_COUNT], | 34 | events: [Event<'d>; EVENT_COUNT], |
| 34 | #[cfg(feature = "_dppi")] | 35 | #[cfg(feature = "_dppi")] |
| 35 | tasks: [Task; TASK_COUNT], | 36 | tasks: [Task<'d>; TASK_COUNT], |
| 36 | } | 37 | } |
| 37 | 38 | ||
| 38 | /// PPI channel group driver. | 39 | /// PPI channel group driver. |
| @@ -95,7 +96,7 @@ impl<'d, G: Group> PpiGroup<'d, G> { | |||
| 95 | /// Get a reference to the "enable all" task. | 96 | /// Get a reference to the "enable all" task. |
| 96 | /// | 97 | /// |
| 97 | /// When triggered, it will enable all the channels in this group. | 98 | /// When triggered, it will enable all the channels in this group. |
| 98 | pub fn task_enable_all(&self) -> Task { | 99 | pub fn task_enable_all(&self) -> Task<'d> { |
| 99 | let n = self.g.number(); | 100 | let n = self.g.number(); |
| 100 | Task::from_reg(®s().tasks_chg[n].en) | 101 | Task::from_reg(®s().tasks_chg[n].en) |
| 101 | } | 102 | } |
| @@ -103,7 +104,7 @@ impl<'d, G: Group> PpiGroup<'d, G> { | |||
| 103 | /// Get a reference to the "disable all" task. | 104 | /// Get a reference to the "disable all" task. |
| 104 | /// | 105 | /// |
| 105 | /// When triggered, it will disable all the channels in this group. | 106 | /// When triggered, it will disable all the channels in this group. |
| 106 | pub fn task_disable_all(&self) -> Task { | 107 | pub fn task_disable_all(&self) -> Task<'d> { |
| 107 | let n = self.g.number(); | 108 | let n = self.g.number(); |
| 108 | Task::from_reg(®s().tasks_chg[n].dis) | 109 | Task::from_reg(®s().tasks_chg[n].dis) |
| 109 | } | 110 | } |
| @@ -125,16 +126,16 @@ const REGISTER_DPPI_CONFIG_OFFSET: usize = 0x80 / core::mem::size_of::<u32>(); | |||
| 125 | /// When a task is subscribed to a PPI channel, it will run when the channel is triggered by | 126 | /// When a task is subscribed to a PPI channel, it will run when the channel is triggered by |
| 126 | /// a published event. | 127 | /// a published event. |
| 127 | #[derive(PartialEq, Eq, Clone, Copy)] | 128 | #[derive(PartialEq, Eq, Clone, Copy)] |
| 128 | pub struct Task(NonNull<u32>); | 129 | pub struct Task<'d>(NonNull<u32>, PhantomData<&'d ()>); |
| 129 | 130 | ||
| 130 | impl Task { | 131 | impl<'d> Task<'d> { |
| 131 | /// Create a new `Task` from a task register pointer | 132 | /// Create a new `Task` from a task register pointer |
| 132 | /// | 133 | /// |
| 133 | /// # Safety | 134 | /// # Safety |
| 134 | /// | 135 | /// |
| 135 | /// `ptr` must be a pointer to a valid `TASKS_*` register from an nRF peripheral. | 136 | /// `ptr` must be a pointer to a valid `TASKS_*` register from an nRF peripheral. |
| 136 | pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self { | 137 | pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self { |
| 137 | Self(ptr) | 138 | Self(ptr, PhantomData) |
| 138 | } | 139 | } |
| 139 | 140 | ||
| 140 | /// Triggers this task. | 141 | /// Triggers this task. |
| @@ -143,7 +144,10 @@ impl Task { | |||
| 143 | } | 144 | } |
| 144 | 145 | ||
| 145 | pub(crate) fn from_reg<T>(reg: &T) -> Self { | 146 | pub(crate) fn from_reg<T>(reg: &T) -> Self { |
| 146 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) | 147 | Self( |
| 148 | unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }, | ||
| 149 | PhantomData, | ||
| 150 | ) | ||
| 147 | } | 151 | } |
| 148 | 152 | ||
| 149 | /// Address of subscription register for this task. | 153 | /// Address of subscription register for this task. |
| @@ -156,26 +160,29 @@ impl Task { | |||
| 156 | /// # Safety | 160 | /// # Safety |
| 157 | /// | 161 | /// |
| 158 | /// NonNull is not send, but this event is only allowed to point at registers and those exist in any context on the same core. | 162 | /// NonNull is not send, but this event is only allowed to point at registers and those exist in any context on the same core. |
| 159 | unsafe impl Send for Task {} | 163 | unsafe impl Send for Task<'_> {} |
| 160 | 164 | ||
| 161 | /// Represents an event that a peripheral can publish. | 165 | /// Represents an event that a peripheral can publish. |
| 162 | /// | 166 | /// |
| 163 | /// An event can be set to publish on a PPI channel when the event happens. | 167 | /// An event can be set to publish on a PPI channel when the event happens. |
| 164 | #[derive(PartialEq, Eq, Clone, Copy)] | 168 | #[derive(PartialEq, Eq, Clone, Copy)] |
| 165 | pub struct Event(NonNull<u32>); | 169 | pub struct Event<'d>(NonNull<u32>, PhantomData<&'d ()>); |
| 166 | 170 | ||
| 167 | impl Event { | 171 | impl<'d> Event<'d> { |
| 168 | /// Create a new `Event` from an event register pointer | 172 | /// Create a new `Event` from an event register pointer |
| 169 | /// | 173 | /// |
| 170 | /// # Safety | 174 | /// # Safety |
| 171 | /// | 175 | /// |
| 172 | /// `ptr` must be a pointer to a valid `EVENTS_*` register from an nRF peripheral. | 176 | /// `ptr` must be a pointer to a valid `EVENTS_*` register from an nRF peripheral. |
| 173 | pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self { | 177 | pub unsafe fn new_unchecked(ptr: NonNull<u32>) -> Self { |
| 174 | Self(ptr) | 178 | Self(ptr, PhantomData) |
| 175 | } | 179 | } |
| 176 | 180 | ||
| 177 | pub(crate) fn from_reg<T>(reg: &T) -> Self { | 181 | pub(crate) fn from_reg<T>(reg: &'d T) -> Self { |
| 178 | Self(unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }) | 182 | Self( |
| 183 | unsafe { NonNull::new_unchecked(reg as *const _ as *mut _) }, | ||
| 184 | PhantomData, | ||
| 185 | ) | ||
| 179 | } | 186 | } |
| 180 | 187 | ||
| 181 | /// Describes whether this Event is currently in a triggered state. | 188 | /// Describes whether this Event is currently in a triggered state. |
| @@ -198,7 +205,7 @@ impl Event { | |||
| 198 | /// # Safety | 205 | /// # Safety |
| 199 | /// | 206 | /// |
| 200 | /// NonNull is not send, but this event is only allowed to point at registers and those exist in any context on the same core. | 207 | /// NonNull is not send, but this event is only allowed to point at registers and those exist in any context on the same core. |
| 201 | unsafe impl Send for Event {} | 208 | unsafe impl Send for Event<'_> {} |
| 202 | 209 | ||
| 203 | // ====================== | 210 | // ====================== |
| 204 | // traits | 211 | // traits |
diff --git a/embassy-nrf/src/ppi/ppi.rs b/embassy-nrf/src/ppi/ppi.rs index f1eeaee1e..1fe898625 100644 --- a/embassy-nrf/src/ppi/ppi.rs +++ b/embassy-nrf/src/ppi/ppi.rs | |||
| @@ -3,12 +3,12 @@ use embassy_hal_common::into_ref; | |||
| 3 | use super::{Channel, ConfigurableChannel, Event, Ppi, StaticChannel, Task}; | 3 | use super::{Channel, ConfigurableChannel, Event, Ppi, StaticChannel, Task}; |
| 4 | use crate::{pac, Peripheral}; | 4 | use crate::{pac, Peripheral}; |
| 5 | 5 | ||
| 6 | impl Task { | 6 | impl<'d> Task<'d> { |
| 7 | fn reg_val(&self) -> u32 { | 7 | fn reg_val(&self) -> u32 { |
| 8 | self.0.as_ptr() as _ | 8 | self.0.as_ptr() as _ |
| 9 | } | 9 | } |
| 10 | } | 10 | } |
| 11 | impl Event { | 11 | impl<'d> Event<'d> { |
| 12 | fn reg_val(&self) -> u32 { | 12 | fn reg_val(&self) -> u32 { |
| 13 | self.0.as_ptr() as _ | 13 | self.0.as_ptr() as _ |
| 14 | } | 14 | } |
| @@ -34,7 +34,7 @@ impl<'d, C: StaticChannel> Ppi<'d, C, 0, 1> { | |||
| 34 | 34 | ||
| 35 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { | 35 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { |
| 36 | /// Configure PPI channel to trigger `task` on `event`. | 36 | /// Configure PPI channel to trigger `task` on `event`. |
| 37 | pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event, task: Task) -> Self { | 37 | pub fn new_one_to_one(ch: impl Peripheral<P = C> + 'd, event: Event<'d>, task: Task<'d>) -> Self { |
| 38 | into_ref!(ch); | 38 | into_ref!(ch); |
| 39 | 39 | ||
| 40 | let r = regs(); | 40 | let r = regs(); |
| @@ -49,7 +49,7 @@ impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 1> { | |||
| 49 | #[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task | 49 | #[cfg(not(feature = "nrf51"))] // Not for nrf51 because of the fork task |
| 50 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { | 50 | impl<'d, C: ConfigurableChannel> Ppi<'d, C, 1, 2> { |
| 51 | /// Configure PPI channel to trigger both `task1` and `task2` on `event`. | 51 | /// Configure PPI channel to trigger both `task1` and `task2` on `event`. |
| 52 | pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event, task1: Task, task2: Task) -> Self { | 52 | pub fn new_one_to_two(ch: impl Peripheral<P = C> + 'd, event: Event<'d>, task1: Task<'d>, task2: Task<'d>) -> Self { |
| 53 | into_ref!(ch); | 53 | into_ref!(ch); |
| 54 | 54 | ||
| 55 | let r = regs(); | 55 | let r = regs(); |
diff --git a/embassy-nrf/src/pwm.rs b/embassy-nrf/src/pwm.rs index 363a255d5..c8c81fa01 100644 --- a/embassy-nrf/src/pwm.rs +++ b/embassy-nrf/src/pwm.rs | |||
| @@ -181,7 +181,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 181 | 181 | ||
| 182 | /// Returns reference to `Stopped` event endpoint for PPI. | 182 | /// Returns reference to `Stopped` event endpoint for PPI. |
| 183 | #[inline(always)] | 183 | #[inline(always)] |
| 184 | pub fn event_stopped(&self) -> Event { | 184 | pub fn event_stopped(&self) -> Event<'d> { |
| 185 | let r = T::regs(); | 185 | let r = T::regs(); |
| 186 | 186 | ||
| 187 | Event::from_reg(&r.events_stopped) | 187 | Event::from_reg(&r.events_stopped) |
| @@ -189,7 +189,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 189 | 189 | ||
| 190 | /// Returns reference to `LoopsDone` event endpoint for PPI. | 190 | /// Returns reference to `LoopsDone` event endpoint for PPI. |
| 191 | #[inline(always)] | 191 | #[inline(always)] |
| 192 | pub fn event_loops_done(&self) -> Event { | 192 | pub fn event_loops_done(&self) -> Event<'d> { |
| 193 | let r = T::regs(); | 193 | let r = T::regs(); |
| 194 | 194 | ||
| 195 | Event::from_reg(&r.events_loopsdone) | 195 | Event::from_reg(&r.events_loopsdone) |
| @@ -197,7 +197,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 197 | 197 | ||
| 198 | /// Returns reference to `PwmPeriodEnd` event endpoint for PPI. | 198 | /// Returns reference to `PwmPeriodEnd` event endpoint for PPI. |
| 199 | #[inline(always)] | 199 | #[inline(always)] |
| 200 | pub fn event_pwm_period_end(&self) -> Event { | 200 | pub fn event_pwm_period_end(&self) -> Event<'d> { |
| 201 | let r = T::regs(); | 201 | let r = T::regs(); |
| 202 | 202 | ||
| 203 | Event::from_reg(&r.events_pwmperiodend) | 203 | Event::from_reg(&r.events_pwmperiodend) |
| @@ -205,7 +205,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 205 | 205 | ||
| 206 | /// Returns reference to `Seq0 End` event endpoint for PPI. | 206 | /// Returns reference to `Seq0 End` event endpoint for PPI. |
| 207 | #[inline(always)] | 207 | #[inline(always)] |
| 208 | pub fn event_seq_end(&self) -> Event { | 208 | pub fn event_seq_end(&self) -> Event<'d> { |
| 209 | let r = T::regs(); | 209 | let r = T::regs(); |
| 210 | 210 | ||
| 211 | Event::from_reg(&r.events_seqend[0]) | 211 | Event::from_reg(&r.events_seqend[0]) |
| @@ -213,7 +213,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 213 | 213 | ||
| 214 | /// Returns reference to `Seq1 End` event endpoint for PPI. | 214 | /// Returns reference to `Seq1 End` event endpoint for PPI. |
| 215 | #[inline(always)] | 215 | #[inline(always)] |
| 216 | pub fn event_seq1_end(&self) -> Event { | 216 | pub fn event_seq1_end(&self) -> Event<'d> { |
| 217 | let r = T::regs(); | 217 | let r = T::regs(); |
| 218 | 218 | ||
| 219 | Event::from_reg(&r.events_seqend[1]) | 219 | Event::from_reg(&r.events_seqend[1]) |
| @@ -221,7 +221,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 221 | 221 | ||
| 222 | /// Returns reference to `Seq0 Started` event endpoint for PPI. | 222 | /// Returns reference to `Seq0 Started` event endpoint for PPI. |
| 223 | #[inline(always)] | 223 | #[inline(always)] |
| 224 | pub fn event_seq0_started(&self) -> Event { | 224 | pub fn event_seq0_started(&self) -> Event<'d> { |
| 225 | let r = T::regs(); | 225 | let r = T::regs(); |
| 226 | 226 | ||
| 227 | Event::from_reg(&r.events_seqstarted[0]) | 227 | Event::from_reg(&r.events_seqstarted[0]) |
| @@ -229,7 +229,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 229 | 229 | ||
| 230 | /// Returns reference to `Seq1 Started` event endpoint for PPI. | 230 | /// Returns reference to `Seq1 Started` event endpoint for PPI. |
| 231 | #[inline(always)] | 231 | #[inline(always)] |
| 232 | pub fn event_seq1_started(&self) -> Event { | 232 | pub fn event_seq1_started(&self) -> Event<'d> { |
| 233 | let r = T::regs(); | 233 | let r = T::regs(); |
| 234 | 234 | ||
| 235 | Event::from_reg(&r.events_seqstarted[1]) | 235 | Event::from_reg(&r.events_seqstarted[1]) |
| @@ -240,7 +240,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 240 | /// | 240 | /// |
| 241 | /// Interacting with the sequence while it runs puts it in an unknown state | 241 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 242 | #[inline(always)] | 242 | #[inline(always)] |
| 243 | pub unsafe fn task_start_seq0(&self) -> Task { | 243 | pub unsafe fn task_start_seq0(&self) -> Task<'d> { |
| 244 | let r = T::regs(); | 244 | let r = T::regs(); |
| 245 | 245 | ||
| 246 | Task::from_reg(&r.tasks_seqstart[0]) | 246 | Task::from_reg(&r.tasks_seqstart[0]) |
| @@ -251,7 +251,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 251 | /// | 251 | /// |
| 252 | /// Interacting with the sequence while it runs puts it in an unknown state | 252 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 253 | #[inline(always)] | 253 | #[inline(always)] |
| 254 | pub unsafe fn task_start_seq1(&self) -> Task { | 254 | pub unsafe fn task_start_seq1(&self) -> Task<'d> { |
| 255 | let r = T::regs(); | 255 | let r = T::regs(); |
| 256 | 256 | ||
| 257 | Task::from_reg(&r.tasks_seqstart[1]) | 257 | Task::from_reg(&r.tasks_seqstart[1]) |
| @@ -262,7 +262,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 262 | /// | 262 | /// |
| 263 | /// Interacting with the sequence while it runs puts it in an unknown state | 263 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 264 | #[inline(always)] | 264 | #[inline(always)] |
| 265 | pub unsafe fn task_next_step(&self) -> Task { | 265 | pub unsafe fn task_next_step(&self) -> Task<'d> { |
| 266 | let r = T::regs(); | 266 | let r = T::regs(); |
| 267 | 267 | ||
| 268 | Task::from_reg(&r.tasks_nextstep) | 268 | Task::from_reg(&r.tasks_nextstep) |
| @@ -273,7 +273,7 @@ impl<'d, T: Instance> SequencePwm<'d, T> { | |||
| 273 | /// | 273 | /// |
| 274 | /// Interacting with the sequence while it runs puts it in an unknown state | 274 | /// Interacting with the sequence while it runs puts it in an unknown state |
| 275 | #[inline(always)] | 275 | #[inline(always)] |
| 276 | pub unsafe fn task_stop(&self) -> Task { | 276 | pub unsafe fn task_stop(&self) -> Task<'d> { |
| 277 | let r = T::regs(); | 277 | let r = T::regs(); |
| 278 | 278 | ||
| 279 | Task::from_reg(&r.tasks_stop) | 279 | Task::from_reg(&r.tasks_stop) |
diff --git a/embassy-nrf/src/saadc.rs b/embassy-nrf/src/saadc.rs index cf3fb9993..23292924c 100644 --- a/embassy-nrf/src/saadc.rs +++ b/embassy-nrf/src/saadc.rs | |||
| @@ -320,7 +320,9 @@ impl<'d, const N: usize> Saadc<'d, N> { | |||
| 320 | timer.cc(0).write(sample_counter); | 320 | timer.cc(0).write(sample_counter); |
| 321 | timer.cc(0).short_compare_clear(); | 321 | timer.cc(0).short_compare_clear(); |
| 322 | 322 | ||
| 323 | let mut sample_ppi = Ppi::new_one_to_one(ppi_ch2, timer.cc(0).event_compare(), Task::from_reg(&r.tasks_sample)); | 323 | let timer_cc = timer.cc(0); |
| 324 | |||
| 325 | let mut sample_ppi = Ppi::new_one_to_one(ppi_ch2, timer_cc.event_compare(), Task::from_reg(&r.tasks_sample)); | ||
| 324 | 326 | ||
| 325 | timer.start(); | 327 | timer.start(); |
| 326 | 328 | ||
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index dc3757856..04748238d 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -168,21 +168,21 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 168 | /// Returns the START task, for use with PPI. | 168 | /// Returns the START task, for use with PPI. |
| 169 | /// | 169 | /// |
| 170 | /// When triggered, this task starts the timer. | 170 | /// When triggered, this task starts the timer. |
| 171 | pub fn task_start(&self) -> Task { | 171 | pub fn task_start(&self) -> Task<'d> { |
| 172 | Task::from_reg(&T::regs().tasks_start) | 172 | Task::from_reg(&T::regs().tasks_start) |
| 173 | } | 173 | } |
| 174 | 174 | ||
| 175 | /// Returns the STOP task, for use with PPI. | 175 | /// Returns the STOP task, for use with PPI. |
| 176 | /// | 176 | /// |
| 177 | /// When triggered, this task stops the timer. | 177 | /// When triggered, this task stops the timer. |
| 178 | pub fn task_stop(&self) -> Task { | 178 | pub fn task_stop(&self) -> Task<'d> { |
| 179 | Task::from_reg(&T::regs().tasks_stop) | 179 | Task::from_reg(&T::regs().tasks_stop) |
| 180 | } | 180 | } |
| 181 | 181 | ||
| 182 | /// Returns the CLEAR task, for use with PPI. | 182 | /// Returns the CLEAR task, for use with PPI. |
| 183 | /// | 183 | /// |
| 184 | /// When triggered, this task resets the timer's counter to 0. | 184 | /// When triggered, this task resets the timer's counter to 0. |
| 185 | pub fn task_clear(&self) -> Task { | 185 | pub fn task_clear(&self) -> Task<'d> { |
| 186 | Task::from_reg(&T::regs().tasks_clear) | 186 | Task::from_reg(&T::regs().tasks_clear) |
| 187 | } | 187 | } |
| 188 | 188 | ||
| @@ -190,7 +190,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 190 | /// | 190 | /// |
| 191 | /// When triggered, this task increments the timer's counter by 1. | 191 | /// When triggered, this task increments the timer's counter by 1. |
| 192 | /// Only works in counter mode. | 192 | /// Only works in counter mode. |
| 193 | pub fn task_count(&self) -> Task { | 193 | pub fn task_count(&self) -> Task<'d> { |
| 194 | Task::from_reg(&T::regs().tasks_count) | 194 | Task::from_reg(&T::regs().tasks_count) |
| 195 | } | 195 | } |
| 196 | 196 | ||
| @@ -258,14 +258,14 @@ impl<'d, T: Instance> Cc<'d, T> { | |||
| 258 | /// Returns this CC register's CAPTURE task, for use with PPI. | 258 | /// Returns this CC register's CAPTURE task, for use with PPI. |
| 259 | /// | 259 | /// |
| 260 | /// When triggered, this task will capture the current value of the timer's counter in this register. | 260 | /// When triggered, this task will capture the current value of the timer's counter in this register. |
| 261 | pub fn task_capture(&self) -> Task { | 261 | pub fn task_capture(&self) -> Task<'d> { |
| 262 | Task::from_reg(&T::regs().tasks_capture) | 262 | Task::from_reg(&T::regs().tasks_capture) |
| 263 | } | 263 | } |
| 264 | 264 | ||
| 265 | /// Returns this CC register's COMPARE event, for use with PPI. | 265 | /// Returns this CC register's COMPARE event, for use with PPI. |
| 266 | /// | 266 | /// |
| 267 | /// This event will fire when the timer's counter reaches the value in this CC register. | 267 | /// This event will fire when the timer's counter reaches the value in this CC register. |
| 268 | pub fn event_compare(&self) -> Event { | 268 | pub fn event_compare(&self) -> Event<'d> { |
| 269 | Event::from_reg(&T::regs().events_compare[self.n]) | 269 | Event::from_reg(&T::regs().events_compare[self.n]) |
| 270 | } | 270 | } |
| 271 | 271 | ||
