diff options
| author | Ulf Lilleengen <[email protected]> | 2021-06-14 11:58:16 +0200 |
|---|---|---|
| committer | Ulf Lilleengen <[email protected]> | 2021-06-14 11:58:16 +0200 |
| commit | 531093f28189573818d5ebcfd4ccf56389d3972f (patch) | |
| tree | 833f4531578d64e276765bcd23e3f8c6663c2602 | |
| parent | 5e1b0a539876f498ac11cb2d4c42424a499d7087 (diff) | |
Derive SPI v1 and v3 clocks automatically
| -rw-r--r-- | embassy-stm32/src/spi/v1.rs | 2 | ||||
| -rw-r--r-- | embassy-stm32/src/spi/v3.rs | 2 |
2 files changed, 2 insertions, 2 deletions
diff --git a/embassy-stm32/src/spi/v1.rs b/embassy-stm32/src/spi/v1.rs index 227a36a89..01cbf86b6 100644 --- a/embassy-stm32/src/spi/v1.rs +++ b/embassy-stm32/src/spi/v1.rs | |||
| @@ -29,7 +29,6 @@ pub struct Spi<'d, T: Instance> { | |||
| 29 | 29 | ||
| 30 | impl<'d, T: Instance> Spi<'d, T> { | 30 | impl<'d, T: Instance> Spi<'d, T> { |
| 31 | pub fn new<F>( | 31 | pub fn new<F>( |
| 32 | pclk: Hertz, | ||
| 33 | _peri: impl Unborrow<Target = T> + 'd, | 32 | _peri: impl Unborrow<Target = T> + 'd, |
| 34 | sck: impl Unborrow<Target = impl SckPin<T>>, | 33 | sck: impl Unborrow<Target = impl SckPin<T>>, |
| 35 | mosi: impl Unborrow<Target = impl MosiPin<T>>, | 34 | mosi: impl Unborrow<Target = impl MosiPin<T>>, |
| @@ -58,6 +57,7 @@ impl<'d, T: Instance> Spi<'d, T> { | |||
| 58 | }); | 57 | }); |
| 59 | } | 58 | } |
| 60 | 59 | ||
| 60 | let pclk = T::frequency(); | ||
| 61 | let br = Self::compute_baud_rate(pclk, freq.into()); | 61 | let br = Self::compute_baud_rate(pclk, freq.into()); |
| 62 | 62 | ||
| 63 | unsafe { | 63 | unsafe { |
diff --git a/embassy-stm32/src/spi/v3.rs b/embassy-stm32/src/spi/v3.rs index 6073616bd..0b4a71457 100644 --- a/embassy-stm32/src/spi/v3.rs +++ b/embassy-stm32/src/spi/v3.rs | |||
| @@ -37,7 +37,6 @@ pub struct Spi<'d, T: Instance> { | |||
| 37 | 37 | ||
| 38 | impl<'d, T: Instance> Spi<'d, T> { | 38 | impl<'d, T: Instance> Spi<'d, T> { |
| 39 | pub fn new<F>( | 39 | pub fn new<F>( |
| 40 | pclk: Hertz, | ||
| 41 | _peri: impl Unborrow<Target = T> + 'd, | 40 | _peri: impl Unborrow<Target = T> + 'd, |
| 42 | sck: impl Unborrow<Target = impl SckPin<T>>, | 41 | sck: impl Unborrow<Target = impl SckPin<T>>, |
| 43 | mosi: impl Unborrow<Target = impl MosiPin<T>>, | 42 | mosi: impl Unborrow<Target = impl MosiPin<T>>, |
| @@ -62,6 +61,7 @@ impl<'d, T: Instance> Spi<'d, T> { | |||
| 62 | let mosi = mosi.degrade(); | 61 | let mosi = mosi.degrade(); |
| 63 | let miso = miso.degrade(); | 62 | let miso = miso.degrade(); |
| 64 | 63 | ||
| 64 | let pclk = T::frequency(); | ||
| 65 | let br = Self::compute_baud_rate(pclk, freq.into()); | 65 | let br = Self::compute_baud_rate(pclk, freq.into()); |
| 66 | unsafe { | 66 | unsafe { |
| 67 | T::enable(); | 67 | T::enable(); |
