Skip to content

Commit 8145969

Browse files
committed
interrupt build none
1 parent 438950a commit 8145969

File tree

4 files changed

+9
-9
lines changed

4 files changed

+9
-9
lines changed

svd-parser/src/peripheral.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ impl Parse for Peripheral {
3838
.filter(|t| t.is_element() && t.has_tag_name("interrupt"))
3939
.map(|i| Interrupt::parse(&i, config))
4040
.collect();
41-
interrupt?
41+
Some(interrupt?)
4242
})
4343
.registers(if let Some(registers) = tree.get_child("registers") {
4444
let rs: Result<Vec<_>, _> = registers

svd-rs/src/bitrange.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ impl BitRange {
6060
range_type: BitRangeType::MsbLsb,
6161
}
6262
}
63-
/// Construct a [`BitRange`] from string in the format `[<msb>:<lsb>]`
63+
/// Construct a [`BitRange`] from a string in the format `[<msb>:<lsb>]`
6464
pub fn from_bit_range(text: &str) -> Option<Self> {
6565
if !text.starts_with('[') || !text.ends_with(']') {
6666
return None;

svd-rs/src/clusterinfo.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ use super::{
66
/// Errors from [`ClusterInfo::validate`]
77
#[derive(Clone, Debug, PartialEq, Eq, thiserror::Error)]
88
pub enum Error {
9-
/// The cluster is can not be empty
9+
/// The cluster can not be empty
1010
#[error("Cluster must contain at least one Register or Cluster")]
1111
EmptyCluster,
1212
}

svd-rs/src/peripheral.rs

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -99,7 +99,7 @@ pub struct PeripheralBuilder {
9999
base_address: Option<u64>,
100100
default_register_properties: RegisterProperties,
101101
address_block: Option<Vec<AddressBlock>>,
102-
interrupt: Vec<Interrupt>,
102+
interrupt: Option<Vec<Interrupt>>,
103103
registers: Option<Vec<RegisterCluster>>,
104104
derived_from: Option<String>,
105105
}
@@ -115,7 +115,7 @@ impl From<Peripheral> for PeripheralBuilder {
115115
base_address: Some(p.base_address),
116116
default_register_properties: p.default_register_properties,
117117
address_block: p.address_block,
118-
interrupt: p.interrupt,
118+
interrupt: Some(p.interrupt),
119119
registers: p.registers,
120120
derived_from: p.derived_from,
121121
}
@@ -164,7 +164,7 @@ impl PeripheralBuilder {
164164
self
165165
}
166166
/// Set the interrupts of the peripheral
167-
pub fn interrupt(mut self, value: Vec<Interrupt>) -> Self {
167+
pub fn interrupt(mut self, value: Option<Vec<Interrupt>>) -> Self {
168168
self.interrupt = value;
169169
self
170170
}
@@ -193,7 +193,7 @@ impl PeripheralBuilder {
193193
.ok_or_else(|| BuildError::Uninitialized("base_address".to_string()))?,
194194
default_register_properties: self.default_register_properties.build(lvl)?,
195195
address_block: self.address_block,
196-
interrupt: self.interrupt,
196+
interrupt: self.interrupt.unwrap_or_default(),
197197
registers: self.registers,
198198
derived_from: self.derived_from,
199199
};
@@ -233,8 +233,8 @@ impl Peripheral {
233233
if let Some(base_address) = builder.base_address {
234234
self.base_address = base_address;
235235
}
236-
if !builder.interrupt.is_empty() {
237-
self.interrupt = builder.interrupt;
236+
if let Some(interrupt) = builder.interrupt {
237+
self.interrupt = interrupt;
238238
}
239239
if builder.derived_from.is_some() {
240240
self.derived_from = builder.derived_from;

0 commit comments

Comments
 (0)