mirror of
https://github.com/embassy-rs/embassy.git
synced 2025-09-29 21:31:08 +00:00
Merge pull request #4696 from 0e4ef622/persist
nrf: add persist() for gpiote and timer
This commit is contained in:
commit
768182545a
@ -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: nrf54l: Disable glitch detection and enable DC/DC in init.
|
||||||
- changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4
|
- 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
|
## 0.7.0 - 2025-08-26
|
||||||
|
|
||||||
|
@ -193,6 +193,15 @@ pub struct InputChannel<'d> {
|
|||||||
pin: Input<'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> {
|
impl<'d> Drop for InputChannel<'d> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let g = regs();
|
let g = regs();
|
||||||
@ -263,6 +272,15 @@ pub struct OutputChannel<'d> {
|
|||||||
_pin: Output<'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> {
|
impl<'d> Drop for OutputChannel<'d> {
|
||||||
fn drop(&mut self) {
|
fn drop(&mut self) {
|
||||||
let g = regs();
|
let g = regs();
|
||||||
|
@ -104,7 +104,7 @@ impl<'d, T: Instance> Timer<'d, T> {
|
|||||||
Self::new_inner(timer, true)
|
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 regs = T::regs();
|
||||||
|
|
||||||
let this = Self { _p: timer };
|
let this = Self { _p: timer };
|
||||||
@ -114,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T> {
|
|||||||
this.stop();
|
this.stop();
|
||||||
|
|
||||||
regs.mode().write(|w| {
|
regs.mode().write(|w| {
|
||||||
w.set_mode(match _is_counter {
|
w.set_mode(match is_counter {
|
||||||
#[cfg(not(feature = "_nrf51"))]
|
#[cfg(not(feature = "_nrf51"))]
|
||||||
true => vals::Mode::LOW_POWER_COUNTER,
|
true => vals::Mode::LOW_POWER_COUNTER,
|
||||||
#[cfg(feature = "_nrf51")]
|
#[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 representation of a timer's Capture/Compare (CC) register.
|
||||||
///
|
///
|
||||||
/// A CC register holds a 32-bit value.
|
/// A CC register holds a 32-bit value.
|
||||||
|
Loading…
x
Reference in New Issue
Block a user