From 029b156563e70e00cf0ffdf9d5ec23964e5ecc77 Mon Sep 17 00:00:00 2001 From: Henrik Berg Date: Mon, 26 Jun 2023 08:48:04 +0200 Subject: [PATCH] RP: Add scratchN registers to watchdog. Add Clone and Debug to DateTime --- embassy-rp/src/rtc/datetime_no_deps.rs | 1 + embassy-rp/src/watchdog.rs | 96 ++++++++++++++++++++++++++ 2 files changed, 97 insertions(+) diff --git a/embassy-rp/src/rtc/datetime_no_deps.rs b/embassy-rp/src/rtc/datetime_no_deps.rs index 92770e98..ea899c33 100644 --- a/embassy-rp/src/rtc/datetime_no_deps.rs +++ b/embassy-rp/src/rtc/datetime_no_deps.rs @@ -25,6 +25,7 @@ pub enum Error { } /// Structure containing date and time information +#[derive(Clone, Debug)] pub struct DateTime { /// 0..4095 pub year: u16, diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs index d37795cc..7b36bb5a 100644 --- a/embassy-rp/src/watchdog.rs +++ b/embassy-rp/src/watchdog.rs @@ -107,4 +107,100 @@ impl Watchdog { w.set_trigger(true); }) } + + pub fn set_scratch0(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch0().write(|w| { + *w = value; + }) + } + + pub fn get_scratch0(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch0().read() + } + + pub fn set_scratch1(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch1().write(|w| { + *w = value; + }) + } + + pub fn get_scratch1(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch1().read() + } + + pub fn set_scratch2(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch2().write(|w| { + *w = value; + }) + } + + pub fn get_scratch2(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch2().read() + } + + pub fn set_scratch3(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch3().write(|w| { + *w = value; + }) + } + + pub fn get_scratch3(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch3().read() + } + + pub fn set_scratch4(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch4().write(|w| { + *w = value; + }) + } + + pub fn get_scratch4(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch4().read() + } + + pub fn set_scratch5(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch5().write(|w| { + *w = value; + }) + } + + pub fn get_scratch5(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch5().read() + } + + pub fn set_scratch6(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch6().write(|w| { + *w = value; + }) + } + + pub fn get_scratch6(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch6().read() + } + + pub fn set_scratch7(&mut self, value: u32) { + let watchdog = pac::WATCHDOG; + watchdog.scratch7().write(|w| { + *w = value; + }) + } + + pub fn get_scratch7(&mut self) -> u32 { + let watchdog = pac::WATCHDOG; + watchdog.scratch7().read() + } }