Derive SPI v1 and v3 clocks automatically

This commit is contained in:
Ulf Lilleengen 2021-06-14 11:58:16 +02:00
parent 5e1b0a5398
commit 531093f281
2 changed files with 2 additions and 2 deletions

View File

@ -29,7 +29,6 @@ pub struct Spi<'d, T: Instance> {
impl<'d, T: Instance> Spi<'d, T> { impl<'d, T: Instance> Spi<'d, T> {
pub fn new<F>( pub fn new<F>(
pclk: Hertz,
_peri: impl Unborrow<Target = T> + 'd, _peri: impl Unborrow<Target = T> + 'd,
sck: impl Unborrow<Target = impl SckPin<T>>, sck: impl Unborrow<Target = impl SckPin<T>>,
mosi: impl Unborrow<Target = impl MosiPin<T>>, mosi: impl Unborrow<Target = impl MosiPin<T>>,
@ -58,6 +57,7 @@ impl<'d, T: Instance> Spi<'d, T> {
}); });
} }
let pclk = T::frequency();
let br = Self::compute_baud_rate(pclk, freq.into()); let br = Self::compute_baud_rate(pclk, freq.into());
unsafe { unsafe {

View File

@ -37,7 +37,6 @@ pub struct Spi<'d, T: Instance> {
impl<'d, T: Instance> Spi<'d, T> { impl<'d, T: Instance> Spi<'d, T> {
pub fn new<F>( pub fn new<F>(
pclk: Hertz,
_peri: impl Unborrow<Target = T> + 'd, _peri: impl Unborrow<Target = T> + 'd,
sck: impl Unborrow<Target = impl SckPin<T>>, sck: impl Unborrow<Target = impl SckPin<T>>,
mosi: impl Unborrow<Target = impl MosiPin<T>>, mosi: impl Unborrow<Target = impl MosiPin<T>>,
@ -62,6 +61,7 @@ impl<'d, T: Instance> Spi<'d, T> {
let mosi = mosi.degrade(); let mosi = mosi.degrade();
let miso = miso.degrade(); let miso = miso.degrade();
let pclk = T::frequency();
let br = Self::compute_baud_rate(pclk, freq.into()); let br = Self::compute_baud_rate(pclk, freq.into());
unsafe { unsafe {
T::enable(); T::enable();