11use super :: {
2- BuildError , Cpu , Description , EmptyToNone , Name , Peripheral , RegisterProperties , SvdError ,
3- ValidateLevel ,
2+ BuildError , Cpu , Description , EmptyToNone , Name , Peripheral , RegisterProperties , Riscv ,
3+ SvdError , ValidateLevel ,
44} ;
55
66/// Errors for [`Device::validate`]
@@ -105,6 +105,13 @@ pub struct Device {
105105 /// Specify the compliant CMSIS-SVD schema version
106106 #[ cfg_attr( feature = "serde" , serde( skip, default = "default_schema_version" ) ) ]
107107 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 > ,
108115}
109116
110117fn default_xmlns_xs ( ) -> String {
@@ -130,6 +137,7 @@ pub struct DeviceBuilder {
130137 version : Option < String > ,
131138 description : Option < String > ,
132139 license_text : Option < String > ,
140+ riscv : Option < Riscv > ,
133141 cpu : Option < Cpu > ,
134142 header_system_filename : Option < String > ,
135143 header_definitions_prefix : Option < String > ,
@@ -152,6 +160,7 @@ impl From<Device> for DeviceBuilder {
152160 version : Some ( d. version ) ,
153161 description : Some ( d. description ) ,
154162 license_text : d. license_text ,
163+ riscv : d. riscv ,
155164 cpu : d. cpu ,
156165 header_system_filename : d. header_system_filename ,
157166 header_definitions_prefix : d. header_definitions_prefix ,
@@ -202,6 +211,11 @@ impl DeviceBuilder {
202211 self . license_text = value;
203212 self
204213 }
214+ /// Set the riscv of the device.
215+ pub fn riscv ( mut self , value : Option < Riscv > ) -> Self {
216+ self . riscv = value;
217+ self
218+ }
205219 /// Set the cpu of the device.
206220 pub fn cpu ( mut self , value : Option < Cpu > ) -> Self {
207221 self . cpu = value;
@@ -283,6 +297,7 @@ impl DeviceBuilder {
283297 } )
284298 . ok_or_else ( || BuildError :: Uninitialized ( "description" . to_string ( ) ) ) ?,
285299 license_text : self . license_text ,
300+ riscv : self . riscv ,
286301 cpu : self . cpu ,
287302 header_system_filename : self . header_system_filename ,
288303 header_definitions_prefix : self . header_definitions_prefix ,
@@ -341,6 +356,9 @@ impl Device {
341356 if builder. license_text . is_some ( ) {
342357 self . license_text = builder. license_text . empty_to_none ( ) ;
343358 }
359+ if builder. riscv . is_some ( ) {
360+ self . riscv = builder. riscv ;
361+ }
344362 if builder. cpu . is_some ( ) {
345363 self . cpu = builder. cpu ;
346364 }
0 commit comments