aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--embassy-nrf/src/wdt.rs19
1 files changed, 9 insertions, 10 deletions
diff --git a/embassy-nrf/src/wdt.rs b/embassy-nrf/src/wdt.rs
index 7ab9adc29..dc99a16f5 100644
--- a/embassy-nrf/src/wdt.rs
+++ b/embassy-nrf/src/wdt.rs
@@ -66,11 +66,11 @@ impl Default for Config {
66} 66}
67 67
68/// Watchdog driver. 68/// Watchdog driver.
69pub struct Watchdog<T: Instance> { 69pub struct Watchdog {
70 _wdt: Peri<'static, T>, 70 r: pac::wdt::Wdt,
71} 71}
72 72
73impl<T: Instance> Watchdog<T> { 73impl Watchdog {
74 /// Try to create a new watchdog driver. 74 /// Try to create a new watchdog driver.
75 /// 75 ///
76 /// This function will return an error if the watchdog is already active 76 /// This function will return an error if the watchdog is already active
@@ -79,7 +79,7 @@ impl<T: Instance> Watchdog<T> {
79 /// 79 ///
80 /// `N` must be between 1 and 8, inclusive. 80 /// `N` must be between 1 and 8, inclusive.
81 #[inline] 81 #[inline]
82 pub fn try_new<const N: usize>( 82 pub fn try_new<T: Instance, const N: usize>(
83 wdt: Peri<'static, T>, 83 wdt: Peri<'static, T>,
84 config: Config, 84 config: Config,
85 ) -> Result<(Self, [WatchdogHandle; N]), Peri<'static, T>> { 85 ) -> Result<(Self, [WatchdogHandle; N]), Peri<'static, T>> {
@@ -116,7 +116,7 @@ impl<T: Instance> Watchdog<T> {
116 r.tasks_start().write_value(1); 116 r.tasks_start().write_value(1);
117 } 117 }
118 118
119 let this = Self { _wdt: wdt }; 119 let this = Self { r: T::REGS };
120 120
121 let mut handles = [const { WatchdogHandle { index: 0 } }; N]; 121 let mut handles = [const { WatchdogHandle { index: 0 } }; N];
122 for i in 0..N { 122 for i in 0..N {
@@ -135,7 +135,7 @@ impl<T: Instance> Watchdog<T> {
135 /// interrupt has been enabled. 135 /// interrupt has been enabled.
136 #[inline(always)] 136 #[inline(always)]
137 pub fn enable_interrupt(&mut self) { 137 pub fn enable_interrupt(&mut self) {
138 T::REGS.intenset().write(|w| w.set_timeout(true)); 138 self.r.intenset().write(|w| w.set_timeout(true));
139 } 139 }
140 140
141 /// Disable the watchdog interrupt. 141 /// Disable the watchdog interrupt.
@@ -143,7 +143,7 @@ impl<T: Instance> Watchdog<T> {
143 /// NOTE: This has no effect on the reset caused by the Watchdog. 143 /// NOTE: This has no effect on the reset caused by the Watchdog.
144 #[inline(always)] 144 #[inline(always)]
145 pub fn disable_interrupt(&mut self) { 145 pub fn disable_interrupt(&mut self) {
146 T::REGS.intenclr().write(|w| w.set_timeout(true)); 146 self.r.intenclr().write(|w| w.set_timeout(true));
147 } 147 }
148 148
149 /// Is the watchdog still awaiting pets from any handle? 149 /// Is the watchdog still awaiting pets from any handle?
@@ -152,9 +152,8 @@ impl<T: Instance> Watchdog<T> {
152 /// handles to prevent a reset this time period. 152 /// handles to prevent a reset this time period.
153 #[inline(always)] 153 #[inline(always)]
154 pub fn awaiting_pets(&self) -> bool { 154 pub fn awaiting_pets(&self) -> bool {
155 let r = T::REGS; 155 let enabled = self.r.rren().read().0;
156 let enabled = r.rren().read().0; 156 let status = self.r.reqstatus().read().0;
157 let status = r.reqstatus().read().0;
158 (status & enabled) == 0 157 (status & enabled) == 0
159 } 158 }
160} 159}