@@ -71,23 +71,25 @@ pub struct DmaInterrupts {
71
71
}
72
72
73
73
/// Alias for a tuple with all DMA channels.
74
- pub struct ChannelsTuple < T > (
75
- pub Channel1 < T > ,
76
- pub Channel2 < T > ,
77
- pub Channel3 < T > ,
78
- pub Channel4 < T > ,
79
- pub Channel5 < T > ,
80
- pub Channel6 < T > ,
81
- #[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ] pub Channel7 < T > ,
82
- #[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ] pub Channel8 < T > ,
83
- ) ;
74
+ pub struct Channels < T > {
75
+ pub ch1 : Channel1 < T > ,
76
+ pub ch2 : Channel2 < T > ,
77
+ pub ch3 : Channel3 < T > ,
78
+ pub ch4 : Channel4 < T > ,
79
+ pub ch5 : Channel5 < T > ,
80
+ pub ch6 : Channel6 < T > ,
81
+ #[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ]
82
+ pub ch7 : Channel7 < T > ,
83
+ #[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ]
84
+ pub ch8 : Channel8 < T > ,
85
+ }
84
86
85
87
pub trait DMAExt < I > {
86
- fn split ( self , rcc : & Rcc ) -> ChannelsTuple < I > ;
88
+ fn split ( self , rcc : & Rcc ) -> Channels < I > ;
87
89
}
88
90
89
91
impl DMAExt < Self > for DMA1 {
90
- fn split ( self , rcc : & Rcc ) -> ChannelsTuple < DMA1 > {
92
+ fn split ( self , rcc : & Rcc ) -> Channels < DMA1 > {
91
93
// Enable DMAMux is not yet enabled
92
94
if !rcc. rb . ahb1enr ( ) . read ( ) . dmamuxen ( ) . bit_is_set ( ) {
93
95
// Enable peripheral
@@ -97,12 +99,12 @@ impl DMAExt<Self> for DMA1 {
97
99
// Enable peripheral
98
100
rcc. rb . ahb1enr ( ) . modify ( |_, w| w. dma1en ( ) . set_bit ( ) ) ;
99
101
100
- ChannelsTuple :: new ( self )
102
+ Channels :: new ( self )
101
103
}
102
104
}
103
105
104
106
impl DMAExt < Self > for DMA2 {
105
- fn split ( self , rcc : & Rcc ) -> ChannelsTuple < DMA2 > {
107
+ fn split ( self , rcc : & Rcc ) -> Channels < DMA2 > {
106
108
// Enable DMAMux is not yet enabled
107
109
if !rcc. rb . ahb1enr ( ) . read ( ) . dmamuxen ( ) . bit_is_set ( ) {
108
110
// Enable peripheral
@@ -112,25 +114,25 @@ impl DMAExt<Self> for DMA2 {
112
114
// Enable peripheral
113
115
rcc. rb . ahb1enr ( ) . modify ( |_, w| w. dma2en ( ) . set_bit ( ) ) ;
114
116
115
- ChannelsTuple :: new ( self )
117
+ Channels :: new ( self )
116
118
}
117
119
}
118
120
119
- impl < I : Instance > ChannelsTuple < I > {
121
+ impl < I : Instance > Channels < I > {
120
122
/// Splits the DMA peripheral into channels.
121
123
pub ( crate ) fn new ( _regs : I ) -> Self {
122
- Self (
123
- Channel1 { _dma : PhantomData } ,
124
- Channel2 { _dma : PhantomData } ,
125
- Channel3 { _dma : PhantomData } ,
126
- Channel4 { _dma : PhantomData } ,
127
- Channel5 { _dma : PhantomData } ,
128
- Channel6 { _dma : PhantomData } ,
124
+ Self {
125
+ ch1 : Channel1 { _dma : PhantomData } ,
126
+ ch2 : Channel2 { _dma : PhantomData } ,
127
+ ch3 : Channel3 { _dma : PhantomData } ,
128
+ ch4 : Channel4 { _dma : PhantomData } ,
129
+ ch5 : Channel5 { _dma : PhantomData } ,
130
+ ch6 : Channel6 { _dma : PhantomData } ,
129
131
#[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ]
130
- Channel7 { _dma : PhantomData } ,
132
+ ch7 : Channel7 { _dma : PhantomData } ,
131
133
#[ cfg( not( any( feature = "stm32g431" , feature = "stm32g441" , ) ) ) ]
132
- Channel8 { _dma : PhantomData } ,
133
- )
134
+ ch8 : Channel8 { _dma : PhantomData } ,
135
+ }
134
136
}
135
137
}
136
138
0 commit comments