4
4
5
5
#[ cfg( feature = "9160" ) ]
6
6
use crate :: pac:: {
7
- timer0_ns:: RegisterBlock as RegBlock0 , Interrupt , TIMER0_NS as TIMER0 , TIMER1_NS as TIMER1 ,
8
- TIMER2_NS as TIMER2 ,
7
+ generic:: Reg ,
8
+ timer0_ns:: {
9
+ RegisterBlock as RegBlock0 , _EVENTS_COMPARE, _TASKS_CAPTURE, _TASKS_CLEAR, _TASKS_COUNT,
10
+ _TASKS_START, _TASKS_STOP,
11
+ } ,
12
+ Interrupt , TIMER0_NS as TIMER0 , TIMER1_NS as TIMER1 , TIMER2_NS as TIMER2 ,
9
13
} ;
10
14
11
15
#[ cfg( not( feature = "9160" ) ) ]
12
- use crate :: pac:: { timer0:: RegisterBlock as RegBlock0 , Interrupt , TIMER0 , TIMER1 , TIMER2 } ;
13
-
16
+ use crate :: pac:: {
17
+ generic:: Reg ,
18
+ timer0:: {
19
+ RegisterBlock as RegBlock0 , _EVENTS_COMPARE, _TASKS_CAPTURE, _TASKS_CLEAR, _TASKS_COUNT,
20
+ _TASKS_START, _TASKS_STOP,
21
+ } ,
22
+ Interrupt , TIMER0 , TIMER1 , TIMER2 ,
23
+ } ;
14
24
use cast:: u32;
15
25
use embedded_hal:: {
16
26
blocking:: delay:: { DelayMs , DelayUs } ,
@@ -25,12 +35,16 @@ use crate::pac::{TIMER3, TIMER4};
25
35
26
36
// The 832 and 840 expose TIMER3 and TIMER for as timer3::RegisterBlock...
27
37
#[ cfg( any( feature = "52832" , feature = "52840" ) ) ]
28
- use crate :: pac:: timer3:: RegisterBlock as RegBlock3 ;
38
+ use crate :: pac:: timer3:: {
39
+ RegisterBlock as RegBlock3 , _EVENTS_COMPARE as EventsCompare3 , _TASKS_CAPTURE as TasksCapture3 ,
40
+ } ;
29
41
30
42
// ...but the 833 exposes them as timer0::RegisterBlock. This might be a bug
31
43
// in the PAC, and could be fixed later. For now, it is equivalent anyway.
32
44
#[ cfg( feature = "52833" ) ]
33
- use crate :: pac:: timer0:: RegisterBlock as RegBlock3 ;
45
+ use crate :: pac:: timer0:: {
46
+ RegisterBlock as RegBlock3 , _EVENTS_COMPARE as EventsCompare3 , _TASKS_CAPTURE as TasksCapture3 ,
47
+ } ;
34
48
35
49
use core:: marker:: PhantomData ;
36
50
@@ -135,6 +149,94 @@ where
135
149
Err ( x) => unreachable ( x) ,
136
150
}
137
151
}
152
+
153
+ /// Returns reference to the `START` task endpoint for PPI.
154
+ /// Starts timer.
155
+ #[ inline( always) ]
156
+ pub fn task_start ( & self ) -> & Reg < u32 , _TASKS_START > {
157
+ & self . 0 . as_timer0 ( ) . tasks_start
158
+ }
159
+
160
+ /// Returns reference to the `STOP` task endpoint for PPI.
161
+ /// Stops timer.
162
+ #[ inline( always) ]
163
+ pub fn task_stop ( & self ) -> & Reg < u32 , _TASKS_STOP > {
164
+ & self . 0 . as_timer0 ( ) . tasks_stop
165
+ }
166
+
167
+ /// Returns reference to the `COUNT` task endpoint for PPI.
168
+ /// Increments timer (counter mode only).
169
+ #[ inline( always) ]
170
+ pub fn task_count ( & self ) -> & Reg < u32 , _TASKS_COUNT > {
171
+ & self . 0 . as_timer0 ( ) . tasks_count
172
+ }
173
+
174
+ /// Returns reference to the `CLEAR` task endpoint for PPI.
175
+ /// Clears timer.
176
+ #[ inline( always) ]
177
+ pub fn task_clear ( & self ) -> & Reg < u32 , _TASKS_CLEAR > {
178
+ & self . 0 . as_timer0 ( ) . tasks_clear
179
+ }
180
+
181
+ /// Returns reference to the CC[0] `CAPTURE` task endpoint for PPI.
182
+ /// Captures timer value to the CC[0] register.
183
+ #[ inline( always) ]
184
+ pub fn task_capture_cc0 ( & self ) -> & Reg < u32 , _TASKS_CAPTURE > {
185
+ & self . 0 . as_timer0 ( ) . tasks_capture [ 0 ]
186
+ }
187
+
188
+ /// Returns reference to the CC[1] `CAPTURE` task endpoint for PPI.
189
+ /// Captures timer value to the CC[1] register.
190
+ #[ inline( always) ]
191
+ pub fn task_capture_cc1 ( & self ) -> & Reg < u32 , _TASKS_CAPTURE > {
192
+ & self . 0 . as_timer0 ( ) . tasks_capture [ 1 ]
193
+ }
194
+
195
+ /// Returns reference to the CC[2] `CAPTURE` task endpoint for PPI.
196
+ /// Captures timer value to the CC[2] register.
197
+ #[ inline( always) ]
198
+ pub fn task_capture_cc2 ( & self ) -> & Reg < u32 , _TASKS_CAPTURE > {
199
+ & self . 0 . as_timer0 ( ) . tasks_capture [ 2 ]
200
+ }
201
+
202
+ /// Returns reference to the CC[3] `CAPTURE` task endpoint for PPI.
203
+ /// Captures timer value to the CC[3] register.
204
+ #[ inline( always) ]
205
+ pub fn task_capture_cc3 ( & self ) -> & Reg < u32 , _TASKS_CAPTURE > {
206
+ & self . 0 . as_timer0 ( ) . tasks_capture [ 3 ]
207
+ }
208
+
209
+ /// Returns reference to the CC[0] `COMPARE` event endpoint for PPI.
210
+ /// Generated when the counter is incremented and then matches the value
211
+ /// specified in the CC[0] register.
212
+ #[ inline( always) ]
213
+ pub fn event_compare_cc0 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
214
+ & self . 0 . as_timer0 ( ) . events_compare [ 0 ]
215
+ }
216
+
217
+ /// Returns reference to the CC[1] `COMPARE` event endpoint for PPI.
218
+ /// Generated when the counter is incremented and then matches the value
219
+ /// specified in the CC[1] register.
220
+ #[ inline( always) ]
221
+ pub fn event_compare_cc1 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
222
+ & self . 0 . as_timer0 ( ) . events_compare [ 1 ]
223
+ }
224
+
225
+ /// Returns reference to the CC[2] `COMPARE` event endpoint for PPI.
226
+ /// Generated when the counter is incremented and then matches the value
227
+ /// specified in the CC[2] register.
228
+ #[ inline( always) ]
229
+ pub fn event_compare_cc2 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
230
+ & self . 0 . as_timer0 ( ) . events_compare [ 2 ]
231
+ }
232
+
233
+ /// Returns reference to the CC[3] `COMPARE` event endpoint for PPI.
234
+ /// Generated when the counter is incremented and then matches the value
235
+ /// specified in the CC[3] register.
236
+ #[ inline( always) ]
237
+ pub fn event_compare_cc3 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
238
+ & self . 0 . as_timer0 ( ) . events_compare [ 3 ]
239
+ }
138
240
}
139
241
140
242
impl < T , U > timer:: CountDown for Timer < T , U >
@@ -400,6 +502,69 @@ impl Instance for TIMER4 {
400
502
}
401
503
}
402
504
505
+ /// Adds task- and event PPI endpoint getters for CC[4] and CC[5] on supported instances.
506
+ #[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
507
+ pub trait ExtendedCCTimer {
508
+ fn task_capture_cc4 ( & self ) -> & Reg < u32 , TasksCapture3 > ;
509
+ fn task_capture_cc5 ( & self ) -> & Reg < u32 , TasksCapture3 > ;
510
+ fn event_compare_cc4 ( & self ) -> & Reg < u32 , EventsCompare3 > ;
511
+ fn event_compare_cc5 ( & self ) -> & Reg < u32 , EventsCompare3 > ;
512
+ }
513
+
514
+ #[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
515
+ impl ExtendedCCTimer for Timer < TIMER3 > {
516
+ /// Returns reference to the CC[4] `CAPTURE` task endpoint for PPI.
517
+ #[ inline( always) ]
518
+ fn task_capture_cc4 ( & self ) -> & Reg < u32 , TasksCapture3 > {
519
+ & self . 0 . tasks_capture [ 4 ]
520
+ }
521
+
522
+ /// Returns reference to the CC[5] `CAPTURE` task endpoint for PPI.
523
+ #[ inline( always) ]
524
+ fn task_capture_cc5 ( & self ) -> & Reg < u32 , TasksCapture3 > {
525
+ & self . 0 . tasks_capture [ 5 ]
526
+ }
527
+
528
+ /// Returns reference to the CC[4] `COMPARE` event endpoint for PPI.
529
+ #[ inline( always) ]
530
+ fn event_compare_cc4 ( & self ) -> & Reg < u32 , EventsCompare3 > {
531
+ & self . 0 . events_compare [ 4 ]
532
+ }
533
+
534
+ /// Returns reference to the CC[5] `COMPARE` event endpoint for PPI.
535
+ #[ inline( always) ]
536
+ fn event_compare_cc5 ( & self ) -> & Reg < u32 , EventsCompare3 > {
537
+ & self . 0 . events_compare [ 5 ]
538
+ }
539
+ }
540
+
541
+ #[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
542
+ impl ExtendedCCTimer for Timer < TIMER4 > {
543
+ /// Returns reference to the CC[4] `CAPTURE` task endpoint for PPI.
544
+ #[ inline( always) ]
545
+ fn task_capture_cc4 ( & self ) -> & Reg < u32 , TasksCapture3 > {
546
+ & self . 0 . tasks_capture [ 4 ]
547
+ }
548
+
549
+ /// Returns reference to the CC[5] `CAPTURE` task endpoint for PPI.
550
+ #[ inline( always) ]
551
+ fn task_capture_cc5 ( & self ) -> & Reg < u32 , TasksCapture3 > {
552
+ & self . 0 . tasks_capture [ 5 ]
553
+ }
554
+
555
+ /// Returns reference to the CC[4] `COMPARE` event endpoint for PPI.
556
+ #[ inline( always) ]
557
+ fn event_compare_cc4 ( & self ) -> & Reg < u32 , EventsCompare3 > {
558
+ & self . 0 . events_compare [ 4 ]
559
+ }
560
+
561
+ /// Returns reference to the CC[5] `COMPARE` event endpoint for PPI.
562
+ #[ inline( always) ]
563
+ fn event_compare_cc5 ( & self ) -> & Reg < u32 , EventsCompare3 > {
564
+ & self . 0 . events_compare [ 5 ]
565
+ }
566
+ }
567
+
403
568
mod sealed {
404
569
pub trait Sealed { }
405
570
impl Sealed for super :: TIMER0 { }
0 commit comments