aboutsummaryrefslogtreecommitdiff
path: root/embassy-mspm0/build.rs
diff options
context:
space:
mode:
authori509VCB <[email protected]>2025-12-13 21:23:22 -0600
committeri509VCB <[email protected]>2025-12-14 00:37:30 -0600
commit5bef2eab2352113c2ab9a97be72d72d6df46045d (patch)
tree40c43682d2c8e0ec6f714b8b0a20b4ec2e4a33a0 /embassy-mspm0/build.rs
parent574868282518ceb81bddcb03bee38fc5b6208a5a (diff)
mspm0: add MSPM0G518x support and new packages for others
G518x is the first MSPM0 part with a USB, I2S and NPU peripheral. There is also a new TIMB peripheral (no PWM, so it is perfect for a time driver). Unfortunately it also introduces UNICOMM which is a shared peripheral which can be in UART/I2C/SPI modes. This means that the current UART and I2C drivers need some adjustment to work with the new UNICOMM parts (which is the future).
Diffstat (limited to 'embassy-mspm0/build.rs')
-rw-r--r--embassy-mspm0/build.rs52
1 files changed, 44 insertions, 8 deletions
diff --git a/embassy-mspm0/build.rs b/embassy-mspm0/build.rs
index 0fe056c4e..ac40adbdf 100644
--- a/embassy-mspm0/build.rs
+++ b/embassy-mspm0/build.rs
@@ -31,7 +31,7 @@ fn generate_code(cfgs: &mut CfgSet) {
31 PathBuf::from(env::var_os("OUT_DIR").unwrap()).display(), 31 PathBuf::from(env::var_os("OUT_DIR").unwrap()).display(),
32 ); 32 );
33 33
34 cfgs.declare_all(&["gpio_pb", "gpio_pc", "int_group1"]); 34 cfgs.declare_all(&["gpio_pb", "gpio_pc", "int_group1", "unicomm"]);
35 35
36 let chip_name = match env::vars() 36 let chip_name = match env::vars()
37 .map(|(a, _)| a) 37 .map(|(a, _)| a)
@@ -116,6 +116,10 @@ fn get_chip_cfgs(chip_name: &str) -> Vec<String> {
116 cfgs.push("mspm0g351x".to_string()); 116 cfgs.push("mspm0g351x".to_string());
117 } 117 }
118 118
119 if chip_name.starts_with("mspm0g518") {
120 cfgs.push("mspm0g518x".to_string());
121 }
122
119 if chip_name.starts_with("mspm0h321") { 123 if chip_name.starts_with("mspm0h321") {
120 cfgs.push("mspm0h321x".to_string()); 124 cfgs.push("mspm0h321x".to_string());
121 } 125 }
@@ -300,6 +304,15 @@ fn get_singletons(cfgs: &mut common::CfgSet) -> Vec<Singleton> {
300 // by the HAL. 304 // by the HAL.
301 "iomux" | "cpuss" => true, 305 "iomux" | "cpuss" => true,
302 306
307 // Unicomm instances get their own singletons, but we need to enable a cfg for unicomm drivers.
308 "unicomm" => {
309 cfgs.enable("unicomm");
310 false
311 }
312
313 // TODO: Remove after TIMB is fixed
314 "tim" if peripheral.name.starts_with("TIMB") => true,
315
303 _ => false, 316 _ => false,
304 }; 317 };
305 318
@@ -423,6 +436,8 @@ fn time_driver(singletons: &mut Vec<Singleton>, cfgs: &mut CfgSet) {
423 // Verify the selected timer is available 436 // Verify the selected timer is available
424 let selected_timer = match time_driver.as_ref().map(|x| x.as_ref()) { 437 let selected_timer = match time_driver.as_ref().map(|x| x.as_ref()) {
425 None => "", 438 None => "",
439 // TODO: Fix TIMB0
440 // Some("timb0") => "TIMB0",
426 Some("timg0") => "TIMG0", 441 Some("timg0") => "TIMG0",
427 Some("timg1") => "TIMG1", 442 Some("timg1") => "TIMG1",
428 Some("timg2") => "TIMG2", 443 Some("timg2") => "TIMG2",
@@ -440,16 +455,17 @@ fn time_driver(singletons: &mut Vec<Singleton>, cfgs: &mut CfgSet) {
440 Some("tima1") => "TIMA1", 455 Some("tima1") => "TIMA1",
441 Some("any") => { 456 Some("any") => {
442 // Order of timer candidates: 457 // Order of timer candidates:
443 // 1. 16-bit, 2 channel 458 // 1. Basic timers
444 // 2. 16-bit, 2 channel with shadow registers 459 // 2. 16-bit, 2 channel
445 // 3. 16-bit, 4 channel 460 // 3. 16-bit, 2 channel with shadow registers
446 // 4. 16-bit with QEI 461 // 4. 16-bit, 4 channel
447 // 5. Advanced timers 462 // 5. 16-bit with QEI
463 // 6. Advanced timers
448 // 464 //
449 // TODO: Select RTC first if available
450 // TODO: 32-bit timers are not considered yet 465 // TODO: 32-bit timers are not considered yet
451 [ 466 [
452 // 16-bit, 2 channel 467 // basic timers. No PWM pins
468 // "TIMB0", // 16-bit, 2 channel
453 "TIMG0", "TIMG1", "TIMG2", "TIMG3", // 16-bit, 2 channel with shadow registers 469 "TIMG0", "TIMG1", "TIMG2", "TIMG3", // 16-bit, 2 channel with shadow registers
454 "TIMG4", "TIMG5", "TIMG6", "TIMG7", // 16-bit, 4 channel 470 "TIMG4", "TIMG5", "TIMG6", "TIMG7", // 16-bit, 4 channel
455 "TIMG14", // 16-bit with QEI 471 "TIMG14", // 16-bit with QEI
@@ -519,6 +535,8 @@ fn generate_timers() -> TokenStream {
519 .peripherals 535 .peripherals
520 .iter() 536 .iter()
521 .filter(|p| p.name.starts_with("TIM")) 537 .filter(|p| p.name.starts_with("TIM"))
538 // TODO: Fix TIMB when used at time driver.
539 .filter(|p| !p.name.starts_with("TIMB"))
522 .map(|peripheral| { 540 .map(|peripheral| {
523 let name = Ident::new(&peripheral.name, Span::call_site()); 541 let name = Ident::new(&peripheral.name, Span::call_site());
524 let timers = &*TIMERS; 542 let timers = &*TIMERS;
@@ -730,6 +748,24 @@ struct TimerDesc {
730const TIMERS: LazyLock<HashMap<String, TimerDesc>> = LazyLock::new(|| { 748const TIMERS: LazyLock<HashMap<String, TimerDesc>> = LazyLock::new(|| {
731 let mut map = HashMap::new(); 749 let mut map = HashMap::new();
732 map.insert( 750 map.insert(
751 "TIMB0".into(),
752 TimerDesc {
753 bits: 16,
754 prescaler: true,
755 repeat_counter: false,
756 ccp_channels_internal: 2,
757 ccp_channels_external: 2,
758 external_pwm_channels: 0,
759 phase_load: false,
760 shadow_load: false,
761 shadow_ccs: false,
762 deadband: false,
763 fault_handler: false,
764 qei_hall: false,
765 },
766 );
767
768 map.insert(
733 "TIMG0".into(), 769 "TIMG0".into(),
734 TimerDesc { 770 TimerDesc {
735 bits: 16, 771 bits: 16,