@@ -357,6 +357,7 @@ where
357
357
Index : marker:: Index ,
358
358
{
359
359
/// Configures the pin to operate as an input pin
360
+ #[ inline]
360
361
pub fn into_input ( self ) -> Pin < Gpio , Index , Input > {
361
362
// NOTE(unsafe) atomic modify with no side effects
362
363
unsafe { ( * self . gpio . ptr ( ) ) . input ( self . index . index ( ) ) } ;
@@ -365,6 +366,7 @@ where
365
366
366
367
/// Convenience method to configure the pin to operate as an input pin
367
368
/// and set the internal resistor floating
369
+ #[ inline]
368
370
pub fn into_floating_input ( self ) -> Pin < Gpio , Index , Input > {
369
371
// NOTE(unsafe) atomic modify with no side effects
370
372
unsafe {
@@ -376,6 +378,7 @@ where
376
378
377
379
/// Convenience method to configure the pin to operate as an input pin
378
380
/// and set the internal resistor pull-up
381
+ #[ inline]
379
382
pub fn into_pull_up_input ( self ) -> Pin < Gpio , Index , Input > {
380
383
// NOTE(unsafe) atomic modify with no side effects
381
384
unsafe {
@@ -387,6 +390,7 @@ where
387
390
388
391
/// Convenience method to configure the pin to operate as an input pin
389
392
/// and set the internal resistor pull-down
393
+ #[ inline]
390
394
pub fn into_pull_down_input ( self ) -> Pin < Gpio , Index , Input > {
391
395
// NOTE(unsafe) atomic modify with no side effects
392
396
unsafe {
@@ -397,6 +401,7 @@ where
397
401
}
398
402
399
403
/// Configures the pin to operate as a push-pull output pin
404
+ #[ inline]
400
405
pub fn into_push_pull_output ( self ) -> Pin < Gpio , Index , Output < PushPull > > {
401
406
// NOTE(unsafe) atomic modify with no side effects
402
407
unsafe {
@@ -407,6 +412,7 @@ where
407
412
}
408
413
409
414
/// Configures the pin to operate as an open-drain output pin
415
+ #[ inline]
410
416
pub fn into_open_drain_output ( self ) -> Pin < Gpio , Index , Output < OpenDrain > > {
411
417
// NOTE(unsafe) atomic modify with no side effects
412
418
unsafe {
@@ -417,6 +423,7 @@ where
417
423
}
418
424
419
425
/// Configures the pin to operate as an alternate function push-pull output pin
426
+ #[ inline]
420
427
pub fn into_af_push_pull < const A : u8 > ( self ) -> Pin < Gpio , Index , Alternate < PushPull , A > >
421
428
where
422
429
Self : marker:: IntoAf < A > ,
@@ -431,6 +438,7 @@ where
431
438
}
432
439
433
440
/// Configures the pin to operate as an alternate function open-drain output pin
441
+ #[ inline]
434
442
pub fn into_af_open_drain < const A : u8 > ( self ) -> Pin < Gpio , Index , Alternate < OpenDrain , A > >
435
443
where
436
444
Self : marker:: IntoAf < A > ,
@@ -445,6 +453,7 @@ where
445
453
}
446
454
447
455
/// Configures the pin to operate as an analog pin, with disabled schmitt trigger.
456
+ #[ inline]
448
457
pub fn into_analog ( self ) -> Pin < Gpio , Index , Analog > {
449
458
// NOTE(unsafe) atomic modify with no side effects
450
459
unsafe {
@@ -510,6 +519,7 @@ where
510
519
Mode : marker:: OutputSpeed ,
511
520
{
512
521
/// Set pin output slew rate
522
+ #[ inline]
513
523
pub fn set_speed ( & mut self , speed : Speed ) {
514
524
// NOTE(unsafe) atomic modify with no side effects
515
525
match speed {
@@ -527,6 +537,7 @@ where
527
537
Mode : marker:: Active ,
528
538
{
529
539
/// Set the internal pull-up and pull-down resistor
540
+ #[ inline]
530
541
pub fn set_internal_resistor ( & mut self , resistor : Resistor ) {
531
542
// NOTE(unsafe) atomic modify with no side effects
532
543
match resistor {
@@ -537,6 +548,7 @@ where
537
548
}
538
549
539
550
/// Enables / disables the internal pull up (Provided for compatibility with other stm32 HALs)
551
+ #[ inline]
540
552
pub fn internal_pull_up ( & mut self , on : bool ) {
541
553
self . set_internal_resistor ( match on {
542
554
true => Resistor :: PullUp ,
@@ -552,12 +564,14 @@ where
552
564
{
553
565
type Error = Infallible ;
554
566
567
+ #[ inline]
555
568
fn set_high ( & mut self ) -> Result < ( ) , Self :: Error > {
556
569
// NOTE(unsafe) atomic write to a stateless register
557
570
unsafe { ( * self . gpio . ptr ( ) ) . set_high ( self . index . index ( ) ) } ;
558
571
Ok ( ( ) )
559
572
}
560
573
574
+ #[ inline]
561
575
fn set_low ( & mut self ) -> Result < ( ) , Self :: Error > {
562
576
// NOTE(unsafe) atomic write to a stateless register
563
577
unsafe { ( * self . gpio . ptr ( ) ) . set_low ( self . index . index ( ) ) } ;
@@ -573,10 +587,12 @@ where
573
587
{
574
588
type Error = Infallible ;
575
589
590
+ #[ inline]
576
591
fn is_high ( & self ) -> Result < bool , Self :: Error > {
577
592
Ok ( !self . is_low ( ) ?)
578
593
}
579
594
595
+ #[ inline]
580
596
fn is_low ( & self ) -> Result < bool , Self :: Error > {
581
597
// NOTE(unsafe) atomic read with no side effects
582
598
Ok ( unsafe { ( * self . gpio . ptr ( ) ) . is_low ( self . index . index ( ) ) } )
@@ -588,10 +604,12 @@ where
588
604
Gpio : marker:: Gpio ,
589
605
Index : marker:: Index ,
590
606
{
607
+ #[ inline]
591
608
fn is_set_high ( & self ) -> Result < bool , Self :: Error > {
592
609
Ok ( !self . is_set_low ( ) ?)
593
610
}
594
611
612
+ #[ inline]
595
613
fn is_set_low ( & self ) -> Result < bool , Self :: Error > {
596
614
// NOTE(unsafe) atomic read with no side effects
597
615
Ok ( unsafe { ( * self . gpio . ptr ( ) ) . is_set_low ( self . index . index ( ) ) } )
@@ -635,6 +653,7 @@ where
635
653
/// This is also useful for all other [`cortex_m::peripheral::NVIC`] functions.
636
654
// TODO(Sh3rm4n): It would be cool to have this either const or have a const function.
637
655
// But this is currenlty not possible, because index() is runtime defined.
656
+ #[ inline]
638
657
pub fn interrupt ( & self ) -> Interrupt {
639
658
match self . index . index ( ) {
640
659
0 => Interrupt :: EXTI0 ,
@@ -655,6 +674,7 @@ where
655
674
}
656
675
657
676
/// Generate interrupt on rising edge, falling edge, or both
677
+ #[ inline]
658
678
pub fn trigger_on_edge ( & mut self , exti : & mut EXTI , edge : Edge ) {
659
679
const BITWIDTH : u8 = 1 ;
660
680
let index = self . index . index ( ) ;
@@ -676,6 +696,7 @@ where
676
696
///
677
697
/// Remeber to also configure the interrupt pin on
678
698
/// the SysCfg site, with [`crate::syscfg::SysCfg::select_exti_interrupt_source()`]
699
+ #[ inline]
679
700
pub fn configure_interrupt ( & mut self , exti : & mut EXTI , enable : impl Into < Toggle > ) {
680
701
const BITWIDTH : u8 = 1 ;
681
702
@@ -694,22 +715,26 @@ where
694
715
///
695
716
/// Remeber to also configure the interrupt pin on
696
717
/// the SysCfg site, with [`crate::syscfg::SysCfg::select_exti_interrupt_source()`]
718
+ #[ inline]
697
719
pub fn enable_interrupt ( & mut self , exti : & mut EXTI ) {
698
720
self . configure_interrupt ( exti, Toggle :: On )
699
721
}
700
722
701
723
/// Disable external interrupts from this pin
724
+ #[ inline]
702
725
pub fn disable_interrupt ( & mut self , exti : & mut EXTI ) {
703
726
self . configure_interrupt ( exti, Toggle :: Off )
704
727
}
705
728
706
729
/// Clear the interrupt pending bit for this pin
730
+ #[ inline]
707
731
pub fn clear_interrupt ( & mut self ) {
708
732
// SAFETY: Atomic write to register without side-effects.
709
733
unsafe { reg_for_cpu ! ( ( * EXTI :: ptr( ) ) , pr) . write ( |w| w. bits ( 1 << self . index . index ( ) ) ) } ;
710
734
}
711
735
712
736
/// Reads the interrupt pending bit for this pin
737
+ #[ inline]
713
738
pub fn is_interrupt_pending ( & self ) -> bool {
714
739
// SAFETY: Atomic write to register without side-effects.
715
740
unsafe { reg_for_cpu ! ( ( * EXTI :: ptr( ) ) , pr) . read ( ) . bits ( ) & ( 1 << self . index . index ( ) ) != 0 }
0 commit comments