diff options
| author | i509VCB <[email protected]> | 2025-10-08 20:30:05 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-10-08 20:30:05 +0000 |
| commit | 35b0ba4ce0fed7588febe504e16bbf1788384f5a (patch) | |
| tree | ec566c03efa33467878cc5ddc73dc63069034b04 | |
| parent | 96b87658fc2c9cfd68358195c2dc03ebba2482a2 (diff) | |
| parent | c6799c2921780254319d293d37f33161f5fd1832 (diff) | |
Merge pull request #4733 from i509VCB/h321x
mspm0: add mspm0h321x support
| -rw-r--r-- | embassy-mspm0/CHANGELOG.md | 3 | ||||
| -rw-r--r-- | embassy-mspm0/Cargo.toml | 17 | ||||
| -rw-r--r-- | embassy-mspm0/build.rs | 50 | ||||
| -rw-r--r-- | embassy-mspm0/src/gpio.rs | 17 | ||||
| -rw-r--r-- | embassy-mspm0/src/i2c.rs | 4 |
5 files changed, 67 insertions, 24 deletions
diff --git a/embassy-mspm0/CHANGELOG.md b/embassy-mspm0/CHANGELOG.md index 40abca38b..948f0205d 100644 --- a/embassy-mspm0/CHANGELOG.md +++ b/embassy-mspm0/CHANGELOG.md | |||
| @@ -14,4 +14,5 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 | |||
| 14 | - feat: Add MSPM0C1105/C1106 support | 14 | - feat: Add MSPM0C1105/C1106 support |
| 15 | - feat: Add adc implementation (#4646) | 15 | - feat: Add adc implementation (#4646) |
| 16 | - fix: gpio OutputOpenDrain config (#4735) | 16 | - fix: gpio OutputOpenDrain config (#4735) |
| 17 | - fix: add MSPM0C1106 to build test matrix \ No newline at end of file | 17 | - fix: add MSPM0C1106 to build test matrix |
| 18 | - feat: add MSPM0H3216 support | ||
diff --git a/embassy-mspm0/Cargo.toml b/embassy-mspm0/Cargo.toml index 7245cd100..df6176ff6 100644 --- a/embassy-mspm0/Cargo.toml +++ b/embassy-mspm0/Cargo.toml | |||
| @@ -16,17 +16,18 @@ publish = false | |||
| 16 | build = [ | 16 | build = [ |
| 17 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1104dgs20", "time-driver-any"]}, | 17 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1104dgs20", "time-driver-any"]}, |
| 18 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1106rgz", "time-driver-any"]}, | 18 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0c1106rgz", "time-driver-any"]}, |
| 19 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1107ycj", "time-driver-any"]}, | ||
| 20 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1505pt", "time-driver-any"]}, | ||
| 21 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1519rhb", "time-driver-any"]}, | ||
| 22 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3105rhb", "time-driver-any"]}, | ||
| 19 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3507pm", "time-driver-any"]}, | 23 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3507pm", "time-driver-any"]}, |
| 20 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3519pz", "time-driver-any"]}, | 24 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3519pz", "time-driver-any"]}, |
| 25 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0h3216pt", "time-driver-any"]}, | ||
| 21 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1306rhb", "time-driver-any"]}, | 26 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1306rhb", "time-driver-any"]}, |
| 22 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l2228pn", "time-driver-any"]}, | 27 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l2228pn", "time-driver-any"]}, |
| 23 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1345dgs28", "time-driver-any"]}, | 28 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1345dgs28", "time-driver-any"]}, |
| 24 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1106dgs28", "time-driver-any"]}, | 29 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1106dgs28", "time-driver-any"]}, |
| 25 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1228pm", "time-driver-any"]}, | 30 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0l1228pt", "time-driver-any"]}, |
| 26 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1107ycj", "time-driver-any"]}, | ||
| 27 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g3105rhb", "time-driver-any"]}, | ||
| 28 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1505pt", "time-driver-any"]}, | ||
| 29 | {target = "thumbv6m-none-eabi", features = ["defmt", "mspm0g1519rhb", "time-driver-any"]}, | ||
| 30 | ] | 31 | ] |
| 31 | 32 | ||
| 32 | [package.metadata.embassy_docs] | 33 | [package.metadata.embassy_docs] |
| @@ -38,6 +39,7 @@ flavors = [ | |||
| 38 | { regex_feature = "mspm0c.*", target = "thumbv6m-none-eabi" }, | 39 | { regex_feature = "mspm0c.*", target = "thumbv6m-none-eabi" }, |
| 39 | { regex_feature = "mspm0l.*", target = "thumbv6m-none-eabi" }, | 40 | { regex_feature = "mspm0l.*", target = "thumbv6m-none-eabi" }, |
| 40 | { regex_feature = "mspm0g.*", target = "thumbv6m-none-eabi" }, | 41 | { regex_feature = "mspm0g.*", target = "thumbv6m-none-eabi" }, |
| 42 | { regex_feature = "mspm0h.*", target = "thumbv6m-none-eabi" }, | ||
| 41 | ] | 43 | ] |
| 42 | 44 | ||
| 43 | [package.metadata.docs.rs] | 45 | [package.metadata.docs.rs] |
| @@ -70,7 +72,7 @@ cortex-m = "0.7.6" | |||
| 70 | critical-section = "1.2.0" | 72 | critical-section = "1.2.0" |
| 71 | 73 | ||
| 72 | # mspm0-metapac = { version = "" } | 74 | # mspm0-metapac = { version = "" } |
| 73 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-d7bf3d01ac0780e716a45b0474234d39443dc5cf" } | 75 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-e7de4103a0713772695ffcad52c3c2f07414dc29" } |
| 74 | 76 | ||
| 75 | [build-dependencies] | 77 | [build-dependencies] |
| 76 | proc-macro2 = "1.0.94" | 78 | proc-macro2 = "1.0.94" |
| @@ -78,7 +80,7 @@ quote = "1.0.40" | |||
| 78 | cfg_aliases = "0.2.1" | 80 | cfg_aliases = "0.2.1" |
| 79 | 81 | ||
| 80 | # mspm0-metapac = { version = "", default-features = false, features = ["metadata"] } | 82 | # mspm0-metapac = { version = "", default-features = false, features = ["metadata"] } |
| 81 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-d7bf3d01ac0780e716a45b0474234d39443dc5cf", default-features = false, features = ["metadata"] } | 83 | mspm0-metapac = { git = "https://github.com/mspm0-rs/mspm0-data-generated/", tag = "mspm0-data-e7de4103a0713772695ffcad52c3c2f07414dc29", default-features = false, features = ["metadata"] } |
| 82 | 84 | ||
| 83 | [features] | 85 | [features] |
| 84 | default = ["rt"] | 86 | default = ["rt"] |
| @@ -244,6 +246,7 @@ mspm0g3519pn = ["mspm0-metapac/mspm0g3519pn"] | |||
| 244 | mspm0g3519pz = ["mspm0-metapac/mspm0g3519pz"] | 246 | mspm0g3519pz = ["mspm0-metapac/mspm0g3519pz"] |
| 245 | mspm0g3519rgz = ["mspm0-metapac/mspm0g3519rgz"] | 247 | mspm0g3519rgz = ["mspm0-metapac/mspm0g3519rgz"] |
| 246 | mspm0g3519rhb = ["mspm0-metapac/mspm0g3519rhb"] | 248 | mspm0g3519rhb = ["mspm0-metapac/mspm0g3519rhb"] |
| 249 | mspm0h3216pt = ["mspm0-metapac/mspm0h3216pt"] | ||
| 247 | mspm0l1105dgs20 = ["mspm0-metapac/mspm0l1105dgs20"] | 250 | mspm0l1105dgs20 = ["mspm0-metapac/mspm0l1105dgs20"] |
| 248 | mspm0l1105dgs28 = ["mspm0-metapac/mspm0l1105dgs28"] | 251 | mspm0l1105dgs28 = ["mspm0-metapac/mspm0l1105dgs28"] |
| 249 | mspm0l1105dyy = ["mspm0-metapac/mspm0l1105dyy"] | 252 | mspm0l1105dyy = ["mspm0-metapac/mspm0l1105dyy"] |
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>) { |
diff --git a/embassy-mspm0/src/gpio.rs b/embassy-mspm0/src/gpio.rs index 13da4f30b..d8eb42dc2 100644 --- a/embassy-mspm0/src/gpio.rs +++ b/embassy-mspm0/src/gpio.rs | |||
| @@ -10,7 +10,7 @@ use embassy_sync::waitqueue::AtomicWaker; | |||
| 10 | 10 | ||
| 11 | use crate::pac::gpio::vals::*; | 11 | use crate::pac::gpio::vals::*; |
| 12 | use crate::pac::gpio::{self}; | 12 | use crate::pac::gpio::{self}; |
| 13 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 13 | #[cfg(all(feature = "rt", any(gpioa_interrupt, gpiob_interrupt)))] |
| 14 | use crate::pac::interrupt; | 14 | use crate::pac::interrupt; |
| 15 | use crate::pac::{self}; | 15 | use crate::pac::{self}; |
| 16 | 16 | ||
| @@ -1110,16 +1110,21 @@ fn irq_handler(gpio: gpio::Gpio, wakers: &[AtomicWaker; 32]) { | |||
| 1110 | } | 1110 | } |
| 1111 | } | 1111 | } |
| 1112 | 1112 | ||
| 1113 | #[cfg(all(gpioa_interrupt, gpioa_group))] | ||
| 1114 | compile_error!("gpioa_interrupt and gpioa_group are mutually exclusive cfgs"); | ||
| 1115 | #[cfg(all(gpiob_interrupt, gpiob_group))] | ||
| 1116 | compile_error!("gpiob_interrupt and gpiob_group are mutually exclusive cfgs"); | ||
| 1117 | |||
| 1113 | // C110x and L110x have a dedicated interrupts just for GPIOA. | 1118 | // C110x and L110x have a dedicated interrupts just for GPIOA. |
| 1114 | // | 1119 | // |
| 1115 | // These chips do not have a GROUP1 interrupt. | 1120 | // These chips do not have a GROUP1 interrupt. |
| 1116 | #[cfg(all(feature = "rt", any(mspm0c110x, mspm0c1105_c1106, mspm0l110x)))] | 1121 | #[cfg(all(feature = "rt", gpioa_interrupt))] |
| 1117 | #[interrupt] | 1122 | #[interrupt] |
| 1118 | fn GPIOA() { | 1123 | fn GPIOA() { |
| 1119 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1124 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1120 | } | 1125 | } |
| 1121 | 1126 | ||
| 1122 | #[cfg(all(feature = "rt", mspm0c1105_c1106))] | 1127 | #[cfg(all(feature = "rt", gpiob_interrupt))] |
| 1123 | #[interrupt] | 1128 | #[interrupt] |
| 1124 | fn GPIOB() { | 1129 | fn GPIOB() { |
| 1125 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1130 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| @@ -1129,21 +1134,21 @@ fn GPIOB() { | |||
| 1129 | // | 1134 | // |
| 1130 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. | 1135 | // Defining these as no_mangle is required so that the linker will pick these over the default handler. |
| 1131 | 1136 | ||
| 1132 | #[cfg(all(feature = "rt", not(any(mspm0c110x, mspm0c1105_c1106, mspm0l110x))))] | 1137 | #[cfg(all(feature = "rt", gpioa_group))] |
| 1133 | #[unsafe(no_mangle)] | 1138 | #[unsafe(no_mangle)] |
| 1134 | #[allow(non_snake_case)] | 1139 | #[allow(non_snake_case)] |
| 1135 | fn GPIOA() { | 1140 | fn GPIOA() { |
| 1136 | irq_handler(pac::GPIOA, &PORTA_WAKERS); | 1141 | irq_handler(pac::GPIOA, &PORTA_WAKERS); |
| 1137 | } | 1142 | } |
| 1138 | 1143 | ||
| 1139 | #[cfg(all(feature = "rt", gpio_pb, not(mspm0c1105_c1106)))] | 1144 | #[cfg(all(feature = "rt", gpiob_group))] |
| 1140 | #[unsafe(no_mangle)] | 1145 | #[unsafe(no_mangle)] |
| 1141 | #[allow(non_snake_case)] | 1146 | #[allow(non_snake_case)] |
| 1142 | fn GPIOB() { | 1147 | fn GPIOB() { |
| 1143 | irq_handler(pac::GPIOB, &PORTB_WAKERS); | 1148 | irq_handler(pac::GPIOB, &PORTB_WAKERS); |
| 1144 | } | 1149 | } |
| 1145 | 1150 | ||
| 1146 | #[cfg(all(feature = "rt", gpio_pc))] | 1151 | #[cfg(all(feature = "rt", gpioc_group))] |
| 1147 | #[allow(non_snake_case)] | 1152 | #[allow(non_snake_case)] |
| 1148 | #[unsafe(no_mangle)] | 1153 | #[unsafe(no_mangle)] |
| 1149 | fn GPIOC() { | 1154 | fn GPIOC() { |
diff --git a/embassy-mspm0/src/i2c.rs b/embassy-mspm0/src/i2c.rs index a12b4b4a2..192527dd2 100644 --- a/embassy-mspm0/src/i2c.rs +++ b/embassy-mspm0/src/i2c.rs | |||
| @@ -206,8 +206,8 @@ impl Config { | |||
| 206 | } | 206 | } |
| 207 | 207 | ||
| 208 | #[cfg(any( | 208 | #[cfg(any( |
| 209 | mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0l110x, mspm0l122x, mspm0l130x, | 209 | mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0h321x, mspm0l110x, mspm0l122x, |
| 210 | mspm0l134x, mspm0l222x | 210 | mspm0l130x, mspm0l134x, mspm0l222x |
| 211 | ))] | 211 | ))] |
| 212 | fn calculate_clock_source(&self) -> u32 { | 212 | fn calculate_clock_source(&self) -> u32 { |
| 213 | // Assume that BusClk has default value. | 213 | // Assume that BusClk has default value. |
