File tree 3 files changed +19
-0
lines changed
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
/// Trait implemented by readable registers to enable the `read` method.
4
13
///
5
14
/// Registers marked with `Writable` can be also `modify`'ed.
Original file line number Diff line number Diff line change @@ -74,6 +74,14 @@ pub fn render(
74
74
unsafe { & * #name_pc:: ptr( ) }
75
75
}
76
76
}
77
+ impl crate :: RegisterBlock for #name_pc {
78
+ type RB = #base:: RegisterBlock ;
79
+
80
+ #[ inline( always) ]
81
+ fn rb( ) -> * const Self :: RB {
82
+ #name_pc:: ptr( )
83
+ }
84
+ }
77
85
} ) ;
78
86
79
87
// Derived peripherals may not require re-implementation, and will instead
You can’t perform that action at this time.
0 commit comments