@@ -748,15 +748,7 @@ where
748
748
}
749
749
750
750
/// Consumes `self` and returns back the raw peripheral.
751
- pub fn free (
752
- self ,
753
- ) -> (
754
- T ,
755
- Option < Pin < Output < PushPull > > > ,
756
- Option < Pin < Output < PushPull > > > ,
757
- Option < Pin < Output < PushPull > > > ,
758
- Option < Pin < Output < PushPull > > > ,
759
- ) {
751
+ pub fn free ( self ) -> ( T , Pins ) {
760
752
let ch0 = self . pwm . psel . out [ 0 ] . read ( ) ;
761
753
let ch1 = self . pwm . psel . out [ 1 ] . read ( ) ;
762
754
let ch2 = self . pwm . psel . out [ 2 ] . read ( ) ;
@@ -767,30 +759,44 @@ where
767
759
self . pwm . psel . out [ 3 ] . reset ( ) ;
768
760
(
769
761
self . pwm ,
770
- if ch0. connect ( ) . bit_is_set ( ) {
771
- Some ( unsafe { Pin :: from_psel_bits ( ch0. bits ( ) ) } )
772
- } else {
773
- None
774
- } ,
775
- if ch1. connect ( ) . bit_is_set ( ) {
776
- Some ( unsafe { Pin :: from_psel_bits ( ch1. bits ( ) ) } )
777
- } else {
778
- None
779
- } ,
780
- if ch2. connect ( ) . bit_is_set ( ) {
781
- Some ( unsafe { Pin :: from_psel_bits ( ch2. bits ( ) ) } )
782
- } else {
783
- None
784
- } ,
785
- if ch3. connect ( ) . bit_is_set ( ) {
786
- Some ( unsafe { Pin :: from_psel_bits ( ch3. bits ( ) ) } )
787
- } else {
788
- None
762
+ Pins {
763
+ ch0 : if ch0. connect ( ) . bit_is_set ( ) {
764
+ Some ( unsafe { Pin :: from_psel_bits ( ch0. bits ( ) ) } )
765
+ } else {
766
+ None
767
+ } ,
768
+ ch1 : if ch1. connect ( ) . bit_is_set ( ) {
769
+ Some ( unsafe { Pin :: from_psel_bits ( ch1. bits ( ) ) } )
770
+ } else {
771
+ None
772
+ } ,
773
+ ch2 : if ch2. connect ( ) . bit_is_set ( ) {
774
+ Some ( unsafe { Pin :: from_psel_bits ( ch2. bits ( ) ) } )
775
+ } else {
776
+ None
777
+ } ,
778
+ ch3 : if ch3. connect ( ) . bit_is_set ( ) {
779
+ Some ( unsafe { Pin :: from_psel_bits ( ch3. bits ( ) ) } )
780
+ } else {
781
+ None
782
+ } ,
789
783
} ,
790
784
)
791
785
}
792
786
}
793
787
788
+ /// Pins for the Pwm
789
+ pub struct Pins {
790
+ /// Channel 0 pin, `None` if it was unused
791
+ pub ch0 : Option < Pin < Output < PushPull > > > ,
792
+ /// Channel 1 pin, `None` if it was unused
793
+ pub ch1 : Option < Pin < Output < PushPull > > > ,
794
+ /// Channel 2 pin, `None` if it was unused
795
+ pub ch2 : Option < Pin < Output < PushPull > > > ,
796
+ /// Channel 3 pin, `None` if it was unused
797
+ pub ch3 : Option < Pin < Output < PushPull > > > ,
798
+ }
799
+
794
800
/// A Pwm sequence wrapper
795
801
#[ derive( Debug ) ]
796
802
pub struct PwmSeq < T : Instance , B0 , B1 > {
0 commit comments