3 files changed +19
-0
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,8 @@ 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 fixed in memory peripherals)
12
14
- Generated crates now contain the git commit hash and date of svd2rust
13
15
compilation.
14
16
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 @@ -77,6 +77,14 @@ pub fn render(
77
77
unsafe { & * Self :: PTR }
78
78
}
79
79
}
80
+ impl crate :: RegisterBlock for #name_pc {
81
+ type RB = #base:: RegisterBlock ;
82
+
83
+ #[ inline( always) ]
84
+ fn rb( ) -> * const Self :: RB {
85
+ #name_pc:: ptr( )
86
+ }
87
+ }
80
88
} ) ;
81
89
82
90
// Derived peripherals may not require re-implementation, and will instead
0 commit comments