Skip to content

Commit cf32715

Browse files
committed
Refine I2C definitions in preparation for H523/H533/H56x/H573 definitions
1 parent c7cd526 commit cf32715

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

src/i2c.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -494,7 +494,6 @@ impl<I2C: Instance> Inner<I2C> {
494494
}
495495
}
496496

497-
498497
/// Blocks until data is available and returns it
499498
///
500499
/// If a bus error occurs it will be returned and a read will not be

src/i2c/i2c_def.rs

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ use core::marker::PhantomData;
22

33
use crate::gpio::{self, Alternate, OpenDrain};
44
use crate::rcc::{rec, CoreClocks};
5-
use crate::stm32::{self, i2c1, rcc::ccipr4, I2C1, I2C2};
5+
use crate::stm32::{self, i2c1, rcc::ccipr4};
66
use crate::time::Hertz;
77

88
use super::{Instance, PinScl, PinSda};
@@ -22,11 +22,11 @@ macro_rules! pins {
2222

2323
// Implemented by all I2C instances
2424
macro_rules! i2c {
25-
($I2CX:ty: $I2cX:ident, $Pclk:ident, $pclk:ident) => {
25+
($I2CX:ty: $pclk:ident, $pllX:ident) => {
2626

2727
paste::item! {
2828
impl Instance for $I2CX {
29-
type Rec = rec::$I2cX;
29+
type Rec = rec::[< $I2CX:lower:camel >];
3030

3131
fn ptr() -> *const i2c1::RegisterBlock {
3232
<$I2CX>::ptr() as *const _
@@ -36,15 +36,15 @@ macro_rules! i2c {
3636
let ccipr4 = unsafe { (*stm32::RCC::ptr()).ccipr4().read() };
3737

3838
match ccipr4.[<$I2CX:lower sel>]().variant() {
39-
ccipr4::I2CSEL::$Pclk => Some(clocks.$pclk()),
40-
ccipr4::I2CSEL::Pll2R => clocks.pll2_r_ck(),
39+
ccipr4::I2CSEL::Pclk => Some(clocks.$pclk()),
40+
ccipr4::I2CSEL::[< $pllX:camel R>] => clocks.[< $pllX:lower _r_ck >](),
4141
ccipr4::I2CSEL::HsiKer => clocks.hsi_ck(),
4242
ccipr4::I2CSEL::CsiKer => clocks.csi_ck(),
4343
}.expect("Source clock not enabled")
4444
}
4545

4646
fn rec() -> Self::Rec {
47-
rec::$I2cX { _marker: PhantomData }
47+
rec::[< $I2CX:lower:camel >] { _marker: PhantomData }
4848
}
4949
}
5050

@@ -56,6 +56,7 @@ macro_rules! i2c {
5656
#[cfg(feature = "rm0492")]
5757
mod rm492 {
5858
use super::*;
59+
use crate::stm32::{I2C1, I2C2};
5960

6061
pins! {
6162
I2C1:
@@ -91,6 +92,6 @@ mod rm492 {
9192
]
9293
}
9394

94-
i2c! { I2C1: I2c1, Pclk, pclk1 }
95-
i2c! { I2C2: I2c2, Pclk, pclk1 }
95+
i2c! { I2C1: pclk1, Pll2 }
96+
i2c! { I2C2: pclk1, Pll2 }
9697
}

0 commit comments

Comments
 (0)