Skip to content

Commit

Permalink
Merge pull request #15 from yodaldevoid/register_properties
Browse files Browse the repository at this point in the history
Register Properties
  • Loading branch information
Dirbaio committed Nov 20, 2023
2 parents 168ce27 + 711a379 commit 67c6adc
Show file tree
Hide file tree
Showing 4 changed files with 34 additions and 141 deletions.
160 changes: 26 additions & 134 deletions Cargo.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -15,4 +15,4 @@ anyhow = "1.0.75"
regex = "1.9.5"
serde = { version = "1.0.188", features = [ "derive" ]}
serde_yaml = "0.9.25"
svd-parser = { version = "0.10.2", features = ["derive-from"] }
svd-parser = { version = "0.14.2", features = ["derive-from", "expand"] }
5 changes: 3 additions & 2 deletions src/main.rs
Original file line number Diff line number Diff line change
Expand Up @@ -139,14 +139,15 @@ fn main() -> Result<()> {
}
}

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

let device = svd_parser::parse(xml)?;
let device =
svd_parser::parse_with_config(xml, &svd_parser::Config::default().expand_properties(true))?;
Ok(device)
}

Expand Down
8 changes: 4 additions & 4 deletions src/svd2ir.rs
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
use log::*;
use std::collections::{HashMap, HashSet};
use svd_parser as svd;
use svd_parser::svd;

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

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

let access = match r.access {
let access = match r.properties.access {
None => Access::ReadWrite,
Some(svd::Access::ReadOnly) => Access::Read,
Some(svd::Access::WriteOnly) => Access::Write,
Expand All @@ -211,7 +211,7 @@ pub fn convert_peripheral(ir: &mut IR, p: &svd::Peripheral) -> anyhow::Result<()
byte_offset: r.address_offset,
inner: BlockItemInner::Register(Register {
access, // todo
bit_size: r.size.unwrap_or(32),
bit_size: r.properties.size.unwrap_or(32),
fieldset: fieldset_name.clone(),
}),
};
Expand Down

0 comments on commit 67c6adc

Please sign in to comment.