diff options
| author | i509VCB <[email protected]> | 2025-10-02 17:02:20 -0500 |
|---|---|---|
| committer | i509VCB <[email protected]> | 2025-10-08 14:39:07 -0500 |
| commit | c6799c2921780254319d293d37f33161f5fd1832 (patch) | |
| tree | ec566c03efa33467878cc5ddc73dc63069034b04 /embassy-mspm0/build.rs | |
| parent | 96b87658fc2c9cfd68358195c2dc03ebba2482a2 (diff) | |
mspm0: add mspm0h321x support
This also changes selection of GPIO interrupt type to be calculated by the buildscript. H321x is yet another exception with GPIOB being a physical interrupt rather than part of an interrupt group.
H3215/6 are true 5V parts. I wonder if that is a first for an embassy hal
Diffstat (limited to 'embassy-mspm0/build.rs')
| -rw-r--r-- | embassy-mspm0/build.rs | 50 |
1 files changed, 42 insertions, 8 deletions
diff --git a/embassy-mspm0/build.rs b/embassy-mspm0/build.rs index 93ea81ac3..1d118ad66 100644 --- a/embassy-mspm0/build.rs +++ b/embassy-mspm0/build.rs | |||
| @@ -16,14 +16,15 @@ use quote::{format_ident, quote}; | |||
| 16 | mod common; | 16 | mod common; |
| 17 | 17 | ||
| 18 | fn main() { | 18 | fn main() { |
| 19 | generate_code(); | ||
| 20 | interrupt_group_linker_magic(); | ||
| 21 | } | ||
| 22 | |||
| 23 | fn generate_code() { | ||
| 24 | let mut cfgs = common::CfgSet::new(); | 19 | let mut cfgs = common::CfgSet::new(); |
| 25 | common::set_target_cfgs(&mut cfgs); | 20 | common::set_target_cfgs(&mut cfgs); |
| 26 | 21 | ||
| 22 | generate_code(&mut cfgs); | ||
| 23 | select_gpio_features(&mut cfgs); | ||
| 24 | interrupt_group_linker_magic(); | ||
| 25 | } | ||
| 26 | |||
| 27 | fn generate_code(cfgs: &mut CfgSet) { | ||
| 27 | #[cfg(any(feature = "rt"))] | 28 | #[cfg(any(feature = "rt"))] |
| 28 | println!( | 29 | println!( |
| 29 | "cargo:rustc-link-search={}", | 30 | "cargo:rustc-link-search={}", |
| @@ -53,9 +54,9 @@ fn generate_code() { | |||
| 53 | cfgs.declare_all(&get_chip_cfgs(&chip)); | 54 | cfgs.declare_all(&get_chip_cfgs(&chip)); |
| 54 | } | 55 | } |
| 55 | 56 | ||
| 56 | let mut singletons = get_singletons(&mut cfgs); | 57 | let mut singletons = get_singletons(cfgs); |
| 57 | 58 | ||
| 58 | time_driver(&mut singletons, &mut cfgs); | 59 | time_driver(&mut singletons, cfgs); |
| 59 | 60 | ||
| 60 | let mut g = TokenStream::new(); | 61 | let mut g = TokenStream::new(); |
| 61 | 62 | ||
| @@ -68,7 +69,7 @@ fn generate_code() { | |||
| 68 | g.extend(generate_pin_trait_impls()); | 69 | g.extend(generate_pin_trait_impls()); |
| 69 | g.extend(generate_groups()); | 70 | g.extend(generate_groups()); |
| 70 | g.extend(generate_dma_channel_count()); | 71 | g.extend(generate_dma_channel_count()); |
| 71 | g.extend(generate_adc_constants(&mut cfgs)); | 72 | g.extend(generate_adc_constants(cfgs)); |
| 72 | 73 | ||
| 73 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); | 74 | let out_dir = &PathBuf::from(env::var_os("OUT_DIR").unwrap()); |
| 74 | let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); | 75 | let out_file = out_dir.join("_generated.rs").to_string_lossy().to_string(); |
| @@ -115,6 +116,10 @@ fn get_chip_cfgs(chip_name: &str) -> Vec<String> { | |||
| 115 | cfgs.push("mspm0g351x".to_string()); | 116 | cfgs.push("mspm0g351x".to_string()); |
| 116 | } | 117 | } |
| 117 | 118 | ||
| 119 | if chip_name.starts_with("mspm0h321") { | ||
| 120 | cfgs.push("mspm0h321x".to_string()); | ||
| 121 | } | ||
| 122 | |||
| 118 | if chip_name.starts_with("mspm0l110") { | 123 | if chip_name.starts_with("mspm0l110") { |
| 119 | cfgs.push("mspm0l110x".to_string()); | 124 | cfgs.push("mspm0l110x".to_string()); |
| 120 | } | 125 | } |
| @@ -646,6 +651,35 @@ fn generate_pin_trait_impls() -> TokenStream { | |||
| 646 | } | 651 | } |
| 647 | } | 652 | } |
| 648 | 653 | ||
| 654 | fn select_gpio_features(cfgs: &mut CfgSet) { | ||
| 655 | cfgs.declare_all(&[ | ||
| 656 | "gpioa_interrupt", | ||
| 657 | "gpioa_group", | ||
| 658 | "gpiob_interrupt", | ||
| 659 | "gpiob_group", | ||
| 660 | "gpioc_group", | ||
| 661 | ]); | ||
| 662 | |||
| 663 | for interrupt in METADATA.interrupts.iter() { | ||
| 664 | match interrupt.name { | ||
| 665 | "GPIOA" => cfgs.enable("gpioa_interrupt"), | ||
| 666 | "GPIOB" => cfgs.enable("gpiob_interrupt"), | ||
| 667 | _ => (), | ||
| 668 | } | ||
| 669 | } | ||
| 670 | |||
| 671 | for group in METADATA.interrupt_groups.iter() { | ||
| 672 | for interrupt in group.interrupts { | ||
| 673 | match interrupt.name { | ||
| 674 | "GPIOA" => cfgs.enable("gpioa_group"), | ||
| 675 | "GPIOB" => cfgs.enable("gpiob_group"), | ||
| 676 | "GPIOC" => cfgs.enable("gpioc_group"), | ||
| 677 | _ => (), | ||
| 678 | } | ||
| 679 | } | ||
| 680 | } | ||
| 681 | } | ||
| 682 | |||
| 649 | /// rustfmt a given path. | 683 | /// rustfmt a given path. |
| 650 | /// Failures are logged to stderr and ignored. | 684 | /// Failures are logged to stderr and ignored. |
| 651 | fn rustfmt(path: impl AsRef<Path>) { | 685 | fn rustfmt(path: impl AsRef<Path>) { |
