mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-27 04:10:25 +00:00
nrf: add persist() method for gpio and ppi
This commit is contained in:
parent
8394e13208
commit
6e1d6be315
@ -10,6 +10,7 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0
|
||||
|
||||
- changed: nrf54l: Disable glitch detection and enable DC/DC in init.
|
||||
- changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4
|
||||
- changed: add persist() method for gpio and ppi
|
||||
|
||||
## 0.7.0 - 2025-08-26
|
||||
|
||||
|
@ -75,6 +75,15 @@ impl<'d> Input<'d> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Input<'static> {
|
||||
/// Persist the pin's configuration for the rest of the program's lifetime. This method should
|
||||
/// be preferred over [`core::mem::forget()`] because the `'static` bound prevents accidental
|
||||
/// reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
self.pin.persist()
|
||||
}
|
||||
}
|
||||
|
||||
/// Digital input or output level.
|
||||
#[derive(Clone, Copy, Debug, Eq, PartialEq)]
|
||||
#[cfg_attr(feature = "defmt", derive(defmt::Format))]
|
||||
@ -264,6 +273,15 @@ impl<'d> Output<'d> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Output<'static> {
|
||||
/// Persist the pin's configuration for the rest of the program's lifetime. This method should
|
||||
/// be preferred over [`core::mem::forget()`] because the `'static` bound prevents accidental
|
||||
/// reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
self.pin.persist()
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn convert_drive(w: &mut pac::gpio::regs::PinCnf, drive: OutputDrive) {
|
||||
#[cfg(not(feature = "_nrf54l"))]
|
||||
{
|
||||
@ -447,6 +465,15 @@ impl<'d> Flex<'d> {
|
||||
}
|
||||
}
|
||||
|
||||
impl Flex<'static> {
|
||||
/// Persist the pin's configuration for the rest of the program's lifetime. This method should
|
||||
/// be preferred over [`core::mem::forget()`] because the `'static` bound prevents accidental
|
||||
/// reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
core::mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d> Drop for Flex<'d> {
|
||||
fn drop(&mut self) {
|
||||
self.set_as_disconnected();
|
||||
|
@ -59,6 +59,15 @@ impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'d,
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'static, C, EVENT_COUNT, TASK_COUNT> {
|
||||
/// Persist the channel's configuration for the rest of the program's lifetime. This method
|
||||
/// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents
|
||||
/// accidental reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
core::mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop for Ppi<'d, C, EVENT_COUNT, TASK_COUNT> {
|
||||
fn drop(&mut self) {
|
||||
self.disable();
|
||||
|
@ -108,6 +108,14 @@ impl<'d, G: Group> PpiGroup<'d, G> {
|
||||
Task::from_reg(regs().tasks_chg(n).dis())
|
||||
}
|
||||
}
|
||||
impl<G: Group> PpiGroup<'static, G> {
|
||||
/// Persist this group's configuration for the rest of the program's lifetime. This method
|
||||
/// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents
|
||||
/// accidental reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
core::mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, G: Group> Drop for PpiGroup<'d, G> {
|
||||
fn drop(&mut self) {
|
||||
|
@ -68,6 +68,15 @@ impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'d,
|
||||
}
|
||||
}
|
||||
|
||||
impl<C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Ppi<'static, C, EVENT_COUNT, TASK_COUNT> {
|
||||
/// Persist the channel's configuration for the rest of the program's lifetime. This method
|
||||
/// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents
|
||||
/// accidental reuse of the underlying peripheral.
|
||||
pub fn persist(self) {
|
||||
core::mem::forget(self);
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, C: Channel, const EVENT_COUNT: usize, const TASK_COUNT: usize> Drop for Ppi<'d, C, EVENT_COUNT, TASK_COUNT> {
|
||||
fn drop(&mut self) {
|
||||
self.disable();
|
||||
|
@ -90,7 +90,7 @@ pub struct Timer<'d, T: Instance> {
|
||||
impl<'d, T: Instance> Timer<'d, T> {
|
||||
/// Create a new `Timer` driver.
|
||||
///
|
||||
/// This can be useful for triggering tasks via PPI
|
||||
/// This can be useful for triggering tasks via PPI.
|
||||
/// `Uarte` uses this internally.
|
||||
pub fn new(timer: Peri<'d, T>) -> Self {
|
||||
Self::new_inner(timer, false)
|
||||
@ -98,7 +98,7 @@ impl<'d, T: Instance> Timer<'d, T> {
|
||||
|
||||
/// Create a new `Timer` driver in counter mode.
|
||||
///
|
||||
/// This can be useful for triggering tasks via PPI
|
||||
/// This can be useful for triggering tasks via PPI.
|
||||
/// `Uarte` uses this internally.
|
||||
pub fn new_counter(timer: Peri<'d, T>) -> Self {
|
||||
Self::new_inner(timer, true)
|
||||
|
Loading…
x
Reference in New Issue
Block a user