@@ -72,20 +72,25 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
72
72
feature_attribute : & TokenStream ,
73
73
doc : & str ,
74
74
p_ty : & Ident ,
75
+ name_str : & str ,
75
76
doc_alias : Option < TokenStream > ,
76
77
address : LitInt | {
78
+ let pspec = ident ( name_str, config, "peripheral_spec" , Span :: call_site ( ) ) ;
77
79
out. extend ( quote ! {
78
80
#[ doc = #doc]
79
81
#phtml
80
82
#doc_alias
81
83
#feature_attribute
82
- pub type #p_ty = crate :: Periph <#base :: RegisterBlock , #address >;
84
+ pub type #p_ty = crate :: Periph <#pspec >;
83
85
84
86
#feature_attribute
85
- impl core:: fmt:: Debug for #p_ty {
86
- fn fmt( & self , f: & mut core:: fmt:: Formatter ) -> core:: fmt:: Result {
87
- f. debug_struct( #name_str) . finish( )
88
- }
87
+ pub struct #pspec;
88
+
89
+ #feature_attribute
90
+ impl crate :: PeripheralSpec for #pspec {
91
+ type RB = #base:: RegisterBlock ;
92
+ const ADDRESS : usize = #address;
93
+ const NAME : & str = #name_str;
89
94
}
90
95
} ) ;
91
96
} ;
@@ -113,6 +118,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
113
118
& feature_attribute_n,
114
119
& doc,
115
120
& p_ty,
121
+ & name_str,
116
122
doc_alias,
117
123
address,
118
124
) ;
@@ -138,7 +144,15 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
138
144
feature_attribute. extend ( quote ! { #[ cfg( feature = #p_feature) ] } )
139
145
} ;
140
146
// Insert the peripheral structure
141
- per_to_tokens ( & mut out, & feature_attribute, & doc, & p_ty, None , address) ;
147
+ per_to_tokens (
148
+ & mut out,
149
+ & feature_attribute,
150
+ & doc,
151
+ & p_ty,
152
+ & name_str,
153
+ None ,
154
+ address,
155
+ ) ;
142
156
143
157
// Derived peripherals may not require re-implementation, and will instead
144
158
// use a single definition of the non-derived version.
0 commit comments