1
1
use core:: marker;
2
2
3
3
/// Raw register type
4
- pub trait Register {
4
+ pub trait RegisterSpec {
5
5
/// Raw register type (`u8`, `u16`, `u32`, ...).
6
6
type Ux : Copy ;
7
7
}
8
8
9
9
/// Trait implemented by readable registers to enable the `read` method.
10
10
///
11
11
/// Registers marked with `Writable` can be also `modify`'ed.
12
- pub trait Readable : Register { }
12
+ pub trait Readable : RegisterSpec { }
13
13
14
14
/// Trait implemented by writeable registers.
15
15
///
16
16
/// This enables the `write`, `write_with_zero` and `reset` methods.
17
17
///
18
18
/// Registers marked with `Readable` can be also `modify`'ed.
19
- pub trait Writable : Register { }
19
+ pub trait Writable : RegisterSpec { }
20
20
21
21
/// Reset value of the register.
22
22
///
23
23
/// This value is the initial value for the `write` method. It can also be directly written to the
24
24
/// register by using the `reset` method.
25
- pub trait Resettable : Register {
25
+ pub trait Resettable : RegisterSpec {
26
26
/// Reset value of the register.
27
27
fn reset_value ( ) -> Self :: Ux ;
28
28
}
29
29
30
30
/// This structure provides volatile access to registers.
31
- pub struct Reg < REG : Register > {
31
+ pub struct Reg < REG : RegisterSpec > {
32
32
register : vcell:: VolatileCell < REG :: Ux > ,
33
33
_marker : marker:: PhantomData < REG > ,
34
34
}
35
35
36
- unsafe impl < REG : Register > Send for Reg < REG > where REG :: Ux : Send { }
36
+ unsafe impl < REG : RegisterSpec > Send for Reg < REG > where REG :: Ux : Send { }
37
37
38
- impl < REG : Register > Reg < REG > {
38
+ impl < REG : RegisterSpec > Reg < REG > {
39
39
/// Returns the underlying memory address of register.
40
40
///
41
41
/// ```ignore
@@ -174,20 +174,20 @@ impl<REG: Readable + Writable> Reg<REG> {
174
174
///
175
175
/// Result of the `read` methods of registers. Also used as a closure argument in the `modify`
176
176
/// method.
177
- pub struct R < REG : Register > {
177
+ pub struct R < REG : RegisterSpec > {
178
178
pub ( crate ) bits : REG :: Ux ,
179
179
_reg : marker:: PhantomData < REG > ,
180
180
}
181
181
182
- impl < REG : Register > R < REG > {
182
+ impl < REG : RegisterSpec > R < REG > {
183
183
/// Reads raw bits from register.
184
184
#[ inline( always) ]
185
185
pub fn bits ( & self ) -> REG :: Ux {
186
186
self . bits
187
187
}
188
188
}
189
189
190
- impl < REG : Register , FI > PartialEq < FI > for R < REG >
190
+ impl < REG : RegisterSpec , FI > PartialEq < FI > for R < REG >
191
191
where
192
192
REG :: Ux : PartialEq ,
193
193
FI : Copy + Into < REG :: Ux > ,
@@ -201,13 +201,13 @@ where
201
201
/// Register writer.
202
202
///
203
203
/// Used as an argument to the closures in the `write` and `modify` methods of the register.
204
- pub struct W < REG : Register > {
204
+ pub struct W < REG : RegisterSpec > {
205
205
///Writable bits
206
206
pub ( crate ) bits : REG :: Ux ,
207
207
_reg : marker:: PhantomData < REG > ,
208
208
}
209
209
210
- impl < REG : Register > W < REG > {
210
+ impl < REG : RegisterSpec > W < REG > {
211
211
/// Writes raw bits to the register.
212
212
#[ inline( always) ]
213
213
pub unsafe fn bits ( & mut self , bits : REG :: Ux ) -> & mut Self {
0 commit comments