aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorPriit Laes <[email protected]>2023-09-06 16:48:22 +0300
committerDario Nieuwenhuis <[email protected]>2023-09-10 23:17:30 +0200
commit521970535e119f7535d6d4d4760e1d76b2231753 (patch)
tree1c3e8b14d1b6f0616be7cdcda3772b080c318794
parent93d4cfe7c10cfacc8ac88dd75a88d76e71476db0 (diff)
nrf: twim: Use SetConfig trait to reduce code duplication
-rw-r--r--embassy-nrf/src/twim.rs9
1 files changed, 5 insertions, 4 deletions
diff --git a/embassy-nrf/src/twim.rs b/embassy-nrf/src/twim.rs
index fdea480e3..fe38fb102 100644
--- a/embassy-nrf/src/twim.rs
+++ b/embassy-nrf/src/twim.rs
@@ -167,9 +167,10 @@ impl<'d, T: Instance> Twim<'d, T> {
167 // Enable TWIM instance. 167 // Enable TWIM instance.
168 r.enable.write(|w| w.enable().enabled()); 168 r.enable.write(|w| w.enable().enabled());
169 169
170 // Configure frequency. 170 let mut twim = Self { _p: twim };
171 r.frequency 171
172 .write(|w| unsafe { w.frequency().bits(config.frequency as u32) }); 172 // Apply runtime peripheral configuration
173 Self::set_config(&mut twim, &config);
173 174
174 // Disable all events interrupts 175 // Disable all events interrupts
175 r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); 176 r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
@@ -177,7 +178,7 @@ impl<'d, T: Instance> Twim<'d, T> {
177 T::Interrupt::unpend(); 178 T::Interrupt::unpend();
178 unsafe { T::Interrupt::enable() }; 179 unsafe { T::Interrupt::enable() };
179 180
180 Self { _p: twim } 181 twim
181 } 182 }
182 183
183 /// Set TX buffer, checking that it is in RAM and has suitable length. 184 /// Set TX buffer, checking that it is in RAM and has suitable length.