diff options
| author | Ulf Lilleengen <[email protected]> | 2025-09-22 10:38:20 +0200 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-09-22 10:38:20 +0200 |
| commit | e9232bfad31c8a0c8567fa092a323f186bd99eb5 (patch) | |
| tree | 914952e6ff6d434380b574a8c9f6b44c8cee979f /embassy-nrf | |
| parent | d1b55faace4b5059c726d94dd2d7f1ad3805ab48 (diff) | |
| parent | 768182545aa600811c480a1ab298c590ce1093bc (diff) | |
Merge branch 'main' into add-nrf-rtc-driver
Diffstat (limited to 'embassy-nrf')
| -rw-r--r-- | embassy-nrf/CHANGELOG.md | 2 | ||||
| -rw-r--r-- | embassy-nrf/Cargo.toml | 2 | ||||
| -rw-r--r-- | embassy-nrf/src/gpiote.rs | 18 | ||||
| -rw-r--r-- | embassy-nrf/src/timer.rs | 19 |
4 files changed, 39 insertions, 2 deletions
diff --git a/embassy-nrf/CHANGELOG.md b/embassy-nrf/CHANGELOG.md index 7c783c2d4..0fedf9360 100644 --- a/embassy-nrf/CHANGELOG.md +++ b/embassy-nrf/CHANGELOG.md | |||
| @@ -12,6 +12,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 12 | - changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4 | 12 | - changed: Add embassy-net-driver-channel implementation for IEEE 802.15.4 |
| 13 | - changed: add persist() method for gpio and ppi | 13 | - changed: add persist() method for gpio and ppi |
| 14 | - added: basic RTC driver | 14 | - added: basic RTC driver |
| 15 | - changed: add persist() method for gpio, gpiote, timer and ppi | ||
| 16 | - changed: impl Drop for Timer | ||
| 15 | 17 | ||
| 16 | ## 0.7.0 - 2025-08-26 | 18 | ## 0.7.0 - 2025-08-26 |
| 17 | 19 | ||
diff --git a/embassy-nrf/Cargo.toml b/embassy-nrf/Cargo.toml index 4afd28fbd..1af633500 100644 --- a/embassy-nrf/Cargo.toml +++ b/embassy-nrf/Cargo.toml | |||
| @@ -66,6 +66,8 @@ time = ["dep:embassy-time", "embassy-embedded-hal/time"] | |||
| 66 | 66 | ||
| 67 | ## Enable defmt | 67 | ## Enable defmt |
| 68 | defmt = ["dep:defmt", "embassy-hal-internal/defmt", "embassy-sync/defmt", "embassy-usb-driver/defmt", "embassy-embedded-hal/defmt"] | 68 | defmt = ["dep:defmt", "embassy-hal-internal/defmt", "embassy-sync/defmt", "embassy-usb-driver/defmt", "embassy-embedded-hal/defmt"] |
| 69 | ## Enable log | ||
| 70 | log = ["dep:log"] | ||
| 69 | 71 | ||
| 70 | ## Reexport the PAC for the currently enabled chip at `embassy_nrf::pac` (unstable) | 72 | ## Reexport the PAC for the currently enabled chip at `embassy_nrf::pac` (unstable) |
| 71 | unstable-pac = [] | 73 | unstable-pac = [] |
diff --git a/embassy-nrf/src/gpiote.rs b/embassy-nrf/src/gpiote.rs index d169b49f9..43e43f0bf 100644 --- a/embassy-nrf/src/gpiote.rs +++ b/embassy-nrf/src/gpiote.rs | |||
| @@ -193,6 +193,15 @@ pub struct InputChannel<'d> { | |||
| 193 | pin: Input<'d>, | 193 | pin: Input<'d>, |
| 194 | } | 194 | } |
| 195 | 195 | ||
| 196 | impl InputChannel<'static> { | ||
| 197 | /// Persist the channel's configuration for the rest of the program's lifetime. This method | ||
| 198 | /// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents | ||
| 199 | /// accidental reuse of the underlying peripheral. | ||
| 200 | pub fn persist(self) { | ||
| 201 | core::mem::forget(self); | ||
| 202 | } | ||
| 203 | } | ||
| 204 | |||
| 196 | impl<'d> Drop for InputChannel<'d> { | 205 | impl<'d> Drop for InputChannel<'d> { |
| 197 | fn drop(&mut self) { | 206 | fn drop(&mut self) { |
| 198 | let g = regs(); | 207 | let g = regs(); |
| @@ -263,6 +272,15 @@ pub struct OutputChannel<'d> { | |||
| 263 | _pin: Output<'d>, | 272 | _pin: Output<'d>, |
| 264 | } | 273 | } |
| 265 | 274 | ||
| 275 | impl OutputChannel<'static> { | ||
| 276 | /// Persist the channel's configuration for the rest of the program's lifetime. This method | ||
| 277 | /// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents | ||
| 278 | /// accidental reuse of the underlying peripheral. | ||
| 279 | pub fn persist(self) { | ||
| 280 | core::mem::forget(self); | ||
| 281 | } | ||
| 282 | } | ||
| 283 | |||
| 266 | impl<'d> Drop for OutputChannel<'d> { | 284 | impl<'d> Drop for OutputChannel<'d> { |
| 267 | fn drop(&mut self) { | 285 | fn drop(&mut self) { |
| 268 | let g = regs(); | 286 | let g = regs(); |
diff --git a/embassy-nrf/src/timer.rs b/embassy-nrf/src/timer.rs index de2875765..5d6afe49b 100644 --- a/embassy-nrf/src/timer.rs +++ b/embassy-nrf/src/timer.rs | |||
| @@ -104,7 +104,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 104 | Self::new_inner(timer, true) | 104 | Self::new_inner(timer, true) |
| 105 | } | 105 | } |
| 106 | 106 | ||
| 107 | fn new_inner(timer: Peri<'d, T>, _is_counter: bool) -> Self { | 107 | fn new_inner(timer: Peri<'d, T>, is_counter: bool) -> Self { |
| 108 | let regs = T::regs(); | 108 | let regs = T::regs(); |
| 109 | 109 | ||
| 110 | let this = Self { _p: timer }; | 110 | let this = Self { _p: timer }; |
| @@ -114,7 +114,7 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 114 | this.stop(); | 114 | this.stop(); |
| 115 | 115 | ||
| 116 | regs.mode().write(|w| { | 116 | regs.mode().write(|w| { |
| 117 | w.set_mode(match _is_counter { | 117 | w.set_mode(match is_counter { |
| 118 | #[cfg(not(feature = "_nrf51"))] | 118 | #[cfg(not(feature = "_nrf51"))] |
| 119 | true => vals::Mode::LOW_POWER_COUNTER, | 119 | true => vals::Mode::LOW_POWER_COUNTER, |
| 120 | #[cfg(feature = "_nrf51")] | 120 | #[cfg(feature = "_nrf51")] |
| @@ -218,6 +218,21 @@ impl<'d, T: Instance> Timer<'d, T> { | |||
| 218 | } | 218 | } |
| 219 | } | 219 | } |
| 220 | 220 | ||
| 221 | impl<T: Instance> Timer<'static, T> { | ||
| 222 | /// Persist the timer's configuration for the rest of the program's lifetime. This method | ||
| 223 | /// should be preferred over [`core::mem::forget()`] because the `'static` bound prevents | ||
| 224 | /// accidental reuse of the underlying peripheral. | ||
| 225 | pub fn persist(self) { | ||
| 226 | core::mem::forget(self); | ||
| 227 | } | ||
| 228 | } | ||
| 229 | |||
| 230 | impl<'d, T: Instance> Drop for Timer<'d, T> { | ||
| 231 | fn drop(&mut self) { | ||
| 232 | self.stop(); | ||
| 233 | } | ||
| 234 | } | ||
| 235 | |||
| 221 | /// A representation of a timer's Capture/Compare (CC) register. | 236 | /// A representation of a timer's Capture/Compare (CC) register. |
| 222 | /// | 237 | /// |
| 223 | /// A CC register holds a 32-bit value. | 238 | /// A CC register holds a 32-bit value. |
