@@ -293,7 +293,7 @@ impl PinScl<I2C3> for PH7<AlternateOD<4>> {}
293
293
) ) ]
294
294
impl PinSda < I2C3 > for PH8 < AlternateOD < 4 > > { }
295
295
296
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
296
+ #[ cfg( feature = "fmpi2c1" ) ]
297
297
use crate :: {
298
298
gpio:: {
299
299
gpiob:: { PB13 , PB14 , PB15 } ,
@@ -305,40 +305,40 @@ use crate::{
305
305
pac:: FMPI2C1 ,
306
306
} ;
307
307
308
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
308
+ #[ cfg( feature = "fmpi2c1" ) ]
309
309
impl PinScl < FMPI2C1 > for PC6 < AlternateOD < 4 > > { }
310
310
311
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
311
+ #[ cfg( feature = "fmpi2c1" ) ]
312
312
impl PinSda < FMPI2C1 > for PC7 < AlternateOD < 4 > > { }
313
313
314
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
314
+ #[ cfg( feature = "fmpi2c1" ) ]
315
315
impl PinSda < FMPI2C1 > for PB3 < AlternateOD < 4 > > { }
316
316
317
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
317
+ #[ cfg( feature = "fmpi2c1" ) ]
318
318
impl PinScl < FMPI2C1 > for PB10 < AlternateOD < 9 > > { }
319
319
320
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
320
+ #[ cfg( feature = "fmpi2c1" ) ]
321
321
impl PinSda < FMPI2C1 > for PB14 < AlternateOD < 4 > > { }
322
322
323
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
323
+ #[ cfg( feature = "fmpi2c1" ) ]
324
324
impl PinScl < FMPI2C1 > for PB15 < AlternateOD < 4 > > { }
325
325
326
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
326
+ #[ cfg( feature = "fmpi2c1" ) ]
327
327
impl PinScl < FMPI2C1 > for PD12 < AlternateOD < 4 > > { }
328
328
329
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
329
+ #[ cfg( feature = "fmpi2c1" ) ]
330
330
impl PinScl < FMPI2C1 > for PB13 < AlternateOD < 4 > > { }
331
331
332
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
332
+ #[ cfg( feature = "fmpi2c1" ) ]
333
333
impl PinScl < FMPI2C1 > for PD14 < AlternateOD < 4 > > { }
334
334
335
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
335
+ #[ cfg( feature = "fmpi2c1" ) ]
336
336
impl PinScl < FMPI2C1 > for PD15 < AlternateOD < 4 > > { }
337
337
338
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
338
+ #[ cfg( feature = "fmpi2c1" ) ]
339
339
impl PinScl < FMPI2C1 > for PF14 < AlternateOD < 4 > > { }
340
340
341
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
341
+ #[ cfg( feature = "fmpi2c1" ) ]
342
342
impl PinScl < FMPI2C1 > for PF15 < AlternateOD < 4 > > { }
343
343
344
344
#[ derive( Debug , Eq , PartialEq , Copy , Clone ) ]
@@ -359,52 +359,22 @@ mod private {
359
359
360
360
pub trait Instance : private:: Sealed + Deref < Target = i2c1:: RegisterBlock > + Enable + Reset { }
361
361
362
- // Implemented by all I2C instances
363
- macro_rules! i2c {
364
- ( $(
365
- $I2C: ident: ( $i2c: ident, $apbXenr: ident, $en_bit: expr, $apbxrstr: ident, $reset_bit: expr) ,
366
- ) +) => {
367
- $(
368
- impl private:: Sealed for $I2C { }
369
- impl Instance for $I2C { }
370
-
371
- impl <PINS > I2c <$I2C, PINS >
372
- where
373
- PINS : Pins <$I2C>,
374
- {
375
- #[ deprecated(
376
- since = "0.9.0" ,
377
- note = "Please use new instead"
378
- ) ]
379
- pub fn $i2c(
380
- i2c: $I2C,
381
- pins: PINS ,
382
- speed: KiloHertz ,
383
- clocks: Clocks ,
384
- ) -> Self {
385
- Self :: new( i2c, pins, speed, clocks)
386
- }
387
- }
388
- ) +
389
- }
390
- }
391
-
392
- i2c ! {
393
- I2C1 : ( i2c1, apb1enr, 21 , apb1rstr, 21 ) ,
394
- I2C2 : ( i2c2, apb1enr, 22 , apb1rstr, 22 ) ,
395
- }
362
+ impl private:: Sealed for I2C1 { }
363
+ impl Instance for I2C1 { }
364
+ impl private:: Sealed for I2C2 { }
365
+ impl Instance for I2C2 { }
396
366
397
367
#[ cfg( feature = "i2c3" ) ]
398
- i2c ! {
399
- I2C3 : ( i2c3 , apb1enr , 23 , apb1rstr , 23 ) ,
400
- }
368
+ impl private :: Sealed for I2C3 { }
369
+ # [ cfg ( feature = "i2c3" ) ]
370
+ impl Instance for I2C3 { }
401
371
402
372
#[ cfg( feature = "fmpi2c1" ) ]
403
- impl < PINS > FMPI2c < FMPI2C1 , PINS > {
404
- pub fn fmpi2c ( i2c : FMPI2C1 , pins : PINS , speed : KiloHertz ) -> Self
405
- where
406
- PINS : Pins < FMPI2C1 > ,
407
- {
373
+ impl < PINS > FMPI2c < FMPI2C1 , PINS >
374
+ where
375
+ PINS : Pins < FMPI2C1 > ,
376
+ {
377
+ pub fn new ( i2c : FMPI2C1 , pins : PINS , speed : KiloHertz ) -> Self {
408
378
unsafe {
409
379
// NOTE(unsafe) this reference will only be used for atomic writes with no side effects.
410
380
let rcc = & ( * RCC :: ptr ( ) ) ;
@@ -425,11 +395,9 @@ impl<PINS> FMPI2c<FMPI2C1, PINS> {
425
395
impl < I2C , PINS > I2c < I2C , PINS >
426
396
where
427
397
I2C : Instance ,
398
+ PINS : Pins < I2C > ,
428
399
{
429
- pub fn new ( i2c : I2C , pins : PINS , speed : KiloHertz , clocks : Clocks ) -> Self
430
- where
431
- PINS : Pins < I2C > ,
432
- {
400
+ pub fn new ( i2c : I2C , pins : PINS , speed : KiloHertz , clocks : Clocks ) -> Self {
433
401
unsafe {
434
402
// NOTE(unsafe) this reference will only be used for atomic writes with no side effects.
435
403
let rcc = & ( * RCC :: ptr ( ) ) ;
@@ -443,7 +411,12 @@ where
443
411
i2c. i2c_init ( speed, clocks. pclk1 ( ) ) ;
444
412
i2c
445
413
}
414
+ }
446
415
416
+ impl < I2C , PINS > I2c < I2C , PINS >
417
+ where
418
+ I2C : Instance ,
419
+ {
447
420
fn i2c_init ( & self , speed : KiloHertz , pclk : Hertz ) {
448
421
let speed: Hertz = speed. into ( ) ;
449
422
@@ -735,7 +708,7 @@ where
735
708
}
736
709
}
737
710
738
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
711
+ #[ cfg( feature = "fmpi2c1" ) ]
739
712
impl < I2C , PINS > FMPI2c < I2C , PINS >
740
713
where
741
714
I2C : Deref < Target = fmpi2c1:: RegisterBlock > ,
@@ -839,7 +812,7 @@ where
839
812
}
840
813
}
841
814
842
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
815
+ #[ cfg( feature = "fmpi2c1" ) ]
843
816
impl < I2C , PINS > WriteRead for FMPI2c < I2C , PINS >
844
817
where
845
818
I2C : Deref < Target = fmpi2c1:: RegisterBlock > ,
@@ -909,7 +882,7 @@ where
909
882
}
910
883
}
911
884
912
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
885
+ #[ cfg( feature = "fmpi2c1" ) ]
913
886
impl < I2C , PINS > Read for FMPI2c < I2C , PINS >
914
887
where
915
888
I2C : Deref < Target = fmpi2c1:: RegisterBlock > ,
@@ -945,7 +918,7 @@ where
945
918
}
946
919
}
947
920
948
- #[ cfg( any ( feature = "stm32f413" , feature = "stm32f423" , ) ) ]
921
+ #[ cfg( feature = "fmpi2c1" ) ]
949
922
impl < I2C , PINS > Write for FMPI2c < I2C , PINS >
950
923
where
951
924
I2C : Deref < Target = fmpi2c1:: RegisterBlock > ,
0 commit comments