@@ -52,7 +52,8 @@ use embedded_hal::digital::v2::{
5252 InputPin , IoPin , OutputPin , StatefulOutputPin , ToggleableOutputPin ,
5353} ;
5454
55- use crate :: pac:: { EXTI , RCC , SYSCFG } ;
55+ use crate :: pac:: { EXTI , SYSCFG } ;
56+ use crate :: rcc:: { Enable , APB2 } ;
5657
5758mod convert;
5859
@@ -160,7 +161,7 @@ impl<MODE> Interruptable for Input<MODE> {}
160161
161162/// External Interrupt Pin
162163pub 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 ) ;
164165 fn trigger_on_edge ( & mut self , exti : & mut EXTI , level : Edge ) ;
165166 fn enable_interrupt ( & mut self , exti : & mut EXTI ) ;
166167 fn disable_interrupt ( & mut self , exti : & mut EXTI ) ;
@@ -175,9 +176,9 @@ where
175176{
176177 /// Make corresponding EXTI line sensitive to this pin
177178 #[ 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 ) {
179180 // SYSCFG clock must be enabled in order to do register writes
180- rcc . apb2enr . modify ( |_ , w| w . syscfgen ( ) . set_bit ( ) ) ;
181+ SYSCFG :: enable ( apb2 ) ;
181182
182183 let i = self . pin_id ( ) ;
183184 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>>
584585}
585586
586587macro_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, [
588589 $( $PXi: ident: ( $pxi: ident, $i: expr, $MODE: ty) , ) +
589590 ] ) => {
590591 /// GPIO
591592 pub mod $gpiox {
592- use crate :: pac:: { $GPIOX, RCC } ;
593+ use crate :: rcc:: { Enable , Reset } ;
594+ use crate :: pac:: $GPIOX;
593595 use super :: {
594596 Floating , Input ,
595597 } ;
@@ -606,11 +608,10 @@ macro_rules! gpio {
606608 type Parts = Parts ;
607609
608610 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+ }
614615
615616 Parts {
616617 $(
@@ -630,7 +631,7 @@ macro_rules! gpio {
630631 }
631632}
632633
633- gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , gpioaen , gpioarst , [
634+ gpio ! ( GPIOA , gpioa, PA , 'A' , PAn , [
634635 PA0 : ( pa0, 0 , Input <Floating >) ,
635636 PA1 : ( pa1, 1 , Input <Floating >) ,
636637 PA2 : ( pa2, 2 , Input <Floating >) ,
@@ -649,7 +650,7 @@ gpio!(GPIOA, gpioa, PA, 'A', PAn, gpioaen, gpioarst, [
649650 PA15 : ( pa15, 15 , Input <Floating >) ,
650651] ) ;
651652
652- gpio ! ( GPIOB , gpiob, PB , 'B' , PBn , gpioben , gpiobrst , [
653+ gpio ! ( GPIOB , gpiob, PB , 'B' , PBn , [
653654 PB0 : ( pb0, 0 , Input <Floating >) ,
654655 PB1 : ( pb1, 1 , Input <Floating >) ,
655656 PB2 : ( pb2, 2 , Input <Floating >) ,
@@ -668,7 +669,7 @@ gpio!(GPIOB, gpiob, PB, 'B', PBn, gpioben, gpiobrst, [
668669 PB15 : ( pb15, 15 , Input <Floating >) ,
669670] ) ;
670671
671- gpio ! ( GPIOC , gpioc, PC , 'C' , PCn , gpiocen , gpiocrst , [
672+ gpio ! ( GPIOC , gpioc, PC , 'C' , PCn , [
672673 PC0 : ( pc0, 0 , Input <Floating >) ,
673674 PC1 : ( pc1, 1 , Input <Floating >) ,
674675 PC2 : ( pc2, 2 , Input <Floating >) ,
@@ -687,7 +688,7 @@ gpio!(GPIOC, gpioc, PC, 'C', PCn, gpiocen, gpiocrst, [
687688 PC15 : ( pc15, 15 , Input <Floating >) ,
688689] ) ;
689690
690- gpio ! ( GPIOD , gpiod, PD , 'D' , PDn , gpioden , gpiodrst , [
691+ gpio ! ( GPIOD , gpiod, PD , 'D' , PDn , [
691692 PD0 : ( pd0, 0 , Input <Floating >) ,
692693 PD1 : ( pd1, 1 , Input <Floating >) ,
693694 PD2 : ( pd2, 2 , Input <Floating >) ,
@@ -706,7 +707,7 @@ gpio!(GPIOD, gpiod, PD, 'D', PDn, gpioden, gpiodrst, [
706707 PD15 : ( pd15, 15 , Input <Floating >) ,
707708] ) ;
708709
709- gpio ! ( GPIOE , gpioe, PE , 'E' , PEn , gpioeen , gpioerst , [
710+ gpio ! ( GPIOE , gpioe, PE , 'E' , PEn , [
710711 PE0 : ( pe0, 0 , Input <Floating >) ,
711712 PE1 : ( pe1, 1 , Input <Floating >) ,
712713 PE2 : ( pe2, 2 , Input <Floating >) ,
@@ -725,7 +726,7 @@ gpio!(GPIOE, gpioe, PE, 'E', PEn, gpioeen, gpioerst, [
725726 PE15 : ( pe15, 15 , Input <Floating >) ,
726727] ) ;
727728
728- gpio ! ( GPIOF , gpiof, PF , 'F' , PFn , gpiofen , gpiofrst , [
729+ gpio ! ( GPIOF , gpiof, PF , 'F' , PFn , [
729730 PF0 : ( pf0, 0 , Input <Floating >) ,
730731 PF1 : ( pf1, 1 , Input <Floating >) ,
731732 PF2 : ( pf2, 2 , Input <Floating >) ,
@@ -744,7 +745,7 @@ gpio!(GPIOF, gpiof, PF, 'F', PFn, gpiofen, gpiofrst, [
744745 PF15 : ( pf15, 15 , Input <Floating >) ,
745746] ) ;
746747
747- gpio ! ( GPIOG , gpiog, PG , 'G' , PGn , gpiogen , gpiogrst , [
748+ gpio ! ( GPIOG , gpiog, PG , 'G' , PGn , [
748749 PG0 : ( pg0, 0 , Input <Floating >) ,
749750 PG1 : ( pg1, 1 , Input <Floating >) ,
750751 PG2 : ( pg2, 2 , Input <Floating >) ,
@@ -763,7 +764,7 @@ gpio!(GPIOG, gpiog, PG, 'G', PGn, gpiogen, gpiogrst, [
763764 PG15 : ( pg15, 15 , Input <Floating >) ,
764765] ) ;
765766
766- gpio ! ( GPIOH , gpioh, PH , 'H' , PHn , gpiohen , gpiohrst , [
767+ gpio ! ( GPIOH , gpioh, PH , 'H' , PHn , [
767768 PH0 : ( ph0, 0 , Input <Floating >) ,
768769 PH1 : ( ph1, 1 , Input <Floating >) ,
769770 PH2 : ( ph2, 2 , Input <Floating >) ,
@@ -782,7 +783,7 @@ gpio!(GPIOH, gpioh, PH, 'H', PHn, gpiohen, gpiohrst, [
782783 PH15 : ( ph15, 15 , Input <Floating >) ,
783784] ) ;
784785
785- gpio ! ( GPIOI , gpioi, PI , 'I' , PIn , gpioien , gpioirst , [
786+ gpio ! ( GPIOI , gpioi, PI , 'I' , PIn , [
786787 PI0 : ( pi0, 0 , Input <Floating >) ,
787788 PI1 : ( pi1, 1 , Input <Floating >) ,
788789 PI2 : ( pi2, 2 , Input <Floating >) ,
@@ -802,7 +803,7 @@ gpio!(GPIOI, gpioi, PI, 'I', PIn, gpioien, gpioirst, [
802803] ) ;
803804
804805#[ cfg( feature = "gpioj" ) ]
805- gpio ! ( GPIOJ , gpioj, PJ , 'J' , PJn , gpiojen , gpiojrst , [
806+ gpio ! ( GPIOJ , gpioj, PJ , 'J' , PJn , [
806807 PJ0 : ( pj0, 0 , Input <Floating >) ,
807808 PJ1 : ( pj1, 1 , Input <Floating >) ,
808809 PJ2 : ( pj2, 2 , Input <Floating >) ,
@@ -822,7 +823,7 @@ gpio!(GPIOJ, gpioj, PJ, 'J', PJn, gpiojen, gpiojrst, [
822823] ) ;
823824
824825#[ cfg( feature = "gpiok" ) ]
825- gpio ! ( GPIOK , gpiok, PK , 'K' , PKn , gpioken , gpiokrst , [
826+ gpio ! ( GPIOK , gpiok, PK , 'K' , PKn , [
826827 PK0 : ( pk0, 0 , Input <Floating >) ,
827828 PK1 : ( pk1, 1 , Input <Floating >) ,
828829 PK2 : ( pk2, 2 , Input <Floating >) ,
0 commit comments