-
Notifications
You must be signed in to change notification settings - Fork 9
/
chip.rs
35 lines (27 loc) · 831 Bytes
/
chip.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
use crate::chip;
use crate::svd;
use crate::ElementExt;
pub fn generate(c: &chip::Chip) -> crate::Result<xmltree::Element> {
let mut el = xmltree::Element::new("device");
let defaults = [
("vendor", "Atmel"),
("name", c.name.as_ref()),
("addressUnitBits", "8"),
("size", "8"),
("access", "read-write"),
("resetValue", "0"),
("resetMask", "0xff"),
];
for (name, value) in defaults.iter() {
el.child_with_text(name, *value);
}
let mut peripherals = xmltree::Element::new("peripherals");
peripherals.children = c
.peripherals
.values()
.map(svd::peripheral::generate)
.collect::<Result<Vec<_>, _>>()?;
svd::interrupt::generate(&mut peripherals, c)?;
el.children.push(peripherals);
Ok(el)
}