1
1
use core:: marker;
2
2
3
3
/// Generic peripheral accessor
4
- pub struct Periph < RB , PER > {
5
- _marker : marker:: PhantomData < ( RB , PER ) > ,
4
+ pub struct Periph < PER : PeripheralSpec > {
5
+ _marker : marker:: PhantomData < PER > ,
6
6
}
7
7
8
8
pub trait PeripheralSpec {
9
+ type RB ;
9
10
///Pointer to the register block
10
11
const ADDRESS : usize ;
11
12
///Debug name
12
13
const NAME : & str ;
13
14
}
14
15
15
- unsafe impl < RB , PER > Send for Periph < RB , PER > { }
16
+ unsafe impl < PER : PeripheralSpec > Send for Periph < PER > { }
16
17
17
- impl < RB , PER : PeripheralSpec > core:: fmt:: Debug for Periph < RB , PER > {
18
+ impl < PER : PeripheralSpec > core:: fmt:: Debug for Periph < PER > {
18
19
fn fmt ( & self , f : & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
19
20
f. debug_struct ( PER :: NAME ) . finish ( )
20
21
}
21
22
}
22
23
23
- impl < RB , PER : PeripheralSpec > Periph < RB , PER > {
24
+ impl < PER : PeripheralSpec > Periph < PER > {
24
25
///Pointer to the register block
25
- pub const PTR : * const RB = PER :: ADDRESS as * const _ ;
26
+ pub const PTR : * const PER :: RB = PER :: ADDRESS as * const _ ;
26
27
27
28
///Return the pointer to the register block
28
29
#[ inline( always) ]
29
- pub const fn ptr ( ) -> * const RB {
30
+ pub const fn ptr ( ) -> * const PER :: RB {
30
31
Self :: PTR
31
32
}
32
33
@@ -50,8 +51,8 @@ impl<RB, PER: PeripheralSpec> Periph<RB, PER> {
50
51
}
51
52
}
52
53
53
- impl < RB , PER : PeripheralSpec > core:: ops:: Deref for Periph < RB , PER > {
54
- type Target = RB ;
54
+ impl < PER : PeripheralSpec > core:: ops:: Deref for Periph < PER > {
55
+ type Target = PER :: RB ;
55
56
56
57
#[ inline( always) ]
57
58
fn deref ( & self ) -> & Self :: Target {
0 commit comments