Skip to content

Commit ce317cd

Browse files
authored
Merge pull request #297 from kurtjd/add-cpu-target
Make vendorSystickConfig only required for ARM
2 parents 36750c1 + 3ef0edf commit ce317cd

5 files changed

Lines changed: 38 additions & 1 deletion

File tree

svd-encoder/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Pin `indexmap` to `2.11.4` to support our MSRV
11+
1012
## [v0.14.7] - 2025-03-11
1113

1214
- Bump MSRV to 1.70.0

svd-encoder/Cargo.toml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -15,6 +15,9 @@ readme = "README.md"
1515
convert_case = "0.6.0"
1616
svd-rs = { version = "0.14.12", path = "../svd-rs" }
1717
thiserror = "1.0.31"
18+
# This is a transitive dep introduced by XML tree,
19+
# but we need to pin to this version to support our current MSRV of 1.70.0
20+
indexmap = "=2.11.4"
1821

1922
[dependencies.xmltree]
2023
version = "0.11.0"

svd-parser/CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@ and this project adheres to [Semantic Versioning](http://semver.org/).
77

88
## [Unreleased]
99

10+
- Add `Target` enum to `Config` and make `vendorSystickConfig` only required for ARM.
11+
1012
## [v0.14.9] - 2025-03-11
1113

1214
- Bump MSRV to 1.70.0

svd-parser/src/cpu.rs

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,14 @@ impl Parse for Cpu {
1212
return Err(SVDError::NotExpectedTag("cpu".to_string()).at(tree.id()));
1313
}
1414

15+
// Vendor systick is required by ARM targets, but not others
16+
// So for others we just default to false if not provided
17+
let has_vendor_systick = match tree.get_child_bool("vendorSystickConfig") {
18+
Ok(v) => v,
19+
Err(e) if config.target == Target::CortexM => return Err(e),
20+
_ => false,
21+
};
22+
1523
Cpu::builder()
1624
.name(tree.get_child_text("name")?)
1725
.revision(tree.get_child_text("revision")?)
@@ -26,7 +34,7 @@ impl Parse for Cpu {
2634
.dtcm_present(optional::<BoolParse>("dtcmPresent", tree, &())?)
2735
.vtor_present(optional::<BoolParse>("vtorPresent", tree, &())?)
2836
.nvic_priority_bits(tree.get_child_u32("nvicPrioBits")?)
29-
.has_vendor_systick(tree.get_child_bool("vendorSystickConfig")?)
37+
.has_vendor_systick(has_vendor_systick)
3038
.device_num_interrupts(optional::<u32>("deviceNumInterrupts", tree, &())?)
3139
.sau_num_regions(optional::<u32>("sauNumRegions", tree, &())?)
3240
.build(config.validate_level)

svd-parser/src/lib.rs

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,8 @@ pub mod types;
3838
#[non_exhaustive]
3939
/// Advanced parser options
4040
pub struct Config {
41+
/// CPU target architecture
42+
pub target: Target,
4143
/// SVD error check level
4244
pub validate_level: ValidateLevel,
4345
#[cfg(feature = "expand")]
@@ -80,6 +82,26 @@ impl Config {
8082
}
8183
}
8284

85+
#[allow(clippy::upper_case_acronyms)]
86+
#[allow(non_camel_case_types)]
87+
#[derive(Clone, Copy, PartialEq, Eq, Debug, Default)]
88+
/// CPU target architecture
89+
pub enum Target {
90+
#[default]
91+
/// ARM Cortex-M
92+
CortexM,
93+
/// Texas Instruments MSP430
94+
Msp430,
95+
/// RISC-V
96+
RISCV,
97+
/// Xtensa LX
98+
XtensaLX,
99+
/// MIPS
100+
Mips,
101+
/// None specified
102+
None,
103+
}
104+
83105
/// Parse trait allows SVD objects to be parsed from XML elements.
84106
pub trait Parse {
85107
/// Object returned by parse method

0 commit comments

Comments
 (0)