Skip to content

Commit 0b46f3d

Browse files
committed
Inline a bunch of functions
1 parent 983aa93 commit 0b46f3d

File tree

1 file changed

+32
-0
lines changed

1 file changed

+32
-0
lines changed

src/gpio.rs

Lines changed: 32 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -459,6 +459,7 @@ macro_rules! gpio {
459459
impl<MODE> $PXi<MODE> where MODE: Active {
460460
/// Configures the pin to operate as an alternate function push-pull output
461461
/// pin.
462+
#[inline]
462463
pub fn into_alternate_push_pull(
463464
self,
464465
cr: &mut $CR,
@@ -482,6 +483,7 @@ macro_rules! gpio {
482483

483484
/// Configures the pin to operate as an alternate function open-drain output
484485
/// pin.
486+
#[inline]
485487
pub fn into_alternate_open_drain(
486488
self,
487489
cr: &mut $CR,
@@ -504,6 +506,7 @@ macro_rules! gpio {
504506
}
505507

506508
/// Configures the pin to operate as a floating input pin
509+
#[inline]
507510
pub fn into_floating_input(
508511
self,
509512
cr: &mut $CR,
@@ -514,6 +517,7 @@ macro_rules! gpio {
514517
}
515518

516519
/// Configures the pin to operate as a pulled down input pin
520+
#[inline]
517521
pub fn into_pull_down_input(
518522
self,
519523
cr: &mut $CR,
@@ -524,6 +528,7 @@ macro_rules! gpio {
524528
}
525529

526530
/// Configures the pin to operate as a pulled up input pin
531+
#[inline]
527532
pub fn into_pull_up_input(
528533
self,
529534
cr: &mut $CR,
@@ -535,6 +540,7 @@ macro_rules! gpio {
535540

536541
/// Configures the pin to operate as an open-drain output pin.
537542
/// Initial state will be low.
543+
#[inline]
538544
pub fn into_open_drain_output(
539545
self,
540546
cr: &mut $CR,
@@ -544,6 +550,7 @@ macro_rules! gpio {
544550

545551
/// Configures the pin to operate as an open-drain output pin.
546552
/// `initial_state` specifies whether the pin should be initially high or low.
553+
#[inline]
547554
pub fn into_open_drain_output_with_state(
548555
mut self,
549556
cr: &mut $CR,
@@ -556,6 +563,7 @@ macro_rules! gpio {
556563
}
557564
/// Configures the pin to operate as an push-pull output pin.
558565
/// Initial state will be low.
566+
#[inline]
559567
pub fn into_push_pull_output(
560568
self,
561569
cr: &mut $CR,
@@ -565,6 +573,7 @@ macro_rules! gpio {
565573

566574
/// Configures the pin to operate as an push-pull output pin.
567575
/// `initial_state` specifies whether the pin should be initially high or low.
576+
#[inline]
568577
pub fn into_push_pull_output_with_state(
569578
mut self,
570579
cr: &mut $CR,
@@ -577,6 +586,7 @@ macro_rules! gpio {
577586
}
578587

579588
/// Configures the pin to operate as an analog input pin
589+
#[inline]
580590
pub fn into_analog(self, cr: &mut $CR) -> $PXi<Analog> {
581591
unsafe {
582592
$PXi::<Analog>::set_mode(cr)
@@ -586,6 +596,7 @@ macro_rules! gpio {
586596
/// Configures the pin as a pin that can change between input
587597
/// and output without changing the type. It starts out
588598
/// as a floating input
599+
#[inline]
589600
pub fn into_dynamic(self, cr: &mut $CR) -> $PXi<Dynamic> {
590601
self.into_floating_input(cr);
591602
$PXi::<Dynamic>{mode: Dynamic::InputFloating}
@@ -606,6 +617,7 @@ macro_rules! gpio {
606617
The value of the pin after conversion is undefined. If you
607618
want to control it, use `$stateful_fn_name`
608619
*/
620+
#[inline]
609621
pub fn $fn_name(
610622
&mut self,
611623
cr: &mut $CR,
@@ -625,6 +637,7 @@ macro_rules! gpio {
625637
happens. This can cause a short output glitch if switching
626638
between output modes
627639
*/
640+
#[inline]
628641
pub fn $stateful_fn_name(
629642
&mut self,
630643
cr: &mut $CR,
@@ -648,6 +661,7 @@ macro_rules! gpio {
648661
/**
649662
Temporarily change the mode of the pin.
650663
*/
664+
#[inline]
651665
pub fn $fn_name(
652666
&mut self,
653667
cr: &mut $CR,
@@ -689,6 +703,7 @@ macro_rules! gpio {
689703

690704
impl<MODE> $PXi<MODE> where MODE: Active {
691705
/// Erases the pin number from the type
706+
#[inline]
692707
fn into_generic(self) -> Generic<MODE> {
693708
Generic {
694709
i: $i,
@@ -709,22 +724,26 @@ macro_rules! gpio {
709724

710725
impl<MODE> OutputPin for $PXi<Output<MODE>> {
711726
type Error = Infallible;
727+
#[inline]
712728
fn set_high(&mut self) -> Result<(), Self::Error> {
713729
// NOTE(unsafe) atomic write to a stateless register
714730
Ok(self.set_state(State::High))
715731
}
716732

733+
#[inline]
717734
fn set_low(&mut self) -> Result<(), Self::Error> {
718735
// NOTE(unsafe) atomic write to a stateless register
719736
Ok(self.set_state(State::Low))
720737
}
721738
}
722739

723740
impl<MODE> StatefulOutputPin for $PXi<Output<MODE>> {
741+
#[inline]
724742
fn is_set_high(&self) -> Result<bool, Self::Error> {
725743
self.is_set_low().map(|b| !b)
726744
}
727745

746+
#[inline]
728747
fn is_set_low(&self) -> Result<bool, Self::Error> {
729748
Ok(self._is_set_low())
730749
}
@@ -734,10 +753,12 @@ macro_rules! gpio {
734753

735754
impl<MODE> InputPin for $PXi<Input<MODE>> {
736755
type Error = Infallible;
756+
#[inline]
737757
fn is_high(&self) -> Result<bool, Self::Error> {
738758
self.is_low().map(|b| !b)
739759
}
740760

761+
#[inline]
741762
fn is_low(&self) -> Result<bool, Self::Error> {
742763
// NOTE(unsafe) atomic read with no side effects
743764
Ok(self._is_low())
@@ -746,10 +767,12 @@ macro_rules! gpio {
746767

747768
impl InputPin for $PXi<Output<OpenDrain>> {
748769
type Error = Infallible;
770+
#[inline]
749771
fn is_high(&self) -> Result<bool, Self::Error> {
750772
self.is_low().map(|b| !b)
751773
}
752774

775+
#[inline]
753776
fn is_low(&self) -> Result<bool, Self::Error> {
754777
Ok(self._is_low())
755778
}
@@ -759,26 +782,31 @@ macro_rules! gpio {
759782
// Dynamic pin
760783

761784
impl $PXi<Dynamic> {
785+
#[inline]
762786
pub fn make_pull_up_input(&mut self, cr: &mut $CR) {
763787
// NOTE(unsafe), we have a mutable reference to the current pin
764788
unsafe { $PXi::<Input<PullUp>>::set_mode(cr) };
765789
self.mode = Dynamic::InputPullUp;
766790
}
791+
#[inline]
767792
pub fn make_pull_down_input(&mut self, cr: &mut $CR) {
768793
// NOTE(unsafe), we have a mutable reference to the current pin
769794
unsafe { $PXi::<Input<PullDown>>::set_mode(cr) };
770795
self.mode = Dynamic::InputPullDown;
771796
}
797+
#[inline]
772798
pub fn make_floating_input(&mut self, cr: &mut $CR) {
773799
// NOTE(unsafe), we have a mutable reference to the current pin
774800
unsafe { $PXi::<Input<Floating>>::set_mode(cr) };
775801
self.mode = Dynamic::InputFloating;
776802
}
803+
#[inline]
777804
pub fn make_push_pull_output(&mut self, cr: &mut $CR) {
778805
// NOTE(unsafe), we have a mutable reference to the current pin
779806
unsafe { $PXi::<Output<PushPull>>::set_mode(cr) };
780807
self.mode = Dynamic::OutputPushPull;
781808
}
809+
#[inline]
782810
pub fn make_open_drain_output(&mut self, cr: &mut $CR) {
783811
// NOTE(unsafe), we have a mutable reference to the current pin
784812
unsafe { $PXi::<Output<OpenDrain>>::set_mode(cr) };
@@ -856,21 +884,25 @@ macro_rules! gpio {
856884
}
857885

858886
/// Enable external interrupts from this pin.
887+
#[inline]
859888
fn enable_interrupt(&mut self, exti: &EXTI) {
860889
exti.imr.modify(|r, w| unsafe { w.bits(r.bits() | (1 << $i)) });
861890
}
862891

863892
/// Disable external interrupts from this pin
893+
#[inline]
864894
fn disable_interrupt(&mut self, exti: &EXTI) {
865895
exti.imr.modify(|r, w| unsafe { w.bits(r.bits() & !(1 << $i)) });
866896
}
867897

868898
/// Clear the interrupt pending bit for this pin
899+
#[inline]
869900
fn clear_interrupt_pending_bit(&mut self) {
870901
unsafe { (*EXTI::ptr()).pr.write(|w| w.bits(1 << $i) ) };
871902
}
872903

873904
/// Reads the interrupt pending bit for this pin
905+
#[inline]
874906
fn check_interrupt(&mut self) -> bool {
875907
unsafe { ((*EXTI::ptr()).pr.read().bits() & (1 << $i)) != 0 }
876908
}

0 commit comments

Comments
 (0)