From e090ab19151fbea6736d5eac0e1497ef9c36626b Mon Sep 17 00:00:00 2001
From: kalkyl <henrik.alser@me.com>
Date: Sat, 24 Dec 2022 03:22:51 +0100
Subject: [PATCH] Remove lifetime, use pac fields

---
 embassy-rp/src/watchdog.rs      | 14 +++++++-------
 examples/rp/src/bin/watchdog.rs |  6 +++---
 2 files changed, 10 insertions(+), 10 deletions(-)

diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs
index 01509ff4e..f4f165b29 100644
--- a/embassy-rp/src/watchdog.rs
+++ b/embassy-rp/src/watchdog.rs
@@ -14,12 +14,12 @@ use crate::pac;
 use crate::peripherals::WATCHDOG;
 
 /// Watchdog peripheral
-pub struct Watchdog<'d> {
-    phantom: PhantomData<&'d WATCHDOG>,
+pub struct Watchdog {
+    phantom: PhantomData<WATCHDOG>,
     load_value: u32, // decremented by 2 per tick (µs)
 }
 
-impl<'d> Watchdog<'d> {
+impl Watchdog {
     /// Create a new `Watchdog`
     pub fn new(_watchdog: WATCHDOG) -> Self {
         Self {
@@ -35,12 +35,12 @@ impl<'d> Watchdog<'d> {
     /// * `cycles` - Total number of tick cycles before the next tick is generated.
     ///   It is expected to be the frequency in MHz of clk_ref.
     pub fn enable_tick_generation(&mut self, cycles: u8) {
-        const WATCHDOG_TICK_ENABLE_BITS: u32 = 0x200;
         unsafe {
             let watchdog = pac::WATCHDOG;
-            watchdog
-                .tick()
-                .write_value(pac::watchdog::regs::Tick(WATCHDOG_TICK_ENABLE_BITS | cycles as u32))
+            watchdog.tick().write(|w| {
+                w.set_enable(true);
+                w.set_cycles(cycles.into())
+            });
         }
     }
 
diff --git a/examples/rp/src/bin/watchdog.rs b/examples/rp/src/bin/watchdog.rs
index 13af22a2d..ece5cfe38 100644
--- a/examples/rp/src/bin/watchdog.rs
+++ b/examples/rp/src/bin/watchdog.rs
@@ -22,11 +22,11 @@ async fn main(_spawner: Spawner) {
     led.set_high();
     Timer::after(Duration::from_secs(2)).await;
 
-    // Set to watchdog to reset if it's not reloaded within 1.05 seconds, and start it
+    // Set to watchdog to reset if it's not fed within 1.05 seconds, and start it
     watchdog.start(Duration::from_millis(1_050));
     info!("Started the watchdog timer");
 
-    // Blink once a second for 5 seconds, refreshing the watchdog timer once a second to avoid a reset
+    // Blink once a second for 5 seconds, feed the watchdog timer once a second to avoid a reset
     for _ in 1..=5 {
         led.set_low();
         Timer::after(Duration::from_millis(500)).await;
@@ -38,7 +38,7 @@ async fn main(_spawner: Spawner) {
 
     info!("Stopped feeding, device will reset in 1.05 seconds");
     // Blink 10 times per second, not feeding the watchdog.
-    // The processor should reset in 1.05 seconds, or 5 blinks time
+    // The processor should reset in 1.05 seconds.
     loop {
         led.set_low();
         Timer::after(Duration::from_millis(100)).await;