rp/spi: disable+enable when setting frequency
This commit is contained in:
parent
dbff5cc232
commit
da33b3a4d2
1 changed files with 7 additions and 0 deletions
|
@ -142,10 +142,17 @@ impl<'d, T: Instance> Spi<'d, T> {
|
||||||
let (presc, postdiv) = calc_prescs(freq);
|
let (presc, postdiv) = calc_prescs(freq);
|
||||||
let p = self.inner.regs();
|
let p = self.inner.regs();
|
||||||
unsafe {
|
unsafe {
|
||||||
|
// disable
|
||||||
|
p.cr1().write(|w| w.set_sse(false));
|
||||||
|
|
||||||
|
// change stuff
|
||||||
p.cpsr().write(|w| w.set_cpsdvsr(presc));
|
p.cpsr().write(|w| w.set_cpsdvsr(presc));
|
||||||
p.cr0().modify(|w| {
|
p.cr0().modify(|w| {
|
||||||
w.set_scr(postdiv);
|
w.set_scr(postdiv);
|
||||||
});
|
});
|
||||||
|
|
||||||
|
// enable
|
||||||
|
p.cr1().write(|w| w.set_sse(true));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue