File tree Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Expand file tree Collapse file tree 1 file changed +22
-3
lines changed Original file line number Diff line number Diff line change @@ -27,6 +27,8 @@ pub fn device(d: &Device, items: &mut Vec<Tokens>) -> Result<()> {
27
27
extern crate cortex_m;
28
28
extern crate vcell;
29
29
30
+ use core:: ops:: Deref ;
31
+
30
32
use cortex_m:: peripheral:: Peripheral ;
31
33
} ) ;
32
34
@@ -180,10 +182,18 @@ pub fn peripheral(
180
182
181
183
if let Some ( base) = p. derived_from . as_ref ( ) {
182
184
// TODO Verify that base exists
183
- let base_pc = Ident :: new ( & * base. to_sanitized_pascal_case ( ) ) ;
185
+ let base_sc = Ident :: new ( & * base. to_sanitized_snake_case ( ) ) ;
184
186
items. push ( quote ! {
185
187
/// Register block
186
- pub type #name_pc = #base_pc;
188
+ pub struct #name_pc { register_block: #base_sc:: RegisterBlock }
189
+
190
+ impl Deref for #name_pc {
191
+ type Target = #base_sc:: RegisterBlock ;
192
+
193
+ fn deref( & self ) -> & #base_sc:: RegisterBlock {
194
+ & self . register_block
195
+ }
196
+ }
187
197
} ) ;
188
198
189
199
// TODO We don't handle inheritance style `derivedFrom`, we should raise
@@ -223,7 +233,16 @@ pub fn peripheral(
223
233
#( #mod_items) *
224
234
}
225
235
226
- pub use #name_sc:: RegisterBlock as #name_pc;
236
+ #[ doc = #description]
237
+ pub struct #name_pc { register_block: #name_sc:: RegisterBlock }
238
+
239
+ impl Deref for #name_pc {
240
+ type Target = #name_sc:: RegisterBlock ;
241
+
242
+ fn deref( & self ) -> & #name_sc:: RegisterBlock {
243
+ & self . register_block
244
+ }
245
+ }
227
246
} ) ;
228
247
229
248
Ok ( ( ) )
You can’t perform that action at this time.
0 commit comments