aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorBob McWhirter <[email protected]>2021-07-01 13:53:57 -0400
committerBob McWhirter <[email protected]>2021-07-01 13:53:57 -0400
commit9f5d35d891c887a7a359fbe04ad91dd46e9883f8 (patch)
tree67518fd354cbc78954e9e460c30e1bf1132ddcdd
parente7a4a72977c068682748e85ea522dc66c7cf6146 (diff)
Remove the frequency argument for i2c, move to using RccPeripheral.
-rw-r--r--embassy-stm32/src/i2c/mod.rs3
-rw-r--r--embassy-stm32/src/i2c/v1.rs5
-rw-r--r--embassy-stm32/src/i2c/v2.rs5
m---------stm32-data0
4 files changed, 8 insertions, 5 deletions
diff --git a/embassy-stm32/src/i2c/mod.rs b/embassy-stm32/src/i2c/mod.rs
index c108a0a87..d2da8c310 100644
--- a/embassy-stm32/src/i2c/mod.rs
+++ b/embassy-stm32/src/i2c/mod.rs
@@ -17,8 +17,9 @@ pub enum Error {
17 17
18pub(crate) mod sealed { 18pub(crate) mod sealed {
19 use crate::gpio::Pin; 19 use crate::gpio::Pin;
20 use crate::rcc::RccPeripheral;
20 21
21 pub trait Instance { 22 pub trait Instance: RccPeripheral {
22 fn regs() -> &'static crate::pac::i2c::I2c; 23 fn regs() -> &'static crate::pac::i2c::I2c;
23 } 24 }
24 25
diff --git a/embassy-stm32/src/i2c/v1.rs b/embassy-stm32/src/i2c/v1.rs
index 91bc37db3..62435e8a3 100644
--- a/embassy-stm32/src/i2c/v1.rs
+++ b/embassy-stm32/src/i2c/v1.rs
@@ -22,13 +22,14 @@ impl<'d, T: Instance> I2c<'d, T> {
22 _peri: impl Unborrow<Target = T> + 'd, 22 _peri: impl Unborrow<Target = T> + 'd,
23 scl: impl Unborrow<Target = impl SclPin<T>>, 23 scl: impl Unborrow<Target = impl SclPin<T>>,
24 sda: impl Unborrow<Target = impl SdaPin<T>>, 24 sda: impl Unborrow<Target = impl SdaPin<T>>,
25 freq: F,
26 ) -> Self 25 ) -> Self
27 where 26 where
28 F: Into<Hertz>, 27 F: Into<Hertz>,
29 { 28 {
30 unborrow!(scl, sda); 29 unborrow!(scl, sda);
31 30
31 T::enable();
32
32 unsafe { 33 unsafe {
33 Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num()); 34 Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num());
34 Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num()); 35 Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num());
@@ -41,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> {
41 }); 42 });
42 } 43 }
43 44
44 let timings = Timings::new(pclk, freq.into()); 45 let timings = Timings::new(pclk, T::frequency().into());
45 46
46 unsafe { 47 unsafe {
47 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 03ad29f13..7747857b0 100644
--- a/embassy-stm32/src/i2c/v2.rs
+++ b/embassy-stm32/src/i2c/v2.rs
@@ -22,13 +22,14 @@ impl<'d, T: Instance> I2c<'d, T> {
22 _peri: impl Unborrow<Target = T> + 'd, 22 _peri: impl Unborrow<Target = T> + 'd,
23 scl: impl Unborrow<Target = impl SclPin<T>>, 23 scl: impl Unborrow<Target = impl SclPin<T>>,
24 sda: impl Unborrow<Target = impl SdaPin<T>>, 24 sda: impl Unborrow<Target = impl SdaPin<T>>,
25 freq: F,
26 ) -> Self 25 ) -> Self
27 where 26 where
28 F: Into<Hertz>, 27 F: Into<Hertz>,
29 { 28 {
30 unborrow!(scl, sda); 29 unborrow!(scl, sda);
31 30
31 T::enable();
32
32 unsafe { 33 unsafe {
33 Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num()); 34 Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num());
34 Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num()); 35 Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num());
@@ -41,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> {
41 }); 42 });
42 } 43 }
43 44
44 let timings = Timings::new(pclk, freq.into()); 45 let timings = Timings::new(pclk, T::frequency().into());
45 46
46 unsafe { 47 unsafe {
47 T::regs().timingr().write(|reg| { 48 T::regs().timingr().write(|reg| {
diff --git a/stm32-data b/stm32-data
Subproject 0877c27cb1332237e65d74700b7bfb768996ca6 Subproject d7caa63b0091f38af6657ec86b868bfa2e8a7b5