diff options
| author | Bob McWhirter <[email protected]> | 2021-07-02 13:54:07 -0400 |
|---|---|---|
| committer | Bob McWhirter <[email protected]> | 2021-07-02 13:54:07 -0400 |
| commit | f5ce807e2579d2492f22fdd14f9dc5c582015862 (patch) | |
| tree | a54ac851b95128b5797cb4ca36ba684544cc2701 | |
| parent | d8687b16929abf58fcfe7047b0091b685e12c106 (diff) | |
Let's adjust i2c the correct way, removing the correct APBesque frequency, not the i2c periph speed.
| -rw-r--r-- | embassy-stm32/src/i2c/v1.rs | 4 | ||||
| -rw-r--r-- | embassy-stm32/src/i2c/v2.rs | 4 |
2 files changed, 4 insertions, 4 deletions
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs index 62435e8a3..8573f01f4 100644 --- a/embassy-stm32/src/i2c/v1.rs +++ b/embassy-stm32/src/i2c/v1.rs | |||
| @@ -18,10 +18,10 @@ pub struct I2c<'d, T: Instance> { | |||
| 18 | 18 | ||
| 19 | impl<'d, T: Instance> I2c<'d, T> { | 19 | impl<'d, T: Instance> I2c<'d, T> { |
| 20 | pub fn new<F>( | 20 | pub fn new<F>( |
| 21 | pclk: Hertz, | ||
| 22 | _peri: impl Unborrow<Target = T> + 'd, | 21 | _peri: impl Unborrow<Target = T> + 'd, |
| 23 | scl: impl Unborrow<Target = impl SclPin<T>>, | 22 | scl: impl Unborrow<Target = impl SclPin<T>>, |
| 24 | sda: impl Unborrow<Target = impl SdaPin<T>>, | 23 | sda: impl Unborrow<Target = impl SdaPin<T>>, |
| 24 | freq: F, | ||
| 25 | ) -> Self | 25 | ) -> Self |
| 26 | where | 26 | where |
| 27 | F: Into<Hertz>, | 27 | F: Into<Hertz>, |
| @@ -42,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 42 | }); | 42 | }); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | let timings = Timings::new(pclk, T::frequency().into()); | 45 | let timings = Timings::new(T::frequency(), freq.into()); |
| 46 | 46 | ||
| 47 | unsafe { | 47 | unsafe { |
| 48 | T::regs().cr2().modify(|reg| { | 48 | T::regs().cr2().modify(|reg| { |
diff --git a/embassy-stm32/src/i2c/v2.rs b/embassy-stm32/src/i2c/v2.rs index 7747857b0..2f70d4263 100644 --- a/embassy-stm32/src/i2c/v2.rs +++ b/embassy-stm32/src/i2c/v2.rs | |||
| @@ -18,10 +18,10 @@ pub struct I2c<'d, T: Instance> { | |||
| 18 | 18 | ||
| 19 | impl<'d, T: Instance> I2c<'d, T> { | 19 | impl<'d, T: Instance> I2c<'d, T> { |
| 20 | pub fn new<F>( | 20 | pub fn new<F>( |
| 21 | pclk: Hertz, | ||
| 22 | _peri: impl Unborrow<Target = T> + 'd, | 21 | _peri: impl Unborrow<Target = T> + 'd, |
| 23 | scl: impl Unborrow<Target = impl SclPin<T>>, | 22 | scl: impl Unborrow<Target = impl SclPin<T>>, |
| 24 | sda: impl Unborrow<Target = impl SdaPin<T>>, | 23 | sda: impl Unborrow<Target = impl SdaPin<T>>, |
| 24 | freq: F, | ||
| 25 | ) -> Self | 25 | ) -> Self |
| 26 | where | 26 | where |
| 27 | F: Into<Hertz>, | 27 | F: Into<Hertz>, |
| @@ -42,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> { | |||
| 42 | }); | 42 | }); |
| 43 | } | 43 | } |
| 44 | 44 | ||
| 45 | let timings = Timings::new(pclk, T::frequency().into()); | 45 | let timings = Timings::new(T::frequency(), freq.into()); |
| 46 | 46 | ||
| 47 | unsafe { | 47 | unsafe { |
| 48 | T::regs().timingr().write(|reg| { | 48 | T::regs().timingr().write(|reg| { |
