aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorbors[bot] <26634292+bors[bot]@users.noreply.github.com>2022-02-07 22:14:44 +0000
committerGitHub <[email protected]>2022-02-07 22:14:44 +0000
commita4b4a7bcf995c9dcc32a2944887be853df604a1c (patch)
tree74e7cd74d2981c76d13c4ebac8c34dd5d34bfe95
parentf50f3f0a73a41275e6ea21d8661081acad381e05 (diff)
parent8ef5b404f1810cc03a08391ac1927dff94aae0d2 (diff)
Merge #600
600: Update stm32-data r=Dirbaio a=Dirbaio Co-authored-by: Dario Nieuwenhuis <[email protected]>
m---------stm32-data0
-rw-r--r--stm32-metapac-gen/src/data.rs33
-rw-r--r--stm32-metapac-gen/src/lib.rs37
3 files changed, 21 insertions, 49 deletions
diff --git a/stm32-data b/stm32-data
Subproject fe221f48442d4b6eef6dcfd04d9d4deec4402cc Subproject b665a729227a4cdabad58e728f7d4c6a94454b7
diff --git a/stm32-metapac-gen/src/data.rs b/stm32-metapac-gen/src/data.rs
index 56a121ffb..9bb4e191d 100644
--- a/stm32-metapac-gen/src/data.rs
+++ b/stm32-metapac-gen/src/data.rs
@@ -51,7 +51,7 @@ pub struct Peripheral {
51 pub name: String, 51 pub name: String,
52 pub address: u64, 52 pub address: u64,
53 #[serde(default)] 53 #[serde(default)]
54 pub block: Option<String>, 54 pub registers: Option<PeripheralRegisters>,
55 #[serde(default)] 55 #[serde(default)]
56 pub rcc: Option<PeripheralRcc>, 56 pub rcc: Option<PeripheralRcc>,
57 #[serde(default)] 57 #[serde(default)]
@@ -71,11 +71,6 @@ pub struct PeripheralInterrupt {
71#[derive(Debug, Eq, PartialEq, Clone, Deserialize)] 71#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
72pub struct PeripheralRcc { 72pub struct PeripheralRcc {
73 pub clock: String, 73 pub clock: String,
74 pub registers: PeripheralRccRegisters,
75}
76
77#[derive(Debug, Eq, PartialEq, Clone, Deserialize)]
78pub struct PeripheralRccRegisters {
79 #[serde(default)] 74 #[serde(default)]
80 pub enable: Option<PeripheralRccRegister>, 75 pub enable: Option<PeripheralRccRegister>,
81 #[serde(default)] 76 #[serde(default)]
@@ -112,29 +107,9 @@ pub struct PeripheralDmaChannel {
112 pub request: Option<u32>, 107 pub request: Option<u32>,
113} 108}
114 109
115pub struct BlockInfo { 110#[derive(Debug, Eq, PartialEq, Clone, Deserialize, Hash)]
116 /// usart_v1/USART -> usart 111pub struct PeripheralRegisters {
117 pub module: String, 112 pub kind: String,
118 /// usart_v1/USART -> v1
119 pub version: String, 113 pub version: String,
120 /// usart_v1/USART -> USART
121 pub block: String, 114 pub block: String,
122} 115}
123
124impl BlockInfo {
125 pub fn parse(s: &str) -> Self {
126 let mut s = s.split('/');
127 let module = s.next().unwrap();
128 let block = s.next().unwrap();
129 assert!(s.next().is_none());
130 let mut s = module.split('_');
131 let module = s.next().unwrap();
132 let version = s.next().unwrap();
133 assert!(s.next().is_none());
134 Self {
135 module: module.to_string(),
136 version: version.to_string(),
137 block: block.to_string(),
138 }
139 }
140}
diff --git a/stm32-metapac-gen/src/lib.rs b/stm32-metapac-gen/src/lib.rs
index 07de4f1e2..fd8da8a6f 100644
--- a/stm32-metapac-gen/src/lib.rs
+++ b/stm32-metapac-gen/src/lib.rs
@@ -98,12 +98,11 @@ pub fn gen_chip(
98 // Load DBGMCU register for chip 98 // Load DBGMCU register for chip
99 let mut dbgmcu: Option<ir::IR> = core.peripherals.iter().find_map(|p| { 99 let mut dbgmcu: Option<ir::IR> = core.peripherals.iter().find_map(|p| {
100 if p.name == "DBGMCU" { 100 if p.name == "DBGMCU" {
101 p.block.as_ref().map(|block| { 101 p.registers.as_ref().map(|bi| {
102 let bi = BlockInfo::parse(block);
103 let dbgmcu_reg_path = options 102 let dbgmcu_reg_path = options
104 .data_dir 103 .data_dir
105 .join("registers") 104 .join("registers")
106 .join(&format!("{}_{}.yaml", bi.module, bi.version)); 105 .join(&format!("{}_{}.yaml", bi.kind, bi.version));
107 serde_yaml::from_reader(File::open(dbgmcu_reg_path).unwrap()).unwrap() 106 serde_yaml::from_reader(File::open(dbgmcu_reg_path).unwrap()).unwrap()
108 }) 107 })
109 } else { 108 } else {
@@ -160,18 +159,16 @@ pub fn gen_chip(
160 interrupts: HashMap::new(), 159 interrupts: HashMap::new(),
161 }; 160 };
162 161
163 if let Some(block) = &p.block { 162 if let Some(bi) = &p.registers {
164 let bi = BlockInfo::parse(block);
165
166 peripheral_counts.insert( 163 peripheral_counts.insert(
167 bi.module.clone(), 164 bi.kind.clone(),
168 peripheral_counts.get(&bi.module).map_or(1, |v| v + 1), 165 peripheral_counts.get(&bi.kind).map_or(1, |v| v + 1),
169 ); 166 );
170 167
171 for pin in &p.pins { 168 for pin in &p.pins {
172 let mut row = Vec::new(); 169 let mut row = Vec::new();
173 row.push(p.name.clone()); 170 row.push(p.name.clone());
174 row.push(bi.module.clone()); 171 row.push(bi.kind.clone());
175 row.push(bi.block.clone()); 172 row.push(bi.block.clone());
176 row.push(pin.pin.clone()); 173 row.push(pin.pin.clone());
177 row.push(pin.signal.clone()); 174 row.push(pin.signal.clone());
@@ -184,7 +181,7 @@ pub fn gen_chip(
184 for irq in &p.interrupts { 181 for irq in &p.interrupts {
185 let mut row = Vec::new(); 182 let mut row = Vec::new();
186 row.push(p.name.clone()); 183 row.push(p.name.clone());
187 row.push(bi.module.clone()); 184 row.push(bi.kind.clone());
188 row.push(bi.block.clone()); 185 row.push(bi.block.clone());
189 row.push(irq.signal.clone()); 186 row.push(irq.signal.clone());
190 row.push(irq.interrupt.to_ascii_uppercase()); 187 row.push(irq.interrupt.to_ascii_uppercase());
@@ -194,7 +191,7 @@ pub fn gen_chip(
194 for ch in &p.dma_channels { 191 for ch in &p.dma_channels {
195 let mut row = Vec::new(); 192 let mut row = Vec::new();
196 row.push(p.name.clone()); 193 row.push(p.name.clone());
197 row.push(bi.module.clone()); 194 row.push(bi.kind.clone());
198 row.push(bi.block.clone()); 195 row.push(bi.block.clone());
199 row.push(ch.signal.clone()); 196 row.push(ch.signal.clone());
200 row.push(if let Some(channel) = &ch.channel { 197 row.push(if let Some(channel) = &ch.channel {
@@ -221,23 +218,23 @@ pub fn gen_chip(
221 } 218 }
222 219
223 let mut peripheral_row = Vec::new(); 220 let mut peripheral_row = Vec::new();
224 peripheral_row.push(bi.module.clone()); 221 peripheral_row.push(bi.kind.clone());
225 peripheral_row.push(p.name.clone()); 222 peripheral_row.push(p.name.clone());
226 peripherals_table.push(peripheral_row); 223 peripherals_table.push(peripheral_row);
227 224
228 if let Some(old_version) = 225 if let Some(old_version) =
229 peripheral_versions.insert(bi.module.clone(), bi.version.clone()) 226 peripheral_versions.insert(bi.kind.clone(), bi.version.clone())
230 { 227 {
231 if old_version != bi.version { 228 if old_version != bi.version {
232 panic!( 229 panic!(
233 "Peripheral {} has multiple versions: {} and {}", 230 "Peripheral {} has multiple versions: {} and {}",
234 bi.module, old_version, bi.version 231 bi.kind, old_version, bi.version
235 ); 232 );
236 } 233 }
237 } 234 }
238 ir_peri.block = Some(format!("{}::{}", bi.module, bi.block)); 235 ir_peri.block = Some(format!("{}::{}", bi.kind, bi.block));
239 236
240 match bi.module.as_str() { 237 match bi.kind.as_str() {
241 "gpio" => { 238 "gpio" => {
242 let port_letter = p.name.chars().skip(4).next().unwrap(); 239 let port_letter = p.name.chars().skip(4).next().unwrap();
243 assert_eq!(0, (p.address as u32 - gpio_base) % gpio_stride); 240 assert_eq!(0, (p.address as u32 - gpio_base) % gpio_stride);
@@ -265,11 +262,11 @@ pub fn gen_chip(
265 262
266 let mut row = Vec::new(); 263 let mut row = Vec::new();
267 row.push(p.name.clone()); 264 row.push(p.name.clone());
268 row.push(bi.module.clone()); 265 row.push(bi.kind.clone());
269 row.push(bi.block.clone()); 266 row.push(bi.block.clone());
270 row.push(clock); 267 row.push(clock);
271 268
272 for reg in [&rcc.registers.enable, &rcc.registers.reset] { 269 for reg in [&rcc.enable, &rcc.reset] {
273 if let Some(reg) = reg { 270 if let Some(reg) = reg {
274 row.push(format!( 271 row.push(format!(
275 "({}, {}, set_{})", 272 "({}, {}, set_{})",
@@ -292,11 +289,11 @@ pub fn gen_chip(
292 for ch in &core.dma_channels { 289 for ch in &core.dma_channels {
293 let mut row = Vec::new(); 290 let mut row = Vec::new();
294 let dma_peri = core.peripherals.iter().find(|p| p.name == ch.dma).unwrap(); 291 let dma_peri = core.peripherals.iter().find(|p| p.name == ch.dma).unwrap();
295 let bi = BlockInfo::parse(dma_peri.block.as_ref().unwrap()); 292 let bi = dma_peri.registers.as_ref().unwrap();
296 293
297 row.push(ch.name.clone()); 294 row.push(ch.name.clone());
298 row.push(ch.dma.clone()); 295 row.push(ch.dma.clone());
299 row.push(bi.module.clone()); 296 row.push(bi.kind.clone());
300 row.push(ch.channel.to_string()); 297 row.push(ch.channel.to_string());
301 if let Some(dmamux) = &ch.dmamux { 298 if let Some(dmamux) = &ch.dmamux {
302 let dmamux_channel = ch.dmamux_channel.unwrap(); 299 let dmamux_channel = ch.dmamux_channel.unwrap();