Remove the frequency argument for i2c, move to using RccPeripheral.

This commit is contained in:
Bob McWhirter 2021-07-01 13:53:57 -04:00
parent e7a4a72977
commit 9f5d35d891
4 changed files with 9 additions and 6 deletions

View File

@ -17,8 +17,9 @@ pub enum Error {
pub(crate) mod sealed {
use crate::gpio::Pin;
use crate::rcc::RccPeripheral;
pub trait Instance {
pub trait Instance: RccPeripheral {
fn regs() -> &'static crate::pac::i2c::I2c;
}

View File

@ -22,13 +22,14 @@ impl<'d, T: Instance> I2c<'d, T> {
_peri: impl Unborrow<Target = T> + 'd,
scl: impl Unborrow<Target = impl SclPin<T>>,
sda: impl Unborrow<Target = impl SdaPin<T>>,
freq: F,
) -> Self
where
F: Into<Hertz>,
{
unborrow!(scl, sda);
T::enable();
unsafe {
Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num());
Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num());
@ -41,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> {
});
}
let timings = Timings::new(pclk, freq.into());
let timings = Timings::new(pclk, T::frequency().into());
unsafe {
T::regs().cr2().modify(|reg| {

View File

@ -22,13 +22,14 @@ impl<'d, T: Instance> I2c<'d, T> {
_peri: impl Unborrow<Target = T> + 'd,
scl: impl Unborrow<Target = impl SclPin<T>>,
sda: impl Unborrow<Target = impl SdaPin<T>>,
freq: F,
) -> Self
where
F: Into<Hertz>,
{
unborrow!(scl, sda);
T::enable();
unsafe {
Self::configure_pin(scl.block(), scl.pin() as _, scl.af_num());
Self::configure_pin(sda.block(), sda.pin() as _, sda.af_num());
@ -41,7 +42,7 @@ impl<'d, T: Instance> I2c<'d, T> {
});
}
let timings = Timings::new(pclk, freq.into());
let timings = Timings::new(pclk, T::frequency().into());
unsafe {
T::regs().timingr().write(|reg| {

@ -1 +1 @@
Subproject commit 0877c27cb1332237e65d74700b7bfb768996ca66
Subproject commit d7caa63b0091f38af6657ec86b868bfa2e8a7b56