@@ -47,6 +47,27 @@ pub trait HrTimer {
4747 fn as_period_adc_trigger ( & self ) -> super :: adc_trigger:: TimerPeriod < Self :: Timer > ;
4848}
4949
50+ pub trait HrSlaveTimer : HrTimer
51+ where
52+ HrCapt < Self :: Timer , Self :: Prescaler , capture:: Ch1 > : super :: capture:: HrCapture ,
53+ HrCapt < Self :: Timer , Self :: Prescaler , capture:: Ch2 > : 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 HrCapt < Self :: Timer , Self :: Prescaler , capture:: Ch1 > ;
68+ fn capture_ch2 ( & mut self ) -> & mut HrCapt < Self :: Timer , Self :: Prescaler , capture:: Ch2 > ;
69+ }
70+
5071macro_rules! hrtim_timer {
5172 ( $(
5273 $TIMX: ident:
@@ -135,8 +156,8 @@ macro_rules! hrtim_timer {
135156 }
136157 }
137158
138- $( // Only for Non-Master timers
139- impl <PSCL > HrTim <$TIMX, PSCL > {
159+ $(
160+ impl <PSCL > HrSlaveTimer for HrTim <$TIMX, PSCL > {
140161 /// Reset this timer every time the specified event occurs
141162 ///
142163 /// Behaviour depends on `timer_mode`:
@@ -152,20 +173,31 @@ macro_rules! hrtim_timer {
152173 /// * `HrTimerMode::Continuous`: Enabling the timer enables and starts it simultaneously.
153174 /// When the counter reaches the PER value, it rolls-over to 0x0000 and resumes counting.
154175 /// The counter can be reset at any time
155- pub fn enable_reset_event<E : super :: event:: TimerResetEventSource <$TIMX , PSCL >>( & mut self , _event: & E ) {
176+ fn enable_reset_event<E : super :: event:: TimerResetEventSource <Self :: Timer , Self :: Prescaler >>( & mut self , _event: & E ) {
156177 let tim = unsafe { & * $TIMX:: ptr( ) } ;
157178
158179 unsafe { tim. $rstXr. modify( |r, w| w. bits( r. bits( ) | E :: BITS ) ) ; }
159180 }
160181
161182 /// Stop listening to the specified event
162- pub fn disable_reset_event<E : super :: event:: TimerResetEventSource <$TIMX , PSCL >>( & mut self , _event: & E ) {
183+ fn disable_reset_event<E : super :: event:: TimerResetEventSource <Self :: Timer , Self :: Prescaler >>( & mut self , _event: & E ) {
163184 let tim = unsafe { & * $TIMX:: ptr( ) } ;
164185
165186 unsafe { tim. $rstXr. modify( |r, w| w. bits( r. bits( ) & !E :: BITS ) ) ; }
166187 }
188+
189+ /// Access the timers first capture channel
190+ fn capture_ch1( & mut self ) -> & mut HrCapt <Self :: Timer , Self :: Prescaler , capture:: Ch1 > {
191+ & mut self . capture_ch1
192+ }
193+
194+ /// Access the timers second capture channel
195+ fn capture_ch2( & mut self ) -> & mut HrCapt <Self :: Timer , Self :: Prescaler , capture:: Ch2 > {
196+ & mut self . capture_ch2
197+ }
167198 }
168199
200+
169201 /// Timer Period event
170202 impl <DST , PSCL > super :: event:: EventSource <DST , PSCL > for HrTim <$TIMX, PSCL > {
171203 // $rstXr
@@ -228,16 +260,6 @@ hrtim_timer_adc_trigger! {
228260 HRTIM_TIMF : [ ( Adc13 : [ ( PER : 1 << 24 ) , ( RST : 1 << 28 ) ] ) , ( Adc24 : [ ( PER : 1 << 24 ) , ] ) , ( Adc579 : [ ( PER : 30 ) , ( RST : 31 ) ] ) , ( Adc6810 : [ ( PER : 31 ) , ] ) ]
229261}
230262
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-
241263/// Master Timer Period event
242264impl < DST , PSCL > super :: event:: TimerResetEventSource < DST , PSCL > for HrTim < HRTIM_MASTER , PSCL > {
243265 const BITS : u32 = 1 << 4 ; // MSTPER
0 commit comments