@@ -2,7 +2,7 @@ use core::marker::PhantomData;
22
33use crate :: gpio:: { self , Alternate , OpenDrain } ;
44use crate :: rcc:: { rec, CoreClocks } ;
5- use crate :: stm32:: { self , i2c1, rcc:: ccipr4, I2C1 , I2C2 } ;
5+ use crate :: stm32:: { self , i2c1, rcc:: ccipr4} ;
66use crate :: time:: Hertz ;
77
88use super :: { Instance , PinScl , PinSda } ;
@@ -22,11 +22,11 @@ macro_rules! pins {
2222
2323// Implemented by all I2C instances
2424macro_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" ) ]
5757mod 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