diff options
| author | Henrik Berg <[email protected]> | 2023-06-26 08:48:04 +0200 |
|---|---|---|
| committer | Henrik Berg <[email protected]> | 2023-07-12 14:22:48 +0200 |
| commit | 029b156563e70e00cf0ffdf9d5ec23964e5ecc77 (patch) | |
| tree | 23da0319e4c2b729d7b79d26b415e95ed9f98828 | |
| parent | 55a5e9b3a51b537b7de80221d501be423af43303 (diff) | |
RP: Add scratchN registers to watchdog. Add Clone and Debug to DateTime
| -rw-r--r-- | embassy-rp/src/rtc/datetime_no_deps.rs | 1 | ||||
| -rw-r--r-- | embassy-rp/src/watchdog.rs | 96 |
2 files changed, 97 insertions, 0 deletions
diff --git a/embassy-rp/src/rtc/datetime_no_deps.rs b/embassy-rp/src/rtc/datetime_no_deps.rs index 92770e984..ea899c339 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 { | |||
| 25 | } | 25 | } |
| 26 | 26 | ||
| 27 | /// Structure containing date and time information | 27 | /// Structure containing date and time information |
| 28 | #[derive(Clone, Debug)] | ||
| 28 | pub struct DateTime { | 29 | pub struct DateTime { |
| 29 | /// 0..4095 | 30 | /// 0..4095 |
| 30 | pub year: u16, | 31 | pub year: u16, |
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs index d37795cc9..7b36bb5a8 100644 --- a/embassy-rp/src/watchdog.rs +++ b/embassy-rp/src/watchdog.rs | |||
| @@ -107,4 +107,100 @@ impl Watchdog { | |||
| 107 | w.set_trigger(true); | 107 | w.set_trigger(true); |
| 108 | }) | 108 | }) |
| 109 | } | 109 | } |
| 110 | |||
| 111 | pub fn set_scratch0(&mut self, value: u32) { | ||
| 112 | let watchdog = pac::WATCHDOG; | ||
| 113 | watchdog.scratch0().write(|w| { | ||
| 114 | *w = value; | ||
| 115 | }) | ||
| 116 | } | ||
| 117 | |||
| 118 | pub fn get_scratch0(&mut self) -> u32 { | ||
| 119 | let watchdog = pac::WATCHDOG; | ||
| 120 | watchdog.scratch0().read() | ||
| 121 | } | ||
| 122 | |||
| 123 | pub fn set_scratch1(&mut self, value: u32) { | ||
| 124 | let watchdog = pac::WATCHDOG; | ||
| 125 | watchdog.scratch1().write(|w| { | ||
| 126 | *w = value; | ||
| 127 | }) | ||
| 128 | } | ||
| 129 | |||
| 130 | pub fn get_scratch1(&mut self) -> u32 { | ||
| 131 | let watchdog = pac::WATCHDOG; | ||
| 132 | watchdog.scratch1().read() | ||
| 133 | } | ||
| 134 | |||
| 135 | pub fn set_scratch2(&mut self, value: u32) { | ||
| 136 | let watchdog = pac::WATCHDOG; | ||
| 137 | watchdog.scratch2().write(|w| { | ||
| 138 | *w = value; | ||
| 139 | }) | ||
| 140 | } | ||
| 141 | |||
| 142 | pub fn get_scratch2(&mut self) -> u32 { | ||
| 143 | let watchdog = pac::WATCHDOG; | ||
| 144 | watchdog.scratch2().read() | ||
| 145 | } | ||
| 146 | |||
| 147 | pub fn set_scratch3(&mut self, value: u32) { | ||
| 148 | let watchdog = pac::WATCHDOG; | ||
| 149 | watchdog.scratch3().write(|w| { | ||
| 150 | *w = value; | ||
| 151 | }) | ||
| 152 | } | ||
| 153 | |||
| 154 | pub fn get_scratch3(&mut self) -> u32 { | ||
| 155 | let watchdog = pac::WATCHDOG; | ||
| 156 | watchdog.scratch3().read() | ||
| 157 | } | ||
| 158 | |||
| 159 | pub fn set_scratch4(&mut self, value: u32) { | ||
| 160 | let watchdog = pac::WATCHDOG; | ||
| 161 | watchdog.scratch4().write(|w| { | ||
| 162 | *w = value; | ||
| 163 | }) | ||
| 164 | } | ||
| 165 | |||
| 166 | pub fn get_scratch4(&mut self) -> u32 { | ||
| 167 | let watchdog = pac::WATCHDOG; | ||
| 168 | watchdog.scratch4().read() | ||
| 169 | } | ||
| 170 | |||
| 171 | pub fn set_scratch5(&mut self, value: u32) { | ||
| 172 | let watchdog = pac::WATCHDOG; | ||
| 173 | watchdog.scratch5().write(|w| { | ||
| 174 | *w = value; | ||
| 175 | }) | ||
| 176 | } | ||
| 177 | |||
| 178 | pub fn get_scratch5(&mut self) -> u32 { | ||
| 179 | let watchdog = pac::WATCHDOG; | ||
| 180 | watchdog.scratch5().read() | ||
| 181 | } | ||
| 182 | |||
| 183 | pub fn set_scratch6(&mut self, value: u32) { | ||
| 184 | let watchdog = pac::WATCHDOG; | ||
| 185 | watchdog.scratch6().write(|w| { | ||
| 186 | *w = value; | ||
| 187 | }) | ||
| 188 | } | ||
| 189 | |||
| 190 | pub fn get_scratch6(&mut self) -> u32 { | ||
| 191 | let watchdog = pac::WATCHDOG; | ||
| 192 | watchdog.scratch6().read() | ||
| 193 | } | ||
| 194 | |||
| 195 | pub fn set_scratch7(&mut self, value: u32) { | ||
| 196 | let watchdog = pac::WATCHDOG; | ||
| 197 | watchdog.scratch7().write(|w| { | ||
| 198 | *w = value; | ||
| 199 | }) | ||
| 200 | } | ||
| 201 | |||
| 202 | pub fn get_scratch7(&mut self) -> u32 { | ||
| 203 | let watchdog = pac::WATCHDOG; | ||
| 204 | watchdog.scratch7().read() | ||
| 205 | } | ||
| 110 | } | 206 | } |
