nrf: twim: Use SetConfig trait to reduce code duplication

This commit is contained in:
Priit Laes 2023-09-06 16:48:22 +03:00 committed by Dario Nieuwenhuis
parent 93d4cfe7c1
commit 521970535e

View File

@ -167,9 +167,10 @@ impl<'d, T: Instance> Twim<'d, T> {
// Enable TWIM instance. // Enable TWIM instance.
r.enable.write(|w| w.enable().enabled()); r.enable.write(|w| w.enable().enabled());
// Configure frequency. let mut twim = Self { _p: twim };
r.frequency
.write(|w| unsafe { w.frequency().bits(config.frequency as u32) }); // Apply runtime peripheral configuration
Self::set_config(&mut twim, &config);
// Disable all events interrupts // Disable all events interrupts
r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) }); r.intenclr.write(|w| unsafe { w.bits(0xFFFF_FFFF) });
@ -177,7 +178,7 @@ impl<'d, T: Instance> Twim<'d, T> {
T::Interrupt::unpend(); T::Interrupt::unpend();
unsafe { T::Interrupt::enable() }; unsafe { T::Interrupt::enable() };
Self { _p: twim } twim
} }
/// Set TX buffer, checking that it is in RAM and has suitable length. /// Set TX buffer, checking that it is in RAM and has suitable length.