File tree Expand file tree Collapse file tree 3 files changed +19
-0
lines changed Expand file tree Collapse file tree 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/).
99
1010### Added
1111
12+ - RegisterBlock trait (like ` Deref ` , but don't require ` self ` instance,
13+ only for fixed in memory peripherals)
1214- Generated crates now contain the git commit hash and date of svd2rust
1315 compilation.
1416
Original file line number Diff line number Diff line change 11use core:: marker;
22
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+
312/// Trait implemented by readable registers to enable the `read` method.
413///
514/// 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(
7474 unsafe { & * #name_pc:: ptr( ) }
7575 }
7676 }
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+ }
7785 } ) ;
7886
7987 // Derived peripherals may not require re-implementation, and will instead
You can’t perform that action at this time.
0 commit comments