diff options
| author | i509VCB <[email protected]> | 2025-12-13 21:23:22 -0600 |
|---|---|---|
| committer | i509VCB <[email protected]> | 2025-12-14 00:37:30 -0600 |
| commit | 5bef2eab2352113c2ab9a97be72d72d6df46045d (patch) | |
| tree | 40c43682d2c8e0ec6f714b8b0a20b4ec2e4a33a0 /embassy-mspm0/src | |
| parent | 574868282518ceb81bddcb03bee38fc5b6208a5a (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/src')
| -rw-r--r-- | embassy-mspm0/src/gpio.rs | 4 | ||||
| -rw-r--r-- | embassy-mspm0/src/i2c_target.rs | 9 | ||||
| -rw-r--r-- | embassy-mspm0/src/lib.rs | 16 | ||||
| -rw-r--r-- | embassy-mspm0/src/macros.rs | 1 | ||||
| -rw-r--r-- | embassy-mspm0/src/time_driver.rs | 4 |
5 files changed, 24 insertions, 10 deletions
diff --git a/embassy-mspm0/src/gpio.rs b/embassy-mspm0/src/gpio.rs index d8eb42dc2..709102c59 100644 --- a/embassy-mspm0/src/gpio.rs +++ b/embassy-mspm0/src/gpio.rs | |||
| @@ -841,6 +841,7 @@ impl<'d> embedded_hal_async::digital::Wait for OutputOpenDrain<'d> { | |||
| 841 | } | 841 | } |
| 842 | } | 842 | } |
| 843 | 843 | ||
| 844 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 844 | #[derive(Copy, Clone)] | 845 | #[derive(Copy, Clone)] |
| 845 | pub struct PfType { | 846 | pub struct PfType { |
| 846 | pull: Pull, | 847 | pull: Pull, |
| @@ -948,6 +949,7 @@ pub(crate) trait SealedPin { | |||
| 948 | }); | 949 | }); |
| 949 | } | 950 | } |
| 950 | 951 | ||
| 952 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 951 | fn update_pf(&self, ty: PfType) { | 953 | fn update_pf(&self, ty: PfType) { |
| 952 | let pincm = pac::IOMUX.pincm(self._pin_cm() as usize); | 954 | let pincm = pac::IOMUX.pincm(self._pin_cm() as usize); |
| 953 | let pf = pincm.read().pf(); | 955 | let pf = pincm.read().pf(); |
| @@ -955,6 +957,7 @@ pub(crate) trait SealedPin { | |||
| 955 | set_pf(self._pin_cm() as usize, pf, ty); | 957 | set_pf(self._pin_cm() as usize, pf, ty); |
| 956 | } | 958 | } |
| 957 | 959 | ||
| 960 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 958 | fn set_as_pf(&self, pf: u8, ty: PfType) { | 961 | fn set_as_pf(&self, pf: u8, ty: PfType) { |
| 959 | set_pf(self._pin_cm() as usize, pf, ty) | 962 | set_pf(self._pin_cm() as usize, pf, ty) |
| 960 | } | 963 | } |
| @@ -967,6 +970,7 @@ pub(crate) trait SealedPin { | |||
| 967 | /// | 970 | /// |
| 968 | /// Note that this also disables the internal weak pull-up and pull-down resistors. | 971 | /// Note that this also disables the internal weak pull-up and pull-down resistors. |
| 969 | #[inline] | 972 | #[inline] |
| 973 | #[cfg_attr(mspm0g518x, allow(dead_code))] | ||
| 970 | fn set_as_disconnected(&self) { | 974 | fn set_as_disconnected(&self) { |
| 971 | self.set_as_analog(); | 975 | self.set_as_analog(); |
| 972 | } | 976 | } |
diff --git a/embassy-mspm0/src/i2c_target.rs b/embassy-mspm0/src/i2c_target.rs index 86be91415..e371fa903 100644 --- a/embassy-mspm0/src/i2c_target.rs +++ b/embassy-mspm0/src/i2c_target.rs | |||
| @@ -12,12 +12,13 @@ use embassy_embedded_hal::SetConfig; | |||
| 12 | use mspm0_metapac::i2c::vals::CpuIntIidxStat; | 12 | use mspm0_metapac::i2c::vals::CpuIntIidxStat; |
| 13 | 13 | ||
| 14 | use crate::gpio::{AnyPin, SealedPin}; | 14 | use crate::gpio::{AnyPin, SealedPin}; |
| 15 | use crate::interrupt::InterruptExt; | ||
| 16 | use crate::mode::{Async, Blocking, Mode}; | ||
| 17 | use crate::pac::{self, i2c::vals}; | ||
| 18 | use crate::{i2c, i2c_target, interrupt, Peri}; | ||
| 19 | // Re-use I2c controller types | 15 | // Re-use I2c controller types |
| 20 | use crate::i2c::{ClockSel, ConfigError, Info, Instance, InterruptHandler, SclPin, SdaPin, State}; | 16 | use crate::i2c::{ClockSel, ConfigError, Info, Instance, InterruptHandler, SclPin, SdaPin, State}; |
| 17 | use crate::interrupt::InterruptExt; | ||
| 18 | use crate::mode::{Async, Blocking, Mode}; | ||
| 19 | use crate::pac::i2c::vals; | ||
| 20 | use crate::pac::{self}; | ||
| 21 | use crate::{Peri, i2c, i2c_target, interrupt}; | ||
| 21 | 22 | ||
| 22 | #[non_exhaustive] | 23 | #[non_exhaustive] |
| 23 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] | 24 | #[derive(Clone, Copy, PartialEq, Eq, Debug)] |
diff --git a/embassy-mspm0/src/lib.rs b/embassy-mspm0/src/lib.rs index c43c81853..548fb33ca 100644 --- a/embassy-mspm0/src/lib.rs +++ b/embassy-mspm0/src/lib.rs | |||
| @@ -8,20 +8,23 @@ | |||
| 8 | )] | 8 | )] |
| 9 | #![doc = include_str!("../README.md")] | 9 | #![doc = include_str!("../README.md")] |
| 10 | 10 | ||
| 11 | // This mod MUST go first, so that the others see its macros. | 11 | // These mods MUST go first, so that the others see the macros. |
| 12 | pub(crate) mod fmt; | 12 | pub(crate) mod fmt; |
| 13 | |||
| 14 | // This must be declared early as well for | ||
| 15 | mod macros; | 13 | mod macros; |
| 16 | 14 | ||
| 17 | pub mod adc; | 15 | pub mod adc; |
| 18 | pub mod dma; | 16 | pub mod dma; |
| 19 | pub mod gpio; | 17 | pub mod gpio; |
| 18 | // TODO: I2C unicomm | ||
| 19 | #[cfg(not(unicomm))] | ||
| 20 | pub mod i2c; | 20 | pub mod i2c; |
| 21 | #[cfg(not(unicomm))] | ||
| 21 | pub mod i2c_target; | 22 | pub mod i2c_target; |
| 22 | #[cfg(any(mspm0g150x, mspm0g151x, mspm0g350x, mspm0g351x))] | 23 | #[cfg(any(mspm0g150x, mspm0g151x, mspm0g350x, mspm0g351x))] |
| 23 | pub mod mathacl; | 24 | pub mod mathacl; |
| 24 | pub mod timer; | 25 | pub mod timer; |
| 26 | // TODO: UART unicomm | ||
| 27 | #[cfg(not(unicomm))] | ||
| 25 | pub mod uart; | 28 | pub mod uart; |
| 26 | pub mod wwdt; | 29 | pub mod wwdt; |
| 27 | 30 | ||
| @@ -276,7 +279,7 @@ pub enum ResetCause { | |||
| 276 | /// WWDT0 violation | 279 | /// WWDT0 violation |
| 277 | BootrstWwdt0Violation, | 280 | BootrstWwdt0Violation, |
| 278 | /// WWDT1 violation (G-series only) | 281 | /// WWDT1 violation (G-series only) |
| 279 | #[cfg(any(mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x))] | 282 | #[cfg(any(mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0g518x))] |
| 280 | SysrstWwdt1Violation, | 283 | SysrstWwdt1Violation, |
| 281 | /// BSL exit (if present) | 284 | /// BSL exit (if present) |
| 282 | SysrstBslExit, | 285 | SysrstBslExit, |
| @@ -326,7 +329,8 @@ pub fn read_reset_cause() -> Result<ResetCause, u8> { | |||
| 326 | mspm0g151x, | 329 | mspm0g151x, |
| 327 | mspm0g310x, | 330 | mspm0g310x, |
| 328 | mspm0g350x, | 331 | mspm0g350x, |
| 329 | mspm0g351x | 332 | mspm0g351x, |
| 333 | mspm0g518x, | ||
| 330 | )))] | 334 | )))] |
| 331 | Id::BOOTNONPMUPARITY => Ok(BootrstNonPmuParityFault), | 335 | Id::BOOTNONPMUPARITY => Ok(BootrstNonPmuParityFault), |
| 332 | Id::BOOTCLKFAIL => Ok(BootrstClockFault), | 336 | Id::BOOTCLKFAIL => Ok(BootrstClockFault), |
| @@ -335,7 +339,7 @@ pub fn read_reset_cause() -> Result<ResetCause, u8> { | |||
| 335 | Id::BOOTWWDT0 => Ok(BootrstWwdt0Violation), | 339 | Id::BOOTWWDT0 => Ok(BootrstWwdt0Violation), |
| 336 | Id::SYSBSLEXIT => Ok(SysrstBslExit), | 340 | Id::SYSBSLEXIT => Ok(SysrstBslExit), |
| 337 | Id::SYSBSLENTRY => Ok(SysrstBslEntry), | 341 | Id::SYSBSLENTRY => Ok(SysrstBslEntry), |
| 338 | #[cfg(any(mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x))] | 342 | #[cfg(any(mspm0g110x, mspm0g150x, mspm0g151x, mspm0g310x, mspm0g350x, mspm0g351x, mspm0g518x))] |
| 339 | Id::SYSWWDT1 => Ok(SysrstWwdt1Violation), | 343 | Id::SYSWWDT1 => Ok(SysrstWwdt1Violation), |
| 340 | #[cfg(not(any(mspm0c110x, mspm0c1105_c1106, mspm0g351x, mspm0g151x)))] | 344 | #[cfg(not(any(mspm0c110x, mspm0c1105_c1106, mspm0g351x, mspm0g151x)))] |
| 341 | Id::SYSFLASHECC => Ok(SysrstFlashEccError), | 345 | Id::SYSFLASHECC => Ok(SysrstFlashEccError), |
diff --git a/embassy-mspm0/src/macros.rs b/embassy-mspm0/src/macros.rs index 5355e7d59..3a12a528a 100644 --- a/embassy-mspm0/src/macros.rs +++ b/embassy-mspm0/src/macros.rs | |||
| @@ -1,5 +1,6 @@ | |||
| 1 | #![macro_use] | 1 | #![macro_use] |
| 2 | 2 | ||
| 3 | #[allow(unused)] | ||
| 3 | macro_rules! new_pin { | 4 | macro_rules! new_pin { |
| 4 | ($name: ident, $pf_type: expr) => {{ | 5 | ($name: ident, $pf_type: expr) => {{ |
| 5 | let pin = $name; | 6 | let pin = $name; |
diff --git a/embassy-mspm0/src/time_driver.rs b/embassy-mspm0/src/time_driver.rs index 0743c667b..b42ff61c2 100644 --- a/embassy-mspm0/src/time_driver.rs +++ b/embassy-mspm0/src/time_driver.rs | |||
| @@ -16,6 +16,8 @@ use crate::timer::SealedTimer; | |||
| 16 | compile_error!("TIMG12 and TIMG13 are not supported by the time driver yet"); | 16 | compile_error!("TIMG12 and TIMG13 are not supported by the time driver yet"); |
| 17 | 17 | ||
| 18 | // Currently TIMG12 and TIMG13 are excluded because those are 32-bit timers. | 18 | // Currently TIMG12 and TIMG13 are excluded because those are 32-bit timers. |
| 19 | #[cfg(time_driver_timb0)] | ||
| 20 | type T = peripherals::TIMB0; | ||
| 19 | #[cfg(time_driver_timg0)] | 21 | #[cfg(time_driver_timg0)] |
| 20 | type T = peripherals::TIMG0; | 22 | type T = peripherals::TIMG0; |
| 21 | #[cfg(time_driver_timg1)] | 23 | #[cfg(time_driver_timg1)] |
| @@ -333,6 +335,8 @@ pub(crate) fn init(cs: CriticalSection) { | |||
| 333 | DRIVER.init(cs); | 335 | DRIVER.init(cs); |
| 334 | } | 336 | } |
| 335 | 337 | ||
| 338 | // TODO: TIMB0 | ||
| 339 | |||
| 336 | #[cfg(time_driver_timg0)] | 340 | #[cfg(time_driver_timg0)] |
| 337 | #[interrupt] | 341 | #[interrupt] |
| 338 | fn TIMG0() { | 342 | fn TIMG0() { |
