@@ -35,12 +35,16 @@ use crate::pac::{TIMER3, TIMER4};
35
35
36
36
// The 832 and 840 expose TIMER3 and TIMER for as timer3::RegisterBlock...
37
37
#[ cfg( any( feature = "52832" , feature = "52840" ) ) ]
38
- 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
+ } ;
39
41
40
42
// ...but the 833 exposes them as timer0::RegisterBlock. This might be a bug
41
43
// in the PAC, and could be fixed later. For now, it is equivalent anyway.
42
44
#[ cfg( feature = "52833" ) ]
43
- 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
+ } ;
44
48
45
49
use core:: marker:: PhantomData ;
46
50
@@ -174,19 +178,64 @@ where
174
178
& self . 0 . as_timer0 ( ) . tasks_clear
175
179
}
176
180
177
- /// Returns reference to the `CAPTURE` task endpoint for PPI.
178
- /// Captures timer value to the given CC register.
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.
179
228
#[ inline( always) ]
180
- pub fn task_capture ( & self , cc : CC ) -> & Reg < u32 , _TASKS_CAPTURE > {
181
- & self . 0 . as_timer0 ( ) . tasks_capture [ cc as usize ]
229
+ pub fn event_compare_cc2 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
230
+ & self . 0 . as_timer0 ( ) . events_compare [ 2 ]
182
231
}
183
232
184
- /// Returns reference to `COMPARE` event endpoint for PPI.
233
+ /// Returns reference to the CC[3] `COMPARE` event endpoint for PPI.
185
234
/// Generated when the counter is incremented and then matches the value
186
- /// specified in the given CC register
235
+ /// specified in the CC[3] register.
187
236
#[ inline( always) ]
188
- pub fn event_compare ( & self , cc : CC ) -> & Reg < u32 , _EVENTS_COMPARE > {
189
- & self . 0 . as_timer0 ( ) . events_compare [ cc as usize ]
237
+ pub fn event_compare_cc3 ( & self ) -> & Reg < u32 , _EVENTS_COMPARE > {
238
+ & self . 0 . as_timer0 ( ) . events_compare [ 3 ]
190
239
}
191
240
}
192
241
@@ -394,15 +443,6 @@ pub trait Instance: sealed::Sealed {
394
443
}
395
444
}
396
445
397
- pub enum CC {
398
- CC0 = 0 ,
399
- CC1 ,
400
- CC2 ,
401
- CC3 ,
402
- CC4 ,
403
- CC5 ,
404
- }
405
-
406
446
impl Instance for TIMER0 {
407
447
const INTERRUPT : Interrupt = Interrupt :: TIMER0 ;
408
448
@@ -462,6 +502,69 @@ impl Instance for TIMER4 {
462
502
}
463
503
}
464
504
505
+ #[ cfg( any( feature = "52832" , feature = "52833" , feature = "52840" ) ) ]
506
+ /// Adds task- and event PPI endpoint getters for CC[4] and CC[5] on supported instances.
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
+
465
568
mod sealed {
466
569
pub trait Sealed { }
467
570
impl Sealed for super :: TIMER0 { }
0 commit comments