Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions svd-parser/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Add check for wrong size of `bitRange` width
- Add `protection` parsing
- Add `readAction` parsing
- Add array support for peripherals
Expand Down
4 changes: 4 additions & 0 deletions svd-parser/src/bitrange.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ pub enum InvalidBitRange {
ParseError,
MsbLsb,
Empty,
Size,
}

impl Parse for BitRange {
Expand Down Expand Up @@ -83,6 +84,9 @@ impl Parse for BitRange {
return Err(SVDError::InvalidBitRange(InvalidBitRange::Syntax).at(tree.id()));
};

if start > end {
return Err(SVDError::InvalidBitRange(InvalidBitRange::Size).at(tree.id()));
}
Ok(Self {
offset: start,
width: end - start + 1,
Expand Down
1 change: 1 addition & 0 deletions svd-rs/CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ and this project adheres to [Semantic Versioning](http://semver.org/).

## Unreleased

- Add `name` function to `Cluster`
- `AddressBlock` now uses builder
- Add `dim_name` and `dim_array_index` to `DimElement`
- Add `alternate_peripheral`, `prepend_to_name`, `append_to_name`,
Expand Down
8 changes: 8 additions & 0 deletions svd-rs/src/cluster.rs
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,14 @@ impl Cluster {
pub const fn is_array(&self) -> bool {
matches!(self, Self::Array(_, _))
}

/// Get the name of this cluster
pub fn name(&self) -> &str {
match self {
Self::Single(info) => &info.name,
Self::Array(info, _) => &info.name,
}
}
}

#[cfg(feature = "serde")]
Expand Down