From a30f40f2e668427e67bbdd1d3ec31795fb43800a Mon Sep 17 00:00:00 2001 From: xoviat Date: Thu, 20 Apr 2023 17:30:12 -0500 Subject: [PATCH 1/2] i2s: add pins to spi peripheral --- d.ps1 | 44 +++++++++++++++++++++++++++++++++++++ stm32-data-gen/src/chips.rs | 32 +++++++++++++++++++-------- 2 files changed, 67 insertions(+), 9 deletions(-) create mode 100644 d.ps1 diff --git a/d.ps1 b/d.ps1 new file mode 100644 index 0000000..131266f --- /dev/null +++ b/d.ps1 @@ -0,0 +1,44 @@ +<# #> +param ( + [Parameter(Mandatory=$true)] + [string]$CMD, + + [string]$peri +) + +Switch ($CMD) +{ + "download-all" { + rm -r -Force ./sources/ -ErrorAction SilentlyContinue + git clone https://github.com/embassy-rs/stm32-data-sources.git ./sources/ + cd ./sources/ + git checkout ca89656b + cd .. + } + "install-chiptool" { + cargo install --git https://github.com/embassy-rs/chiptool + } + "extract-all" { + rm -r -Force tmp/$peri -ErrorAction SilentlyContinue + mkdir tmp/$peri | Out-Null + + ls sources/svd | foreach-object { + $f = $_.Name.TrimStart("stm32").TrimEnd(".svd") + echo $f + + echo "processing $f ..." + chiptool extract-peripheral --svd "sources/svd/stm32$f.svd" --peripheral "$peri" > "tmp/$peri/$f.yaml" 2> "tmp/$peri/$f.err" + if (!$error) { + rm "tmp/$peri/$f.err" + echo OK + } else { + rm "tmp/$peri/$f.yaml" + echo FAIL + } + + } + } + default { + echo "unknown command" + } +} \ No newline at end of file diff --git a/stm32-data-gen/src/chips.rs b/stm32-data-gen/src/chips.rs index b24d580..3333760 100644 --- a/stm32-data-gen/src/chips.rs +++ b/stm32-data-gen/src/chips.rs @@ -763,15 +763,6 @@ fn process_core( "DMA", // IRTIM is just TIM16+TIM17 "IRTIM", - // I2S is just SPI on disguise - "I2S1", - "I2S2", - "I2S3", - "I2S4", - "I2S5", - "I2S6", - "I2S7", - "I2S8", // We add this as ghost peri "SYS", // These are software libraries @@ -864,6 +855,11 @@ fn process_core( } let mut peripherals = Vec::new(); for (pname, pkind) in peri_kinds { + // We cannot add this to FAKE peripherals because we need the pins + if pname.starts_with("I2S") { + continue; + } + let addr = if chip_name.starts_with("STM32F0") && pname == "ADC" { defines.get_peri_addr("ADC1") } else { @@ -912,6 +908,24 @@ fn process_core( } p.pins = pins.clone(); } + + let i2s_name = if pname.starts_with("SPI") { + "I2S".to_owned() + pname.trim_start_matches("SPI") + } else { + "".to_owned() + }; + + if let Some(i2s_pins) = periph_pins.get_mut(&i2s_name) { + // merge the core xml info with GPIO xml info to hopefully get the full picture + // if the peripheral does not exist in the GPIO xml (one of the notable one is ADC) + // it probably doesn't need any AFIO writes to work + if let Some(af_pins) = chip_af.and_then(|x| x.get(&i2s_name)) { + merge_periph_pins_info(chip_name.contains("STM32F1"), &i2s_name, i2s_pins, af_pins.as_slice()); + } + + p.pins.append(i2s_pins.clone().as_mut()); + } + if let Some(peri_irqs) = chip_irqs.get(&pname) { //filter by available, because some are conditioned on let mut irqs: Vec<_> = peri_irqs From f4116916fd0a265c7d05bfd23c29c22b7185e242 Mon Sep 17 00:00:00 2001 From: xoviat Date: Fri, 21 Apr 2023 18:45:46 -0500 Subject: [PATCH 2/2] i2s: prefix pin name with i2s --- stm32-data-gen/src/chips.rs | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/stm32-data-gen/src/chips.rs b/stm32-data-gen/src/chips.rs index 3333760..eddefa6 100644 --- a/stm32-data-gen/src/chips.rs +++ b/stm32-data-gen/src/chips.rs @@ -1,6 +1,8 @@ use std::collections::hash_map::Entry; use std::collections::{HashMap, HashSet}; +use stm32_data_serde::chip::core::peripheral::Pin; + use super::*; mod xml { @@ -923,7 +925,11 @@ fn process_core( merge_periph_pins_info(chip_name.contains("STM32F1"), &i2s_name, i2s_pins, af_pins.as_slice()); } - p.pins.append(i2s_pins.clone().as_mut()); + p.pins.extend(i2s_pins.iter().map(|p| Pin { + pin: p.pin, + signal: "I2S_".to_owned() + &p.signal, + af: p.af, + })); } if let Some(peri_irqs) = chip_irqs.get(&pname) {