@@ -10,13 +10,20 @@ pub fn render() -> Result<Vec<Tokens>> {
10
10
generic_items. push ( quote ! {
11
11
use core:: marker;
12
12
13
- ///Marker trait for readable register/field
13
+ ///This trait shows that register has `read` method
14
+ ///
15
+ ///Registers marked with `Writable` can be also `modify`'ed
14
16
pub trait Readable { }
15
17
16
- ///Marker trait for writable register/field
18
+ ///This trait shows that register has `write`, `write_with_zero` and `reset` method
19
+ ///
20
+ ///Registers marked with `Readable` can be also `modify`'ed
17
21
pub trait Writable { }
18
22
19
23
///Reset value of the register
24
+ ///
25
+ ///This value is initial value for `write` method.
26
+ ///It can be also directly writed to register by `reset` method.
20
27
pub trait ResetValue <U > {
21
28
///Reset value of the register
22
29
fn reset_value( ) -> U ;
@@ -30,18 +37,22 @@ pub fn render() -> Result<Vec<Tokens>> {
30
37
} ) ;
31
38
32
39
generic_items. push ( quote ! {
33
- ///Wrapper for registers
40
+ ///This structure provides access to register
34
41
pub struct Reg <U , REG > {
35
42
register: vcell:: VolatileCell <U >,
36
43
_marker: marker:: PhantomData <REG >,
37
44
}
38
45
46
+ unsafe impl <U : Send , REG > Send for Reg <U , REG > { }
47
+
39
48
impl <U , REG > Reg <U , REG >
40
49
where
41
50
Self : Readable ,
42
51
U : Copy
43
52
{
44
- ///Reads the contents of the register
53
+ ///Reads the contents of `Readable` register
54
+ ///
55
+ ///See [reading](https://rust-embedded.github.io/book/start/registers.html#reading) in book.
45
56
#[ inline( always) ]
46
57
pub fn read( & self ) -> R <U , Self > {
47
58
R { bits: self . register. get( ) , _reg: marker:: PhantomData }
@@ -53,7 +64,7 @@ pub fn render() -> Result<Vec<Tokens>> {
53
64
Self : ResetValue <U > + Writable ,
54
65
U : Copy ,
55
66
{
56
- ///Writes the reset value to the register
67
+ ///Writes the reset value to `Writable` register
57
68
#[ inline( always) ]
58
69
pub fn reset( & self ) {
59
70
self . register. set( Self :: reset_value( ) )
@@ -67,7 +78,9 @@ pub fn render() -> Result<Vec<Tokens>> {
67
78
Self : ResetValue <U > + Writable ,
68
79
U : Copy
69
80
{
70
- ///Writes to the register
81
+ ///Writes bits to `Writable` register
82
+ ///
83
+ ///See [writing](https://rust-embedded.github.io/book/start/registers.html#writing) in book.
71
84
#[ inline( always) ]
72
85
pub fn write<F >( & self , f: F )
73
86
where
@@ -84,7 +97,7 @@ pub fn render() -> Result<Vec<Tokens>> {
84
97
Self : Writable ,
85
98
U : Copy + Default
86
99
{
87
- ///Writes Zero to the register
100
+ ///Writes Zero to `Writable` register
88
101
#[ inline( always) ]
89
102
pub fn write_with_zero<F >( & self , f: F )
90
103
where
@@ -102,6 +115,8 @@ pub fn render() -> Result<Vec<Tokens>> {
102
115
U : Copy ,
103
116
{
104
117
///Modifies the contents of the register
118
+ ///
119
+ ///See [modifying](https://rust-embedded.github.io/book/start/registers.html#modifying) in book.
105
120
#[ inline( always) ]
106
121
pub fn modify<F >( & self , f: F )
107
122
where
0 commit comments