Merge #850
850: Shared buses with SetConfig r=Dirbaio a=kalkyl Addresses issue #830 Co-authored-by: Henrik Alsér <henrik@mindbite.se>
This commit is contained in:
@ -1,5 +1,6 @@
|
||||
use core::marker::PhantomData;
|
||||
|
||||
use embassy_embedded_hal::SetConfig;
|
||||
use embassy_hal_common::unborrow;
|
||||
pub use embedded_hal_02::spi::{Phase, Polarity};
|
||||
|
||||
@ -350,3 +351,20 @@ mod eh1 {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<'d, T: Instance> SetConfig for Spi<'d, T> {
|
||||
type Config = Config;
|
||||
fn set_config(&mut self, config: &Self::Config) {
|
||||
let p = self.inner.regs();
|
||||
let (presc, postdiv) = calc_prescs(config.frequency);
|
||||
unsafe {
|
||||
p.cpsr().write(|w| w.set_cpsdvsr(presc));
|
||||
p.cr0().write(|w| {
|
||||
w.set_dss(0b0111); // 8bit
|
||||
w.set_spo(config.polarity == Polarity::IdleHigh);
|
||||
w.set_sph(config.phase == Phase::CaptureOnSecondTransition);
|
||||
w.set_scr(postdiv);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user