@@ -45,15 +45,41 @@ pub struct PeripheralInfo {
45
45
) ]
46
46
pub description : Option < String > ,
47
47
48
- // alternatePeripheral
48
+ /// Specifies peripheral assigned to the same address blocks
49
+ #[ cfg_attr(
50
+ feature = "serde" ,
51
+ serde( default , skip_serializing_if = "Option::is_none" )
52
+ ) ]
53
+ pub alternate_peripheral : Option < String > ,
54
+
49
55
/// Assigns this peripheral to a group of peripherals. This is only used bye the System View
50
56
#[ cfg_attr(
51
57
feature = "serde" ,
52
58
serde( default , skip_serializing_if = "Option::is_none" )
53
59
) ]
54
60
pub group_name : Option < String > ,
55
61
56
- // headerStructName
62
+ /// Define a string as prefix. All register names of this peripheral get this prefix
63
+ #[ cfg_attr(
64
+ feature = "serde" ,
65
+ serde( default , skip_serializing_if = "Option::is_none" )
66
+ ) ]
67
+ pub prepend_to_name : Option < String > ,
68
+
69
+ /// Define a string as suffix. All register names of this peripheral get this suffix
70
+ #[ cfg_attr(
71
+ feature = "serde" ,
72
+ serde( default , skip_serializing_if = "Option::is_none" )
73
+ ) ]
74
+ pub append_to_name : Option < String > ,
75
+
76
+ /// Specify the struct type name created in the device header file
77
+ #[ cfg_attr(
78
+ feature = "serde" ,
79
+ serde( default , skip_serializing_if = "Option::is_none" )
80
+ ) ]
81
+ pub header_struct_name : Option < String > ,
82
+
57
83
/// Lowest address reserved or used by the peripheral
58
84
pub base_address : u64 ,
59
85
@@ -98,7 +124,11 @@ pub struct PeripheralInfoBuilder {
98
124
display_name : Option < String > ,
99
125
version : Option < String > ,
100
126
description : Option < String > ,
127
+ alternate_peripheral : Option < String > ,
101
128
group_name : Option < String > ,
129
+ prepend_to_name : Option < String > ,
130
+ append_to_name : Option < String > ,
131
+ header_struct_name : Option < String > ,
102
132
base_address : Option < u64 > ,
103
133
default_register_properties : RegisterProperties ,
104
134
address_block : Option < Vec < AddressBlock > > ,
@@ -114,7 +144,11 @@ impl From<PeripheralInfo> for PeripheralInfoBuilder {
114
144
display_name : p. display_name ,
115
145
version : p. version ,
116
146
description : p. description ,
147
+ alternate_peripheral : p. alternate_peripheral ,
117
148
group_name : p. group_name ,
149
+ prepend_to_name : p. prepend_to_name ,
150
+ append_to_name : p. append_to_name ,
151
+ header_struct_name : p. header_struct_name ,
118
152
base_address : Some ( p. base_address ) ,
119
153
default_register_properties : p. default_register_properties ,
120
154
address_block : p. address_block ,
@@ -146,11 +180,31 @@ impl PeripheralInfoBuilder {
146
180
self . description = value;
147
181
self
148
182
}
183
+ /// Set the alternate peripheral
184
+ pub fn alternate_peripheral ( mut self , value : Option < String > ) -> Self {
185
+ self . alternate_peripheral = value;
186
+ self
187
+ }
149
188
/// Set the group name of the peripheral
150
189
pub fn group_name ( mut self , value : Option < String > ) -> Self {
151
190
self . group_name = value;
152
191
self
153
192
}
193
+ /// Set the prefix for names of all registers of the peripheral
194
+ pub fn prepend_to_name ( mut self , value : Option < String > ) -> Self {
195
+ self . prepend_to_name = value;
196
+ self
197
+ }
198
+ /// Set the suffix for names of all registers of the peripheral
199
+ pub fn append_to_name ( mut self , value : Option < String > ) -> Self {
200
+ self . append_to_name = value;
201
+ self
202
+ }
203
+ /// Set the header struct name of the peripheral
204
+ pub fn header_struct_name ( mut self , value : Option < String > ) -> Self {
205
+ self . header_struct_name = value;
206
+ self
207
+ }
154
208
/// Set the base address of the peripheral
155
209
pub fn base_address ( mut self , value : u64 ) -> Self {
156
210
self . base_address = Some ( value) ;
@@ -190,7 +244,11 @@ impl PeripheralInfoBuilder {
190
244
display_name : self . display_name . empty_to_none ( ) ,
191
245
version : self . version . empty_to_none ( ) ,
192
246
description : self . description . empty_to_none ( ) ,
247
+ alternate_peripheral : self . alternate_peripheral . empty_to_none ( ) ,
193
248
group_name : self . group_name . empty_to_none ( ) ,
249
+ prepend_to_name : self . prepend_to_name . empty_to_none ( ) ,
250
+ append_to_name : self . append_to_name . empty_to_none ( ) ,
251
+ header_struct_name : self . header_struct_name . empty_to_none ( ) ,
194
252
base_address : self
195
253
. base_address
196
254
. ok_or_else ( || BuildError :: Uninitialized ( "base_address" . to_string ( ) ) ) ?,
@@ -238,9 +296,21 @@ impl PeripheralInfo {
238
296
if builder. description . is_some ( ) {
239
297
self . description = builder. description . empty_to_none ( ) ;
240
298
}
299
+ if builder. alternate_peripheral . is_some ( ) {
300
+ self . alternate_peripheral = builder. alternate_peripheral . empty_to_none ( ) ;
301
+ }
241
302
if builder. group_name . is_some ( ) {
242
303
self . group_name = builder. group_name . empty_to_none ( ) ;
243
304
}
305
+ if builder. prepend_to_name . is_some ( ) {
306
+ self . prepend_to_name = builder. prepend_to_name . empty_to_none ( ) ;
307
+ }
308
+ if builder. append_to_name . is_some ( ) {
309
+ self . append_to_name = builder. append_to_name . empty_to_none ( ) ;
310
+ }
311
+ if builder. header_struct_name . is_some ( ) {
312
+ self . header_struct_name = builder. header_struct_name . empty_to_none ( ) ;
313
+ }
244
314
if let Some ( base_address) = builder. base_address {
245
315
self . base_address = base_address;
246
316
}
0 commit comments