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