Skip to content

Commit 67c6adc

Browse files
authored
Merge pull request #15 from yodaldevoid/register_properties
Register Properties
2 parents 168ce27 + 711a379 commit 67c6adc

File tree

4 files changed

+34
-141
lines changed

4 files changed

+34
-141
lines changed

Cargo.lock

+26-134
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,4 +15,4 @@ anyhow = "1.0.75"
1515
regex = "1.9.5"
1616
serde = { version = "1.0.188", features = [ "derive" ]}
1717
serde_yaml = "0.9.25"
18-
svd-parser = { version = "0.10.2", features = ["derive-from"] }
18+
svd-parser = { version = "0.14.2", features = ["derive-from", "expand"] }

src/main.rs

+3-2
Original file line numberDiff line numberDiff line change
@@ -139,14 +139,15 @@ fn main() -> Result<()> {
139139
}
140140
}
141141

142-
fn load_svd(path: &str) -> Result<svd_parser::Device> {
142+
fn load_svd(path: &str) -> Result<svd_parser::svd::Device> {
143143
let xml = &mut String::new();
144144
File::open(path)
145145
.context("Cannot open the SVD file")?
146146
.read_to_string(xml)
147147
.context("Cannot read the SVD file")?;
148148

149-
let device = svd_parser::parse(xml)?;
149+
let device =
150+
svd_parser::parse_with_config(xml, &svd_parser::Config::default().expand_properties(true))?;
150151
Ok(device)
151152
}
152153

src/svd2ir.rs

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
use log::*;
22
use std::collections::{HashMap, HashSet};
3-
use svd_parser as svd;
3+
use svd_parser::svd;
44

55
use crate::util;
66
use crate::{ir::*, transform};
@@ -53,7 +53,7 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
5353
fieldsets.push(ProtoFieldset {
5454
name: fieldset_name.clone(),
5555
description: r.description.clone(),
56-
bit_size: 32, // todo
56+
bit_size: r.properties.size.unwrap_or(32),
5757
fields: fields.clone(),
5858
});
5959

@@ -195,7 +195,7 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
195195
None
196196
};
197197

198-
let access = match r.access {
198+
let access = match r.properties.access {
199199
None => Access::ReadWrite,
200200
Some(svd::Access::ReadOnly) => Access::Read,
201201
Some(svd::Access::WriteOnly) => Access::Write,
@@ -211,7 +211,7 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
211211
byte_offset: r.address_offset,
212212
inner: BlockItemInner::Register(Register {
213213
access, // todo
214-
bit_size: r.size.unwrap_or(32),
214+
bit_size: r.properties.size.unwrap_or(32),
215215
fieldset: fieldset_name.clone(),
216216
}),
217217
};

0 commit comments

Comments
 (0)