@@ -51,6 +51,26 @@ pub enum Event {
51
51
TimeOut ,
52
52
}
53
53
54
+ /// Trigger output source
55
+ pub enum TriggerSource {
56
+ /// Timer reset - UG as trigger output
57
+ Reset ,
58
+ /// Timer enable - CNT_EN as trigger output
59
+ Enable = 0b001 ,
60
+ /// Update event - Update event as trigger output
61
+ Update = 0b010 ,
62
+ /// Compare Pulse - Positive pulse if CC1IF is setted
63
+ ComparePulse = 0b011 ,
64
+ /// Compare1 - OC1REFC as trigger output
65
+ Compare1 = 0b100 ,
66
+ /// Compare2 - OC2REFC as trigger output
67
+ Compare2 = 0b101 ,
68
+ /// Compare3 - OC3REFC as trigger output
69
+ Compare3 = 0b110 ,
70
+ /// Compare4 - OC4REFC as trigger output
71
+ Compare4 = 0b111 ,
72
+ }
73
+
54
74
#[ derive( Debug , Eq , PartialEq , Copy , Clone ) ]
55
75
pub enum Error {
56
76
/// CountDownTimer is disabled
@@ -207,6 +227,18 @@ where
207
227
}
208
228
}
209
229
230
+ macro_rules! hal_ext_trgo {
231
+ ( $( $TIM: ty: ( $tim: ident, $mms: ident) , ) +) => {
232
+ $(
233
+ impl Timer <$TIM> {
234
+ pub fn set_trigger_source( & mut self , trigger_source: TriggerSource ) {
235
+ self . tim. cr2. modify( |_, w| unsafe { w. $mms( ) . bits( trigger_source as u8 ) } ) ;
236
+ }
237
+ }
238
+ ) +
239
+ }
240
+ }
241
+
210
242
macro_rules! hal {
211
243
( $( $TIM: ty: ( $tim: ident) , ) +) => {
212
244
$(
@@ -338,6 +370,18 @@ hal! {
338
370
crate :: stm32:: TIM17 : ( tim17) ,
339
371
}
340
372
373
+ hal_ext_trgo ! {
374
+ crate :: stm32:: TIM1 : ( tim1, mms2) ,
375
+ crate :: stm32:: TIM2 : ( tim2, mms2) ,
376
+ crate :: stm32:: TIM3 : ( tim3, mms2) ,
377
+ crate :: stm32:: TIM4 : ( tim4, mms2) ,
378
+ crate :: stm32:: TIM6 : ( tim6, mms) ,
379
+ crate :: stm32:: TIM7 : ( tim7, mms) ,
380
+ crate :: stm32:: TIM8 : ( tim8, mms2) ,
381
+
382
+ crate :: stm32:: TIM15 : ( tim15, mms) ,
383
+ }
384
+
341
385
#[ cfg( any(
342
386
feature = "stm32g471" ,
343
387
feature = "stm32g473" ,
0 commit comments