Skip to content

Commit c0798e7

Browse files
authored
Merge pull request #301 from xoriath/fpu-and-mpu-is-optional-elements
Change parsing of the CPU block to have optional mpuPresent and
2 parents 14b0840 + e97eeef commit c0798e7

File tree

2 files changed

+14
-4
lines changed

2 files changed

+14
-4
lines changed

svd-parser/src/cpu.rs

Lines changed: 12 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -20,12 +20,22 @@ impl Parse for Cpu {
2020
_ => false,
2121
};
2222

23+
let has_mpu_present = match tree.get_child_bool("mpuPresent") {
24+
Ok(v) => v,
25+
_ => false,
26+
};
27+
28+
let has_fpu_present = match tree.get_child_bool("fpuPresent") {
29+
Ok(v) => v,
30+
_ => false,
31+
};
32+
2333
Cpu::builder()
2434
.name(tree.get_child_text("name")?)
2535
.revision(tree.get_child_text("revision")?)
2636
.endian(Endian::parse(&tree.get_child_elem("endian")?, config)?)
27-
.mpu_present(tree.get_child_bool("mpuPresent")?)
28-
.fpu_present(tree.get_child_bool("fpuPresent")?)
37+
.mpu_present(has_mpu_present)
38+
.fpu_present(has_fpu_present)
2939
.fpu_double_precision(optional::<BoolParse>("fpuDP", tree, &())?)
3040
.dsp_present(optional::<BoolParse>("dspPresent", tree, &())?)
3141
.icache_present(optional::<BoolParse>("icachePresent", tree, &())?)

tests/src/cpu.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ fn decode_encode() {
1616
.unwrap(),
1717
"
1818
<cpu>
19-
<name>EFM32JG12B500F512GM48</name>
19+
<name>EFM32JG12B500F512GM48</name>
2020
<revision>5.1.1</revision>
2121
<endian>little</endian>
2222
<mpuPresent>true</mpuPresent>
@@ -27,7 +27,7 @@ fn decode_encode() {
2727
",
2828
"
2929
<cpu>
30-
<name>EFM32JG12B500F512GM48</name>
30+
<name>EFM32JG12B500F512GM48</name>
3131
<revision>5.1.1</revision>
3232
<endian>little</endian>
3333
<mpuPresent>true</mpuPresent>

0 commit comments

Comments
 (0)