@@ -459,6 +459,7 @@ macro_rules! gpio {
459
459
impl <MODE > $PXi<MODE > where MODE : Active {
460
460
/// Configures the pin to operate as an alternate function push-pull output
461
461
/// pin.
462
+ #[ inline]
462
463
pub fn into_alternate_push_pull(
463
464
self ,
464
465
cr: & mut $CR,
@@ -482,6 +483,7 @@ macro_rules! gpio {
482
483
483
484
/// Configures the pin to operate as an alternate function open-drain output
484
485
/// pin.
486
+ #[ inline]
485
487
pub fn into_alternate_open_drain(
486
488
self ,
487
489
cr: & mut $CR,
@@ -504,6 +506,7 @@ macro_rules! gpio {
504
506
}
505
507
506
508
/// Configures the pin to operate as a floating input pin
509
+ #[ inline]
507
510
pub fn into_floating_input(
508
511
self ,
509
512
cr: & mut $CR,
@@ -514,6 +517,7 @@ macro_rules! gpio {
514
517
}
515
518
516
519
/// Configures the pin to operate as a pulled down input pin
520
+ #[ inline]
517
521
pub fn into_pull_down_input(
518
522
self ,
519
523
cr: & mut $CR,
@@ -524,6 +528,7 @@ macro_rules! gpio {
524
528
}
525
529
526
530
/// Configures the pin to operate as a pulled up input pin
531
+ #[ inline]
527
532
pub fn into_pull_up_input(
528
533
self ,
529
534
cr: & mut $CR,
@@ -535,6 +540,7 @@ macro_rules! gpio {
535
540
536
541
/// Configures the pin to operate as an open-drain output pin.
537
542
/// Initial state will be low.
543
+ #[ inline]
538
544
pub fn into_open_drain_output(
539
545
self ,
540
546
cr: & mut $CR,
@@ -544,6 +550,7 @@ macro_rules! gpio {
544
550
545
551
/// Configures the pin to operate as an open-drain output pin.
546
552
/// `initial_state` specifies whether the pin should be initially high or low.
553
+ #[ inline]
547
554
pub fn into_open_drain_output_with_state(
548
555
mut self ,
549
556
cr: & mut $CR,
@@ -556,6 +563,7 @@ macro_rules! gpio {
556
563
}
557
564
/// Configures the pin to operate as an push-pull output pin.
558
565
/// Initial state will be low.
566
+ #[ inline]
559
567
pub fn into_push_pull_output(
560
568
self ,
561
569
cr: & mut $CR,
@@ -565,6 +573,7 @@ macro_rules! gpio {
565
573
566
574
/// Configures the pin to operate as an push-pull output pin.
567
575
/// `initial_state` specifies whether the pin should be initially high or low.
576
+ #[ inline]
568
577
pub fn into_push_pull_output_with_state(
569
578
mut self ,
570
579
cr: & mut $CR,
@@ -577,6 +586,7 @@ macro_rules! gpio {
577
586
}
578
587
579
588
/// Configures the pin to operate as an analog input pin
589
+ #[ inline]
580
590
pub fn into_analog( self , cr: & mut $CR) -> $PXi<Analog > {
581
591
unsafe {
582
592
$PXi:: <Analog >:: set_mode( cr)
@@ -586,6 +596,7 @@ macro_rules! gpio {
586
596
/// Configures the pin as a pin that can change between input
587
597
/// and output without changing the type. It starts out
588
598
/// as a floating input
599
+ #[ inline]
589
600
pub fn into_dynamic( self , cr: & mut $CR) -> $PXi<Dynamic > {
590
601
self . into_floating_input( cr) ;
591
602
$PXi:: <Dynamic >{ mode: Dynamic :: InputFloating }
@@ -606,6 +617,7 @@ macro_rules! gpio {
606
617
The value of the pin after conversion is undefined. If you
607
618
want to control it, use `$stateful_fn_name`
608
619
*/
620
+ #[ inline]
609
621
pub fn $fn_name(
610
622
& mut self ,
611
623
cr: & mut $CR,
@@ -625,6 +637,7 @@ macro_rules! gpio {
625
637
happens. This can cause a short output glitch if switching
626
638
between output modes
627
639
*/
640
+ #[ inline]
628
641
pub fn $stateful_fn_name(
629
642
& mut self ,
630
643
cr: & mut $CR,
@@ -648,6 +661,7 @@ macro_rules! gpio {
648
661
/**
649
662
Temporarily change the mode of the pin.
650
663
*/
664
+ #[ inline]
651
665
pub fn $fn_name(
652
666
& mut self ,
653
667
cr: & mut $CR,
@@ -689,6 +703,7 @@ macro_rules! gpio {
689
703
690
704
impl <MODE > $PXi<MODE > where MODE : Active {
691
705
/// Erases the pin number from the type
706
+ #[ inline]
692
707
fn into_generic( self ) -> Generic <MODE > {
693
708
Generic {
694
709
i: $i,
@@ -709,22 +724,26 @@ macro_rules! gpio {
709
724
710
725
impl <MODE > OutputPin for $PXi<Output <MODE >> {
711
726
type Error = Infallible ;
727
+ #[ inline]
712
728
fn set_high( & mut self ) -> Result <( ) , Self :: Error > {
713
729
// NOTE(unsafe) atomic write to a stateless register
714
730
Ok ( self . set_state( State :: High ) )
715
731
}
716
732
733
+ #[ inline]
717
734
fn set_low( & mut self ) -> Result <( ) , Self :: Error > {
718
735
// NOTE(unsafe) atomic write to a stateless register
719
736
Ok ( self . set_state( State :: Low ) )
720
737
}
721
738
}
722
739
723
740
impl <MODE > StatefulOutputPin for $PXi<Output <MODE >> {
741
+ #[ inline]
724
742
fn is_set_high( & self ) -> Result <bool , Self :: Error > {
725
743
self . is_set_low( ) . map( |b| !b)
726
744
}
727
745
746
+ #[ inline]
728
747
fn is_set_low( & self ) -> Result <bool , Self :: Error > {
729
748
Ok ( self . _is_set_low( ) )
730
749
}
@@ -734,10 +753,12 @@ macro_rules! gpio {
734
753
735
754
impl <MODE > InputPin for $PXi<Input <MODE >> {
736
755
type Error = Infallible ;
756
+ #[ inline]
737
757
fn is_high( & self ) -> Result <bool , Self :: Error > {
738
758
self . is_low( ) . map( |b| !b)
739
759
}
740
760
761
+ #[ inline]
741
762
fn is_low( & self ) -> Result <bool , Self :: Error > {
742
763
// NOTE(unsafe) atomic read with no side effects
743
764
Ok ( self . _is_low( ) )
@@ -746,10 +767,12 @@ macro_rules! gpio {
746
767
747
768
impl InputPin for $PXi<Output <OpenDrain >> {
748
769
type Error = Infallible ;
770
+ #[ inline]
749
771
fn is_high( & self ) -> Result <bool , Self :: Error > {
750
772
self . is_low( ) . map( |b| !b)
751
773
}
752
774
775
+ #[ inline]
753
776
fn is_low( & self ) -> Result <bool , Self :: Error > {
754
777
Ok ( self . _is_low( ) )
755
778
}
@@ -759,26 +782,31 @@ macro_rules! gpio {
759
782
// Dynamic pin
760
783
761
784
impl $PXi<Dynamic > {
785
+ #[ inline]
762
786
pub fn make_pull_up_input( & mut self , cr: & mut $CR) {
763
787
// NOTE(unsafe), we have a mutable reference to the current pin
764
788
unsafe { $PXi:: <Input <PullUp >>:: set_mode( cr) } ;
765
789
self . mode = Dynamic :: InputPullUp ;
766
790
}
791
+ #[ inline]
767
792
pub fn make_pull_down_input( & mut self , cr: & mut $CR) {
768
793
// NOTE(unsafe), we have a mutable reference to the current pin
769
794
unsafe { $PXi:: <Input <PullDown >>:: set_mode( cr) } ;
770
795
self . mode = Dynamic :: InputPullDown ;
771
796
}
797
+ #[ inline]
772
798
pub fn make_floating_input( & mut self , cr: & mut $CR) {
773
799
// NOTE(unsafe), we have a mutable reference to the current pin
774
800
unsafe { $PXi:: <Input <Floating >>:: set_mode( cr) } ;
775
801
self . mode = Dynamic :: InputFloating ;
776
802
}
803
+ #[ inline]
777
804
pub fn make_push_pull_output( & mut self , cr: & mut $CR) {
778
805
// NOTE(unsafe), we have a mutable reference to the current pin
779
806
unsafe { $PXi:: <Output <PushPull >>:: set_mode( cr) } ;
780
807
self . mode = Dynamic :: OutputPushPull ;
781
808
}
809
+ #[ inline]
782
810
pub fn make_open_drain_output( & mut self , cr: & mut $CR) {
783
811
// NOTE(unsafe), we have a mutable reference to the current pin
784
812
unsafe { $PXi:: <Output <OpenDrain >>:: set_mode( cr) } ;
@@ -856,21 +884,25 @@ macro_rules! gpio {
856
884
}
857
885
858
886
/// Enable external interrupts from this pin.
887
+ #[ inline]
859
888
fn enable_interrupt( & mut self , exti: & EXTI ) {
860
889
exti. imr. modify( |r, w| unsafe { w. bits( r. bits( ) | ( 1 << $i) ) } ) ;
861
890
}
862
891
863
892
/// Disable external interrupts from this pin
893
+ #[ inline]
864
894
fn disable_interrupt( & mut self , exti: & EXTI ) {
865
895
exti. imr. modify( |r, w| unsafe { w. bits( r. bits( ) & !( 1 << $i) ) } ) ;
866
896
}
867
897
868
898
/// Clear the interrupt pending bit for this pin
899
+ #[ inline]
869
900
fn clear_interrupt_pending_bit( & mut self ) {
870
901
unsafe { ( * EXTI :: ptr( ) ) . pr. write( |w| w. bits( 1 << $i) ) } ;
871
902
}
872
903
873
904
/// Reads the interrupt pending bit for this pin
905
+ #[ inline]
874
906
fn check_interrupt( & mut self ) -> bool {
875
907
unsafe { ( ( * EXTI :: ptr( ) ) . pr. read( ) . bits( ) & ( 1 << $i) ) != 0 }
876
908
}
0 commit comments