Skip to content

Commit 63212e6

Browse files
committed
Adds the reset field to a Register
Registers commonly have reset values and it can be useful to know what these are when generating code for them. In the case of the wm8960 I actually inspect the IR and generate a default array (as the device has no ability to read back register over i2c) that is stored in memory. It's entirely optional and unused currently by generators (but certainly could be!)
1 parent 0eaae76 commit 63212e6

File tree

2 files changed

+7
-1
lines changed

2 files changed

+7
-1
lines changed

src/ir.rs

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -123,7 +123,10 @@ pub struct Register {
123123
pub bit_size: u32,
124124
#[serde(default, skip_serializing_if = "Option::is_none")]
125125
pub fieldset: Option<String>,
126+
#[serde(default, skip_serializing_if = "is_0")]
127+
pub reset: u32,
126128
}
129+
127130
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize)]
128131
pub struct BlockItemBlock {
129132
pub block: String,
@@ -184,7 +187,9 @@ fn default_32() -> u32 {
184187
fn is_32(x: &u32) -> bool {
185188
*x == 32
186189
}
187-
190+
fn is_0(x: &u32) -> bool {
191+
*x == 0
192+
}
188193
fn default_readwrite() -> Access {
189194
Access::ReadWrite
190195
}

src/svd2ir.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -214,6 +214,7 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
214214
access, // todo
215215
bit_size: r.properties.size.unwrap_or(32),
216216
fieldset: fieldset_name.clone(),
217+
reset: 0,
217218
}),
218219
};
219220

0 commit comments

Comments
 (0)