aboutsummaryrefslogtreecommitdiff
path: root/embassy-rp
diff options
context:
space:
mode:
authorHenrik Berg <[email protected]>2023-07-12 16:41:35 +0200
committerHenrik Berg <[email protected]>2023-07-12 16:41:35 +0200
commitff2daaff679ab79c856164d19b1bd15c7526991f (patch)
treeeb477f8cc66f741f2ab3bd8332a783a91bfd91cc /embassy-rp
parent6d402fe3932ac04ff939379e6520322476f683dc (diff)
RP: Watchdog scratch set/get with index: usize.
Diffstat (limited to 'embassy-rp')
-rw-r--r--embassy-rp/src/watchdog.rs118
1 files changed, 27 insertions, 91 deletions
diff --git a/embassy-rp/src/watchdog.rs b/embassy-rp/src/watchdog.rs
index 7b36bb5a8..f1e986ec7 100644
--- a/embassy-rp/src/watchdog.rs
+++ b/embassy-rp/src/watchdog.rs
@@ -108,99 +108,35 @@ impl Watchdog {
108 }) 108 })
109 } 109 }
110 110
111 pub fn set_scratch0(&mut self, value: u32) { 111 /// Store data in scratch register
112 let watchdog = pac::WATCHDOG; 112 pub fn set_scratch(&mut self, index: usize, value: u32) {
113 watchdog.scratch0().write(|w| { 113 let watchdog = pac::WATCHDOG;
114 *w = value; 114 match index {
115 }) 115 0 => watchdog.scratch0().write(|w| *w = value),
116 } 116 1 => watchdog.scratch1().write(|w| *w = value),
117 117 2 => watchdog.scratch2().write(|w| *w = value),
118 pub fn get_scratch0(&mut self) -> u32 { 118 3 => watchdog.scratch3().write(|w| *w = value),
119 let watchdog = pac::WATCHDOG; 119 4 => watchdog.scratch4().write(|w| *w = value),
120 watchdog.scratch0().read() 120 5 => watchdog.scratch5().write(|w| *w = value),
121 } 121 6 => watchdog.scratch6().write(|w| *w = value),
122 122 7 => watchdog.scratch7().write(|w| *w = value),
123 pub fn set_scratch1(&mut self, value: u32) { 123 _ => panic!("Invalid watchdog scratch index"),
124 let watchdog = pac::WATCHDOG; 124 }
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 } 125 }
201 126
202 pub fn get_scratch7(&mut self) -> u32 { 127 /// Read data from scratch register
128 pub fn get_scratch(&mut self, index: usize) -> u32 {
203 let watchdog = pac::WATCHDOG; 129 let watchdog = pac::WATCHDOG;
204 watchdog.scratch7().read() 130 match index {
131 0 => watchdog.scratch0().read(),
132 1 => watchdog.scratch1().read(),
133 2 => watchdog.scratch2().read(),
134 3 => watchdog.scratch3().read(),
135 4 => watchdog.scratch4().read(),
136 5 => watchdog.scratch5().read(),
137 6 => watchdog.scratch6().read(),
138 7 => watchdog.scratch7().read(),
139 _ => panic!("Invalid watchdog scratch index"),
140 }
205 } 141 }
206} 142}