3 files changed +21
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,9 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
9
9
10
10
### Added
11
11
12
+ - RegisterBlock trait (like ` Deref ` , but don't require ` self ` instance,
13
+ only for memory fixed peripherals)
14
+
12
15
- New ` -m ` switch generates a ` mod.rs ` file instead of ` lib.rs ` , which can
13
16
be used as a module inside a crate without further modification.
14
17
Original file line number Diff line number Diff line change 1
1
use core:: marker;
2
2
3
+ ///This trait allows to get raw pointer on derived peripheral
4
+ ///as block of registers of base peripheral (like unsafe `Deref`)
5
+ pub trait RegisterBlock {
6
+ ///Type of RegisterBlock of base peripheral
7
+ type RB ;
8
+ ///Take peripheral address as raw pointer
9
+ fn rb ( ) -> * const Self :: RB ;
10
+ }
11
+
3
12
/// Raw register type
4
13
pub trait RegisterSpec {
5
14
/// Raw register type (`u8`, `u16`, `u32`, ...).
Original file line number Diff line number Diff line change @@ -79,6 +79,15 @@ pub fn render(
79
79
}
80
80
}
81
81
82
+ impl crate :: RegisterBlock for #name_pc {
83
+ type RB = #base:: RegisterBlock ;
84
+
85
+ #[ inline( always) ]
86
+ fn rb( ) -> * const Self :: RB {
87
+ #name_pc:: ptr( )
88
+ }
89
+ }
90
+
82
91
impl core:: fmt:: Debug for #name_pc {
83
92
fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
84
93
f. debug_struct( #name_str) . finish( )
0 commit comments