@@ -19,8 +19,8 @@ use crate::target::{TIMER3, TIMER4};
19
19
20
20
use core:: marker:: PhantomData ;
21
21
22
- pub struct OneShotTimer ;
23
- pub struct PeriodicTimer ;
22
+ pub struct OneShot ;
23
+ pub struct Periodic ;
24
24
25
25
26
26
/// Interface to a TIMER instance
@@ -30,13 +30,17 @@ pub struct PeriodicTimer;
30
30
///
31
31
/// CC[0] is used for the current/most-recent delay period and CC[1] is used
32
32
/// to grab the current value of the counter at a given instant.
33
- pub struct Timer < T , U > ( T , PhantomData < U > ) ;
33
+ pub struct BaseTimer < T , U > ( T , PhantomData < U > ) ;
34
34
35
- impl < T > Timer < T , OneShotTimer >
35
+ pub type Timer < T > = BaseTimer < T , OneShot > ;
36
+ pub type PeriodicTimer < T > = BaseTimer < T , Periodic > ;
37
+ pub type OneShotTimer < T > = BaseTimer < T , OneShot > ;
38
+
39
+ impl < T > OneShotTimer < T >
36
40
where
37
41
T : Instance ,
38
42
{
39
- pub fn new ( timer : T ) -> Timer < T , OneShotTimer > {
43
+ pub fn new ( timer : T ) -> OneShotTimer < T > {
40
44
timer
41
45
. shorts
42
46
. write ( |w| w. compare0_clear ( ) . enabled ( ) . compare0_stop ( ) . enabled ( ) ) ;
@@ -45,22 +49,23 @@ where
45
49
) ;
46
50
timer. bitmode . write ( |w| w. bitmode ( ) . _32bit ( ) ) ;
47
51
48
- Timer :: < T , OneShotTimer > ( timer, PhantomData )
52
+ BaseTimer :: < T , OneShot > ( timer, PhantomData )
49
53
}
50
54
51
- pub fn into_periodic ( self ) -> Timer < T , PeriodicTimer > {
55
+ pub fn into_periodic ( self ) -> PeriodicTimer < T > {
52
56
self . 0
53
57
. shorts
54
58
. write ( |w| w. compare0_clear ( ) . enabled ( ) . compare0_stop ( ) . disabled ( ) ) ;
55
- Timer :: < T , PeriodicTimer > ( self . free ( ) , PhantomData )
59
+
60
+ BaseTimer :: < T , Periodic > ( self . free ( ) , PhantomData )
56
61
}
57
62
}
58
63
59
- impl < T > Timer < T , PeriodicTimer >
64
+ impl < T > PeriodicTimer < T >
60
65
where
61
66
T : Instance ,
62
67
{
63
- pub fn new_periodic ( timer : T ) -> Timer < T , PeriodicTimer > {
68
+ pub fn new_periodic ( timer : T ) -> PeriodicTimer < T > {
64
69
timer
65
70
. shorts
66
71
. write ( |w| w. compare0_clear ( ) . enabled ( ) . compare0_stop ( ) . disabled ( ) ) ;
@@ -69,18 +74,19 @@ where
69
74
) ;
70
75
timer. bitmode . write ( |w| w. bitmode ( ) . _32bit ( ) ) ;
71
76
72
- Timer :: < T , PeriodicTimer > ( timer, PhantomData )
77
+ BaseTimer :: < T , Periodic > ( timer, PhantomData )
73
78
}
74
79
75
- pub fn into_oneshot ( self ) -> Timer < T , OneShotTimer > {
80
+ pub fn into_oneshot ( self ) -> OneShotTimer < T > {
76
81
self . 0
77
82
. shorts
78
83
. write ( |w| w. compare0_clear ( ) . enabled ( ) . compare0_stop ( ) . enabled ( ) ) ;
79
- Timer :: < T , OneShotTimer > ( self . free ( ) , PhantomData )
84
+
85
+ BaseTimer :: < T , OneShot > ( self . free ( ) , PhantomData )
80
86
}
81
87
}
82
88
83
- impl < T , U > Timer < T , U >
89
+ impl < T , U > BaseTimer < T , U >
84
90
where
85
91
T : Instance ,
86
92
{
@@ -144,7 +150,7 @@ where
144
150
}
145
151
}
146
152
147
- impl < T , U > timer:: CountDown for Timer < T , U >
153
+ impl < T , U > timer:: CountDown for BaseTimer < T , U >
148
154
where
149
155
T : Instance ,
150
156
{
@@ -205,7 +211,7 @@ where
205
211
}
206
212
}
207
213
208
- impl < T , U > timer:: Cancel for Timer < T , U >
214
+ impl < T , U > timer:: Cancel for BaseTimer < T , U >
209
215
where
210
216
T : Instance ,
211
217
{
@@ -219,7 +225,7 @@ where
219
225
}
220
226
}
221
227
222
- impl < T > timer:: Periodic for Timer < T , PeriodicTimer >
228
+ impl < T > timer:: Periodic for PeriodicTimer < T >
223
229
where
224
230
T : Instance ,
225
231
{ }
0 commit comments