@@ -47,6 +47,27 @@ pub trait HrTimer {
47
47
fn as_period_adc_trigger ( & self ) -> super :: adc_trigger:: TimerPeriod < Self :: Timer > ;
48
48
}
49
49
50
+ pub trait HrSlaveTimer : HrTimer
51
+ {
52
+ type CaptureCh1 : super :: capture:: HrCapture ;
53
+ type CaptureCh2 : super :: capture:: HrCapture ;
54
+
55
+ /// Start listening to the specified event
56
+ fn enable_reset_event < E : super :: event:: TimerResetEventSource < Self :: Timer , Self :: Prescaler > > (
57
+ & mut self ,
58
+ _event : & E ,
59
+ ) ;
60
+
61
+ /// Stop listening to the specified event
62
+ fn disable_reset_event < E : super :: event:: TimerResetEventSource < Self :: Timer , Self :: Prescaler > > (
63
+ & mut self ,
64
+ _event : & E ,
65
+ ) ;
66
+
67
+ fn capture_ch1 ( & mut self ) -> & mut Self :: CaptureCh1 ;
68
+ fn capture_ch2 ( & mut self ) -> & mut Self :: CaptureCh2 ;
69
+ }
70
+
50
71
macro_rules! hrtim_timer {
51
72
( $(
52
73
$TIMX: ident:
@@ -135,8 +156,11 @@ macro_rules! hrtim_timer {
135
156
}
136
157
}
137
158
138
- $( // Only for Non-Master timers
139
- impl <PSCL > HrTim <$TIMX, PSCL > {
159
+ $(
160
+ impl <PSCL > HrSlaveTimer for HrTim <$TIMX, PSCL > {
161
+ type CaptureCh1 = HrCapt <Self :: Timer , Self :: Prescaler , capture:: Ch1 >;
162
+ type CaptureCh2 = HrCapt <Self :: Timer , Self :: Prescaler , capture:: Ch2 >;
163
+
140
164
/// Reset this timer every time the specified event occurs
141
165
///
142
166
/// Behaviour depends on `timer_mode`:
@@ -152,20 +176,31 @@ macro_rules! hrtim_timer {
152
176
/// * `HrTimerMode::Continuous`: Enabling the timer enables and starts it simultaneously.
153
177
/// When the counter reaches the PER value, it rolls-over to 0x0000 and resumes counting.
154
178
/// The counter can be reset at any time
155
- pub fn enable_reset_event<E : super :: event:: TimerResetEventSource <$TIMX , PSCL >>( & mut self , _event: & E ) {
179
+ fn enable_reset_event<E : super :: event:: TimerResetEventSource <Self :: Timer , Self :: Prescaler >>( & mut self , _event: & E ) {
156
180
let tim = unsafe { & * $TIMX:: ptr( ) } ;
157
181
158
182
unsafe { tim. $rstXr. modify( |r, w| w. bits( r. bits( ) | E :: BITS ) ) ; }
159
183
}
160
184
161
185
/// Stop listening to the specified event
162
- pub fn disable_reset_event<E : super :: event:: TimerResetEventSource <$TIMX , PSCL >>( & mut self , _event: & E ) {
186
+ fn disable_reset_event<E : super :: event:: TimerResetEventSource <Self :: Timer , Self :: Prescaler >>( & mut self , _event: & E ) {
163
187
let tim = unsafe { & * $TIMX:: ptr( ) } ;
164
188
165
189
unsafe { tim. $rstXr. modify( |r, w| w. bits( r. bits( ) & !E :: BITS ) ) ; }
166
190
}
191
+
192
+ /// Access the timers first capture channel
193
+ fn capture_ch1( & mut self ) -> & mut Self :: CaptureCh1 {
194
+ & mut self . capture_ch1
195
+ }
196
+
197
+ /// Access the timers second capture channel
198
+ fn capture_ch2( & mut self ) -> & mut Self :: CaptureCh2 {
199
+ & mut self . capture_ch2
200
+ }
167
201
}
168
202
203
+
169
204
/// Timer Period event
170
205
impl <DST , PSCL > super :: event:: EventSource <DST , PSCL > for HrTim <$TIMX, PSCL > {
171
206
// $rstXr
@@ -228,16 +263,6 @@ hrtim_timer_adc_trigger! {
228
263
HRTIM_TIMF : [ ( Adc13 : [ ( PER : 1 << 24 ) , ( RST : 1 << 28 ) ] ) , ( Adc24 : [ ( PER : 1 << 24 ) , ] ) , ( Adc579 : [ ( PER : 30 ) , ( RST : 31 ) ] ) , ( Adc6810 : [ ( PER : 31 ) , ] ) ]
229
264
}
230
265
231
- impl < TIM , PSCL > HrTim < TIM , PSCL > {
232
- pub fn capture_ch1 ( & mut self ) -> & mut HrCapt < TIM , PSCL , capture:: Ch1 > {
233
- & mut self . capture_ch1
234
- }
235
-
236
- pub fn capture_ch2 ( & mut self ) -> & mut HrCapt < TIM , PSCL , capture:: Ch2 > {
237
- & mut self . capture_ch2
238
- }
239
- }
240
-
241
266
/// Master Timer Period event
242
267
impl < DST , PSCL > super :: event:: TimerResetEventSource < DST , PSCL > for HrTim < HRTIM_MASTER , PSCL > {
243
268
const BITS : u32 = 1 << 4 ; // MSTPER
0 commit comments