@@ -52,7 +52,8 @@ use embedded_hal::digital::v2::{
52
52
InputPin , IoPin , OutputPin , StatefulOutputPin , ToggleableOutputPin ,
53
53
} ;
54
54
55
- use crate :: pac:: { EXTI , RCC , SYSCFG } ;
55
+ use crate :: pac:: { EXTI , SYSCFG } ;
56
+ use crate :: rcc:: { Enable , APB2 } ;
56
57
57
58
mod convert;
58
59
@@ -160,7 +161,7 @@ impl<MODE> Interruptable for Input<MODE> {}
160
161
161
162
/// External Interrupt Pin
162
163
pub trait ExtiPin {
163
- fn make_interrupt_source ( & mut self , syscfg : & mut SYSCFG , rcc : & mut RCC ) ;
164
+ fn make_interrupt_source ( & mut self , syscfg : & mut SYSCFG , apb2 : & mut APB2 ) ;
164
165
fn trigger_on_edge ( & mut self , exti : & mut EXTI , level : Edge ) ;
165
166
fn enable_interrupt ( & mut self , exti : & mut EXTI ) ;
166
167
fn disable_interrupt ( & mut self , exti : & mut EXTI ) ;
@@ -175,9 +176,9 @@ where
175
176
{
176
177
/// Make corresponding EXTI line sensitive to this pin
177
178
#[ inline( always) ]
178
- fn make_interrupt_source ( & mut self , syscfg : & mut SYSCFG , rcc : & mut RCC ) {
179
+ fn make_interrupt_source ( & mut self , syscfg : & mut SYSCFG , apb2 : & mut APB2 ) {
179
180
// SYSCFG clock must be enabled in order to do register writes
180
- rcc . apb2enr . modify ( |_ , w| w . syscfgen ( ) . set_bit ( ) ) ;
181
+ SYSCFG :: enable ( apb2 ) ;
181
182
182
183
let i = self . pin_id ( ) ;
183
184
let port = self . port_id ( ) as u32 ;
@@ -584,12 +585,13 @@ impl<const P: char, const N: u8> IoPin<Self, Pin<Output<PushPull>, P, N>>
584
585
}
585
586
586
587
macro_rules! gpio {
587
- ( $GPIOX: ident, $gpiox: ident, $PEPin: ident, $port_id: expr, $PXn: ident, $iopxenr : ident , $iopxrstr : ident , [
588
+ ( $GPIOX: ident, $gpiox: ident, $PEPin: ident, $port_id: expr, $PXn: ident, [
588
589
$( $PXi: ident: ( $pxi: ident, $i: expr, $MODE: ty) , ) +
589
590
] ) => {
590
591
/// GPIO
591
592
pub mod $gpiox {
592
- use crate :: pac:: { $GPIOX, RCC } ;
593
+ use crate :: rcc:: { Enable , Reset } ;
594
+ use crate :: pac:: $GPIOX;
593
595
use super :: {
594
596
Floating , Input ,
595
597
} ;
@@ -606,11 +608,10 @@ macro_rules! gpio {
606
608
type Parts = Parts ;
607
609
608
610
fn split( self ) -> Parts {
609
- // NOTE(unsafe) this reference will only be used for atomic writes with no side effects.
610
- let rcc = unsafe { & ( * RCC :: ptr( ) ) } ;
611
- rcc. ahb1enr. modify( |_, w| w. $iopxenr( ) . set_bit( ) ) ;
612
- rcc. ahb1rstr. modify( |_, w| w. $iopxrstr( ) . set_bit( ) ) ;
613
- rcc. ahb1rstr. modify( |_, w| w. $iopxrstr( ) . clear_bit( ) ) ;
611
+ unsafe {
612
+ <$GPIOX>:: enable_unchecked( ) ;
613
+ <$GPIOX>:: reset_unchecked( ) ;
614
+ }
614
615
615
616
Parts {
616
617
$(
@@ -630,7 +631,7 @@ macro_rules! gpio {
630
631
}
631
632
}
632
633
633
- gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , gpioaen , gpioarst , [
634
+ gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
634
635
PA0 : ( pa0, 0 , Input <Floating >) ,
635
636
PA1 : ( pa1, 1 , Input <Floating >) ,
636
637
PA2 : ( pa2, 2 , Input <Floating >) ,
@@ -649,7 +650,7 @@ gpio!(GPIOA, gpioa, PA, 'A', PAn, gpioaen, gpioarst, [
649
650
PA15 : ( pa15, 15 , Input <Floating >) ,
650
651
] ) ;
651
652
652
- gpio ! ( GPIOB , gpiob, PB , 'B' , PBn , gpioben , gpiobrst , [
653
+ gpio ! ( GPIOB , gpiob, PB , 'B' , PBn , [
653
654
PB0 : ( pb0, 0 , Input <Floating >) ,
654
655
PB1 : ( pb1, 1 , Input <Floating >) ,
655
656
PB2 : ( pb2, 2 , Input <Floating >) ,
@@ -668,7 +669,7 @@ gpio!(GPIOB, gpiob, PB, 'B', PBn, gpioben, gpiobrst, [
668
669
PB15 : ( pb15, 15 , Input <Floating >) ,
669
670
] ) ;
670
671
671
- gpio ! ( GPIOC , gpioc, PC , 'C' , PCn , gpiocen , gpiocrst , [
672
+ gpio ! ( GPIOC , gpioc, PC , 'C' , PCn , [
672
673
PC0 : ( pc0, 0 , Input <Floating >) ,
673
674
PC1 : ( pc1, 1 , Input <Floating >) ,
674
675
PC2 : ( pc2, 2 , Input <Floating >) ,
@@ -687,7 +688,7 @@ gpio!(GPIOC, gpioc, PC, 'C', PCn, gpiocen, gpiocrst, [
687
688
PC15 : ( pc15, 15 , Input <Floating >) ,
688
689
] ) ;
689
690
690
- gpio ! ( GPIOD , gpiod, PD , 'D' , PDn , gpioden , gpiodrst , [
691
+ gpio ! ( GPIOD , gpiod, PD , 'D' , PDn , [
691
692
PD0 : ( pd0, 0 , Input <Floating >) ,
692
693
PD1 : ( pd1, 1 , Input <Floating >) ,
693
694
PD2 : ( pd2, 2 , Input <Floating >) ,
@@ -706,7 +707,7 @@ gpio!(GPIOD, gpiod, PD, 'D', PDn, gpioden, gpiodrst, [
706
707
PD15 : ( pd15, 15 , Input <Floating >) ,
707
708
] ) ;
708
709
709
- gpio ! ( GPIOE , gpioe, PE , 'E' , PEn , gpioeen , gpioerst , [
710
+ gpio ! ( GPIOE , gpioe, PE , 'E' , PEn , [
710
711
PE0 : ( pe0, 0 , Input <Floating >) ,
711
712
PE1 : ( pe1, 1 , Input <Floating >) ,
712
713
PE2 : ( pe2, 2 , Input <Floating >) ,
@@ -725,7 +726,7 @@ gpio!(GPIOE, gpioe, PE, 'E', PEn, gpioeen, gpioerst, [
725
726
PE15 : ( pe15, 15 , Input <Floating >) ,
726
727
] ) ;
727
728
728
- gpio ! ( GPIOF , gpiof, PF , 'F' , PFn , gpiofen , gpiofrst , [
729
+ gpio ! ( GPIOF , gpiof, PF , 'F' , PFn , [
729
730
PF0 : ( pf0, 0 , Input <Floating >) ,
730
731
PF1 : ( pf1, 1 , Input <Floating >) ,
731
732
PF2 : ( pf2, 2 , Input <Floating >) ,
@@ -744,7 +745,7 @@ gpio!(GPIOF, gpiof, PF, 'F', PFn, gpiofen, gpiofrst, [
744
745
PF15 : ( pf15, 15 , Input <Floating >) ,
745
746
] ) ;
746
747
747
- gpio ! ( GPIOG , gpiog, PG , 'G' , PGn , gpiogen , gpiogrst , [
748
+ gpio ! ( GPIOG , gpiog, PG , 'G' , PGn , [
748
749
PG0 : ( pg0, 0 , Input <Floating >) ,
749
750
PG1 : ( pg1, 1 , Input <Floating >) ,
750
751
PG2 : ( pg2, 2 , Input <Floating >) ,
@@ -763,7 +764,7 @@ gpio!(GPIOG, gpiog, PG, 'G', PGn, gpiogen, gpiogrst, [
763
764
PG15 : ( pg15, 15 , Input <Floating >) ,
764
765
] ) ;
765
766
766
- gpio ! ( GPIOH , gpioh, PH , 'H' , PHn , gpiohen , gpiohrst , [
767
+ gpio ! ( GPIOH , gpioh, PH , 'H' , PHn , [
767
768
PH0 : ( ph0, 0 , Input <Floating >) ,
768
769
PH1 : ( ph1, 1 , Input <Floating >) ,
769
770
PH2 : ( ph2, 2 , Input <Floating >) ,
@@ -782,7 +783,7 @@ gpio!(GPIOH, gpioh, PH, 'H', PHn, gpiohen, gpiohrst, [
782
783
PH15 : ( ph15, 15 , Input <Floating >) ,
783
784
] ) ;
784
785
785
- gpio ! ( GPIOI , gpioi, PI , 'I' , PIn , gpioien , gpioirst , [
786
+ gpio ! ( GPIOI , gpioi, PI , 'I' , PIn , [
786
787
PI0 : ( pi0, 0 , Input <Floating >) ,
787
788
PI1 : ( pi1, 1 , Input <Floating >) ,
788
789
PI2 : ( pi2, 2 , Input <Floating >) ,
@@ -802,7 +803,7 @@ gpio!(GPIOI, gpioi, PI, 'I', PIn, gpioien, gpioirst, [
802
803
] ) ;
803
804
804
805
#[ cfg( feature = "gpioj" ) ]
805
- gpio ! ( GPIOJ , gpioj, PJ , 'J' , PJn , gpiojen , gpiojrst , [
806
+ gpio ! ( GPIOJ , gpioj, PJ , 'J' , PJn , [
806
807
PJ0 : ( pj0, 0 , Input <Floating >) ,
807
808
PJ1 : ( pj1, 1 , Input <Floating >) ,
808
809
PJ2 : ( pj2, 2 , Input <Floating >) ,
@@ -822,7 +823,7 @@ gpio!(GPIOJ, gpioj, PJ, 'J', PJn, gpiojen, gpiojrst, [
822
823
] ) ;
823
824
824
825
#[ cfg( feature = "gpiok" ) ]
825
- gpio ! ( GPIOK , gpiok, PK , 'K' , PKn , gpioken , gpiokrst , [
826
+ gpio ! ( GPIOK , gpiok, PK , 'K' , PKn , [
826
827
PK0 : ( pk0, 0 , Input <Floating >) ,
827
828
PK1 : ( pk1, 1 , Input <Floating >) ,
828
829
PK2 : ( pk2, 2 , Input <Floating >) ,
0 commit comments