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 /examples/mspm0g5187/src/bin/button.rs | |
| 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 'examples/mspm0g5187/src/bin/button.rs')
| -rw-r--r-- | examples/mspm0g5187/src/bin/button.rs | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/examples/mspm0g5187/src/bin/button.rs b/examples/mspm0g5187/src/bin/button.rs new file mode 100644 index 000000000..2ed15e354 --- /dev/null +++ b/examples/mspm0g5187/src/bin/button.rs | |||
| @@ -0,0 +1,33 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_mspm0::Config; | ||
| 7 | use embassy_mspm0::gpio::{Input, Level, Output, Pull}; | ||
| 8 | use {defmt_rtt as _, panic_halt as _}; | ||
| 9 | |||
| 10 | #[embassy_executor::main] | ||
| 11 | async fn main(_spawner: Spawner) -> ! { | ||
| 12 | info!("Hello world!"); | ||
| 13 | |||
| 14 | let p = embassy_mspm0::init(Config::default()); | ||
| 15 | |||
| 16 | let led1 = p.PA0; | ||
| 17 | let s2 = p.PA7; | ||
| 18 | |||
| 19 | let mut led1 = Output::new(led1, Level::Low); | ||
| 20 | |||
| 21 | let mut s2 = Input::new(s2, Pull::Up); | ||
| 22 | |||
| 23 | // led1 is active low | ||
| 24 | led1.set_high(); | ||
| 25 | |||
| 26 | loop { | ||
| 27 | s2.wait_for_falling_edge().await; | ||
| 28 | |||
| 29 | info!("Switch 2 was pressed"); | ||
| 30 | |||
| 31 | led1.toggle(); | ||
| 32 | } | ||
| 33 | } | ||
