1
1
use super :: {
2
- BuildError , Cpu , Description , EmptyToNone , Name , Peripheral , RegisterProperties , SvdError ,
3
- ValidateLevel ,
2
+ BuildError , Cpu , Description , EmptyToNone , Name , Peripheral , RegisterProperties , Riscv ,
3
+ SvdError , ValidateLevel ,
4
4
} ;
5
5
6
6
/// Errors for [`Device::validate`]
@@ -105,6 +105,13 @@ pub struct Device {
105
105
/// Specify the compliant CMSIS-SVD schema version
106
106
#[ cfg_attr( feature = "serde" , serde( skip, default = "default_schema_version" ) ) ]
107
107
pub schema_version : String ,
108
+
109
+ /// Describe the processor included in the device
110
+ #[ cfg_attr(
111
+ feature = "serde" ,
112
+ serde( default , skip_serializing_if = "Option::is_none" )
113
+ ) ]
114
+ pub riscv : Option < Riscv > ,
108
115
}
109
116
110
117
fn default_xmlns_xs ( ) -> String {
@@ -130,6 +137,7 @@ pub struct DeviceBuilder {
130
137
version : Option < String > ,
131
138
description : Option < String > ,
132
139
license_text : Option < String > ,
140
+ riscv : Option < Riscv > ,
133
141
cpu : Option < Cpu > ,
134
142
header_system_filename : Option < String > ,
135
143
header_definitions_prefix : Option < String > ,
@@ -152,6 +160,7 @@ impl From<Device> for DeviceBuilder {
152
160
version : Some ( d. version ) ,
153
161
description : Some ( d. description ) ,
154
162
license_text : d. license_text ,
163
+ riscv : d. riscv ,
155
164
cpu : d. cpu ,
156
165
header_system_filename : d. header_system_filename ,
157
166
header_definitions_prefix : d. header_definitions_prefix ,
@@ -202,6 +211,11 @@ impl DeviceBuilder {
202
211
self . license_text = value;
203
212
self
204
213
}
214
+ /// Set the riscv of the device.
215
+ pub fn riscv ( mut self , value : Option < Riscv > ) -> Self {
216
+ self . riscv = value;
217
+ self
218
+ }
205
219
/// Set the cpu of the device.
206
220
pub fn cpu ( mut self , value : Option < Cpu > ) -> Self {
207
221
self . cpu = value;
@@ -283,6 +297,7 @@ impl DeviceBuilder {
283
297
} )
284
298
. ok_or_else ( || BuildError :: Uninitialized ( "description" . to_string ( ) ) ) ?,
285
299
license_text : self . license_text ,
300
+ riscv : self . riscv ,
286
301
cpu : self . cpu ,
287
302
header_system_filename : self . header_system_filename ,
288
303
header_definitions_prefix : self . header_definitions_prefix ,
@@ -341,6 +356,9 @@ impl Device {
341
356
if builder. license_text . is_some ( ) {
342
357
self . license_text = builder. license_text . empty_to_none ( ) ;
343
358
}
359
+ if builder. riscv . is_some ( ) {
360
+ self . riscv = builder. riscv ;
361
+ }
344
362
if builder. cpu . is_some ( ) {
345
363
self . cpu = builder. cpu ;
346
364
}
0 commit comments