@@ -193,6 +193,17 @@ impl HrTimCalibrated {
193
193
fault_4 : FltMonitor4 { _x : PhantomData } ,
194
194
fault_5 : FltMonitor5 { _x : PhantomData } ,
195
195
fault_6 : FltMonitor6 { _x : PhantomData } ,
196
+
197
+ adc_trigger1 : Adc1Trigger { _x : PhantomData } ,
198
+ adc_trigger2 : Adc2Trigger { _x : PhantomData } ,
199
+ adc_trigger3 : Adc3Trigger { _x : PhantomData } ,
200
+ adc_trigger4 : Adc4Trigger { _x : PhantomData } ,
201
+ adc_trigger5 : Adc5Trigger { _x : PhantomData } ,
202
+ adc_trigger6 : Adc6Trigger { _x : PhantomData } ,
203
+ adc_trigger7 : Adc7Trigger { _x : PhantomData } ,
204
+ adc_trigger8 : Adc8Trigger { _x : PhantomData } ,
205
+ adc_trigger9 : Adc9Trigger { _x : PhantomData } ,
206
+ adc_trigger10 : Adc10Trigger { _x : PhantomData } ,
196
207
}
197
208
}
198
209
}
@@ -207,82 +218,90 @@ pub struct HrPwmControl {
207
218
pub fault_4 : FltMonitor4 ,
208
219
pub fault_5 : FltMonitor5 ,
209
220
pub fault_6 : FltMonitor6 ,
210
- }
211
221
212
- use super :: adc_trigger:: { Adc13Trigger , Adc24Trigger , Adc579Trigger , Adc6810Trigger } ;
222
+ pub adc_trigger1 : Adc1Trigger ,
223
+ pub adc_trigger2 : Adc2Trigger ,
224
+ pub adc_trigger3 : Adc3Trigger ,
225
+ pub adc_trigger4 : Adc4Trigger ,
226
+
227
+ pub adc_trigger5 : Adc5Trigger ,
228
+ pub adc_trigger6 : Adc6Trigger ,
229
+ pub adc_trigger7 : Adc7Trigger ,
230
+ pub adc_trigger8 : Adc8Trigger ,
231
+ pub adc_trigger9 : Adc9Trigger ,
232
+ pub adc_trigger10 : Adc10Trigger ,
233
+ }
213
234
214
- impl HrPwmControl {
215
- pub fn enable_adc_trigger1_source < T : Adc13Trigger > ( & mut self , _trigger : & T ) {
216
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
217
- unsafe {
218
- common. adc1r . modify ( |r, w| w. bits ( r. bits ( ) | T :: BITS ) ) ;
235
+ macro_rules! impl_adc1234_trigger {
236
+ ( $( $t: ident: [ $trait_: ident, $adcXr: ident, $variant345: ident $( , $variant12: ident) * ] ) ,* ) => { $(
237
+ pub struct $t {
238
+ _x: PhantomData <( ) >,
219
239
}
220
- }
221
240
222
- pub fn enable_adc_trigger2_source < T : Adc24Trigger > ( & mut self , _trigger : & T ) {
223
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
224
- unsafe {
225
- common. adc2r . modify ( |r, w| w. bits ( r. bits ( ) | T :: BITS ) ) ;
241
+ impl $t {
242
+ pub fn enable_source<T : $trait_>( & mut self , _trigger: & T ) {
243
+ let common = unsafe { & * HRTIM_COMMON :: ptr( ) } ;
244
+ unsafe {
245
+ common. $adcXr. modify( |r, w| w. bits( r. bits( ) | T :: BITS ) ) ;
246
+ }
247
+ }
248
+
249
+ $(
250
+ pub fn as_adc12_trigger( & self ) -> crate :: adc:: config:: ExternalTrigger12 {
251
+ crate :: adc:: config:: ExternalTrigger12 :: $variant12
252
+ }
253
+ ) *
254
+
255
+ pub fn as_adc345_trigger( & self ) -> crate :: adc:: config:: ExternalTrigger345 {
256
+ crate :: adc:: config:: ExternalTrigger345 :: $variant345
257
+ }
226
258
}
227
- }
259
+ ) * }
260
+ }
228
261
229
- pub fn enable_adc_trigger3_source < T : Adc13Trigger > ( & mut self , _trigger : & T ) {
230
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
231
- unsafe {
232
- common . adc3r . modify ( |r , w| w . bits ( r . bits ( ) | T :: BITS ) ) ;
262
+ macro_rules! impl_adc5678910_trigger {
263
+ ( $ ( $t : ident : [ $trait_ : ident , $adcXtrg : ident , $variant345 : ident , $variant12 : ident ] ) , * ) => { $ (
264
+ pub struct $t {
265
+ _x : PhantomData < ( ) > ,
233
266
}
234
- }
235
267
236
- pub fn enable_adc_trigger4_source < T : Adc24Trigger > ( & mut self , _trigger : & T ) {
237
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
238
- unsafe {
239
- common. adc4r . modify ( |r, w| w. bits ( r. bits ( ) | T :: BITS ) ) ;
268
+ impl $t {
269
+ pub fn enable_source<T : $trait_>( & mut self , _trigger: & T ) {
270
+ let common = unsafe { & * HRTIM_COMMON :: ptr( ) } ;
271
+ common
272
+ . adcer
273
+ . modify( |_r, w| w. $adcXtrg( ) . variant( T :: BITS as u8 ) ) ;
274
+ }
275
+
276
+ pub fn as_adc12_trigger( & self ) -> crate :: adc:: config:: ExternalTrigger12 {
277
+ crate :: adc:: config:: ExternalTrigger12 :: $variant12
278
+ }
279
+
280
+ pub fn as_adc345_trigger( & self ) -> crate :: adc:: config:: ExternalTrigger345 {
281
+ crate :: adc:: config:: ExternalTrigger345 :: $variant345
282
+ }
240
283
}
241
- }
242
-
243
- pub fn enable_adc_trigger5_source < T : Adc579Trigger > ( & mut self , _trigger : & T ) {
244
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
245
- common
246
- . adcer
247
- . modify ( |_r, w| w. adc5trg ( ) . variant ( T :: BITS as u8 ) ) ;
248
- }
249
-
250
- pub fn enable_adc_trigger6_source < T : Adc6810Trigger > ( & mut self , _trigger : & T ) {
251
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
252
- common
253
- . adcer
254
- . modify ( |_r, w| w. adc6trg ( ) . variant ( T :: BITS as u8 ) ) ;
255
- }
256
-
257
- pub fn enable_adc_trigger7_source < T : Adc579Trigger > ( & mut self , _trigger : & T ) {
258
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
259
- common
260
- . adcer
261
- . modify ( |_r, w| w. adc7trg ( ) . variant ( T :: BITS as u8 ) ) ;
262
- }
263
-
264
- pub fn enable_adc_trigger8_source < T : Adc6810Trigger > ( & mut self , _trigger : & T ) {
265
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
266
- common
267
- . adcer
268
- . modify ( |_r, w| w. adc8trg ( ) . variant ( T :: BITS as u8 ) ) ;
269
- }
284
+ ) * }
285
+ }
270
286
271
- pub fn enable_adc_trigger9_source < T : Adc579Trigger > ( & mut self , _trigger : & T ) {
272
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
273
- common
274
- . adcer
275
- . modify ( |_r , w| w . adc9trg ( ) . variant ( T :: BITS as u8 ) ) ;
276
- }
287
+ impl_adc1234_trigger ! { // reg adc345, adc12
288
+ Adc1Trigger : [ Adc13Trigger , adc1r , Hrtim_adc_trg_1 , Hrtim_adc_trg_1 ] ,
289
+ Adc2Trigger : [ Adc24Trigger , adc2r , Hrtim_adc_trg_2 ] ,
290
+ Adc3Trigger : [ Adc13Trigger , adc3r , Hrtim_adc_trg_3 , Hrtim_adc_trg_3 ] ,
291
+ Adc4Trigger : [ Adc24Trigger , adc4r , Hrtim_adc_trg_4 ]
292
+ }
277
293
278
- pub fn enable_adc_trigger10_source < T : Adc6810Trigger > ( & mut self , _trigger : & T ) {
279
- let common = unsafe { & * HRTIM_COMMON :: ptr ( ) } ;
280
- common
281
- . adcer
282
- . modify ( |_r, w| w. adc10trg ( ) . variant ( T :: BITS as u8 ) ) ;
283
- }
294
+ impl_adc5678910_trigger ! {
295
+ Adc5Trigger : [ Adc579Trigger , adc5trg, Hrtim_adc_trg_5 , Hrtim_adc_trg_5 ] ,
296
+ Adc6Trigger : [ Adc6810Trigger , adc6trg, Hrtim_adc_trg_6 , Hrtim_adc_trg_6 ] ,
297
+ Adc7Trigger : [ Adc579Trigger , adc7trg, Hrtim_adc_trg_7 , Hrtim_adc_trg_7 ] ,
298
+ Adc8Trigger : [ Adc6810Trigger , adc8trg, Hrtim_adc_trg_8 , Hrtim_adc_trg_8 ] ,
299
+ Adc9Trigger : [ Adc579Trigger , adc9trg, Hrtim_adc_trg_9 , Hrtim_adc_trg_9 ] ,
300
+ Adc10Trigger : [ Adc6810Trigger , adc10trg, Hrtim_adc_trg_10 , Hrtim_adc_trg_10 ]
284
301
}
285
302
303
+ use super :: adc_trigger:: { Adc13Trigger , Adc24Trigger , Adc579Trigger , Adc6810Trigger } ;
304
+
286
305
pub enum AdcTriggerPostscaler {
287
306
None = 0 ,
288
307
Div2 = 1 ,
0 commit comments