@@ -10,7 +10,7 @@ use quote::{format_ident, quote};
10
10
use py32_metapac:: metadata:: ir:: BitOffset ;
11
11
use py32_metapac:: metadata:: {
12
12
MemoryRegionKind , PeripheralRccKernelClock , PeripheralRccRegister , PeripheralRegisters , /*StopMode,*/
13
- // ALL_CHIPS, ALL_PERIPHERAL_VERSIONS,
13
+ ALL_CHIPS , ALL_PERIPHERAL_VERSIONS ,
14
14
METADATA ,
15
15
} ;
16
16
@@ -43,12 +43,12 @@ fn main() {
43
43
}
44
44
}
45
45
46
- // for &(kind, versions) in ALL_PERIPHERAL_VERSIONS.iter() {
47
- // cfgs.declare(kind);
48
- // for &version in versions.iter() {
49
- // cfgs.declare(format!("{}_{}", kind, version));
50
- // }
51
- // }
46
+ for & ( kind, versions) in ALL_PERIPHERAL_VERSIONS . iter ( ) {
47
+ cfgs. declare ( kind) ;
48
+ for & version in versions. iter ( ) {
49
+ cfgs. declare ( format ! ( "{}_{}" , kind, version) ) ;
50
+ }
51
+ }
52
52
53
53
// ========
54
54
// Generate singletons
@@ -561,7 +561,7 @@ fn main() {
561
561
. unwrap ( )
562
562
. byte_offset ;
563
563
let reg_offset: u8 = ( reg_offset / 4 ) . try_into ( ) . unwrap ( ) ;
564
-
564
+
565
565
let bit_offset = & rcc_registers
566
566
. ir
567
567
. fieldsets
@@ -1635,64 +1635,53 @@ fn main() {
1635
1635
// ========
1636
1636
// Configs for multicore and for targeting groups of chips
1637
1637
1638
- // fn get_chip_cfgs(chip_name: &str) -> Vec<String> {
1639
- // let mut cfgs = Vec::new();
1638
+ fn get_chip_cfgs ( chip_name : & str ) -> Vec < String > {
1639
+ let mut cfgs = Vec :: new ( ) ;
1640
1640
1641
- // // Multicore
1641
+ // Multicore
1642
1642
1643
- // let mut s = chip_name.split('_');
1644
- // let mut chip_name: String = s.next().unwrap().to_string();
1645
- // let core_name = if let Some(c) = s.next() {
1646
- // if !c.starts_with("CM") {
1647
- // chip_name.push('_');
1648
- // chip_name.push_str(c);
1649
- // None
1650
- // } else {
1651
- // Some(c)
1652
- // }
1653
- // } else {
1654
- // None
1655
- // };
1656
-
1657
- // if let Some(core) = core_name {
1658
- // cfgs.push(format!("{}_{}", &chip_name[..chip_name.len() - 2], core));
1659
- // }
1643
+ let mut s = chip_name. split ( '_' ) ;
1644
+ let mut chip_name: String = s. next ( ) . unwrap ( ) . to_string ( ) ;
1645
+ let core_name = if let Some ( c) = s. next ( ) {
1646
+ if !c. starts_with ( "CM" ) {
1647
+ chip_name. push ( '_' ) ;
1648
+ chip_name. push_str ( c) ;
1649
+ None
1650
+ } else {
1651
+ Some ( c)
1652
+ }
1653
+ } else {
1654
+ None
1655
+ } ;
1660
1656
1661
- // // Configs for targeting groups of chips
1662
- // if &chip_name[..8] == "stm32wba" {
1663
- // cfgs.push(chip_name[..8].to_owned()); // stm32wba
1664
- // cfgs.push(chip_name[..10].to_owned()); // stm32wba52
1665
- // cfgs.push(format!("package_{}", &chip_name[10..11]));
1666
- // cfgs.push(format!("flashsize_{}", &chip_name[11..12]));
1667
- // } else {
1668
- // if &chip_name[..8] == "stm32h7r" || &chip_name[..8] == "stm32h7s" {
1669
- // cfgs.push("stm32h7rs".to_owned());
1670
- // } else {
1671
- // cfgs.push(chip_name[..7].to_owned()); // stm32f4
1672
- // }
1673
- // cfgs.push(chip_name[..9].to_owned()); // stm32f429
1674
- // cfgs.push(format!("{}x", &chip_name[..8])); // stm32f42x
1675
- // cfgs.push(format!("{}x{}", &chip_name[..7], &chip_name[8..9])); // stm32f4x9
1676
- // cfgs.push(format!("package_{}", &chip_name[9..10]));
1677
- // cfgs.push(format!("flashsize_{}", &chip_name[10..11]));
1678
- // }
1657
+ if let Some ( core) = core_name {
1658
+ cfgs. push ( format ! ( "{}_{}" , & chip_name[ ..chip_name. len( ) - 2 ] , core) ) ;
1659
+ }
1679
1660
1680
- // // Mark the L4+ chips as they have many differences to regular L4.
1681
- // if &chip_name[..7] == "stm32l4" {
1682
- // if "pqrs".contains(&chip_name[7..8]) {
1683
- // cfgs.push("stm32l4_plus".to_owned());
1684
- // } else {
1685
- // cfgs.push("stm32l4_nonplus".to_owned());
1686
- // }
1687
- // }
1661
+ // Configs for targeting groups of chips
1662
+ if & chip_name[ ..9 ] == "py32f002a" || & chip_name[ ..9 ] == "py32f002b" {
1663
+ cfgs. push ( chip_name[ ..6 ] . to_owned ( ) ) ; // py32f0
1664
+ cfgs. push ( chip_name[ ..9 ] . to_owned ( ) ) ; // py32f002a
1665
+ // TODO
1666
+ }
1667
+ else {
1668
+ cfgs. push ( chip_name[ ..6 ] . to_owned ( ) ) ; // py32f0
1669
+ cfgs. push ( chip_name[ ..8 ] . to_owned ( ) ) ; // py32f030
1670
+ cfgs. push ( format ! ( "package_{}" , & chip_name[ 8 ..10 ] ) ) ;
1671
+ cfgs. push ( format ! ( "flashsize_{}" , & chip_name[ 10 ..11 ] ) ) ;
1672
+ }
1673
+
1674
+ // cfgs.push(format!("{}x", &chip_name[..8])); // stm32f42x
1675
+ // cfgs.push(format!("{}x{}", &chip_name[..7], &chip_name[8..9])); // stm32f4x9
1676
+
1688
1677
1689
- // cfgs
1690
- // }
1678
+ cfgs
1679
+ }
1691
1680
1692
- // cfgs.enable_all(&get_chip_cfgs(&chip_name));
1693
- // for &chip_name in ALL_CHIPS.iter() {
1694
- // cfgs.declare_all(&get_chip_cfgs(&chip_name.to_ascii_lowercase()));
1695
- // }
1681
+ cfgs. enable_all ( & get_chip_cfgs ( & chip_name) ) ;
1682
+ for & chip_name in ALL_CHIPS . iter ( ) {
1683
+ cfgs. declare_all ( & get_chip_cfgs ( & chip_name. to_ascii_lowercase ( ) ) ) ;
1684
+ }
1696
1685
1697
1686
println ! ( "cargo:rerun-if-changed=build.rs" ) ;
1698
1687
}
0 commit comments