@@ -72,20 +72,25 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
7272 feature_attribute : & TokenStream ,
7373 doc : & str ,
7474 p_ty : & Ident ,
75+ name_str : & str ,
7576 doc_alias : Option < TokenStream > ,
7677 address : LitInt | {
78+ let pspec = ident ( name_str, config, "peripheral_spec" , Span :: call_site ( ) ) ;
7779 out. extend ( quote ! {
7880 #[ doc = #doc]
7981 #phtml
8082 #doc_alias
8183 #feature_attribute
82- pub type #p_ty = crate :: Periph <#base :: RegisterBlock , #address >;
84+ pub type #p_ty = crate :: Periph <#pspec >;
8385
8486 #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;
8994 }
9095 } ) ;
9196 } ;
@@ -113,6 +118,7 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
113118 & feature_attribute_n,
114119 & doc,
115120 & p_ty,
121+ & name_str,
116122 doc_alias,
117123 address,
118124 ) ;
@@ -138,7 +144,15 @@ pub fn render(p_original: &Peripheral, index: &Index, config: &Config) -> Result
138144 feature_attribute. extend ( quote ! { #[ cfg( feature = #p_feature) ] } )
139145 } ;
140146 // 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+ ) ;
142156
143157 // Derived peripherals may not require re-implementation, and will instead
144158 // use a single definition of the non-derived version.
0 commit comments