Merge pull request #4696 from 0e4ef622/persist

nrf: add persist() for gpiote and timer
This commit is contained in:
Ulf Lilleengen 2025-09-22 08:33:00 +00:00 committed by GitHub
commit 768182545a
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 37 additions and 3 deletions

View File

@ -10,7 +10,8 @@ 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
- changed: add persist() method for gpio, gpiote, timer and ppi
- changed: impl Drop for Timer
## 0.7.0 - 2025-08-26

View File

@ -193,6 +193,15 @@ pub struct InputChannel<'d> {
pin: Input<'d>,
}
impl InputChannel<'static> {
/// 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> Drop for InputChannel<'d> {
fn drop(&mut self) {
let g = regs();
@ -263,6 +272,15 @@ pub struct OutputChannel<'d> {
_pin: Output<'d>,
}
impl OutputChannel<'static> {
/// 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> Drop for OutputChannel<'d> {
fn drop(&mut self) {
let g = regs();

View File

@ -104,7 +104,7 @@ impl<'d, T: Instance> Timer<'d, T> {
Self::new_inner(timer, true)
}
fn new_inner(timer: Peri<'d, T>, _is_counter: bool) -> Self {
fn new_inner(timer: Peri<'d, T>, is_counter: bool) -> Self {
let regs = T::regs();
let this = Self { _p: timer };
@ -114,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T> {
this.stop();
regs.mode().write(|w| {
w.set_mode(match _is_counter {
w.set_mode(match is_counter {
#[cfg(not(feature = "_nrf51"))]
true => vals::Mode::LOW_POWER_COUNTER,
#[cfg(feature = "_nrf51")]
@ -218,6 +218,21 @@ impl<'d, T: Instance> Timer<'d, T> {
}
}
impl<T: Instance> Timer<'static, T> {
/// Persist the timer'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, T: Instance> Drop for Timer<'d, T> {
fn drop(&mut self) {
self.stop();
}
}
/// A representation of a timer's Capture/Compare (CC) register.
///
/// A CC register holds a 32-bit value.