diff options
| author | i509VCB <[email protected]> | 2025-03-13 22:10:45 -0500 |
|---|---|---|
| committer | i509VCB <[email protected]> | 2025-03-13 22:10:45 -0500 |
| commit | e0cdc356ccd7f9e20c2b5355cc52b7eb7610147b (patch) | |
| tree | 0c34424508b1ee8d5010dc186247b72fac7aca69 /examples/mspm0g3507/src | |
| parent | 38f26137fc67beb874aa73c9a7ab2150d9f3d372 (diff) | |
Embassy for MSPM0
This adds an embassy hal for the Texas Instruments MSPM0 microcontroller series.
So far the GPIO and time drivers have been implemented. I have tested these drivers on the following parts:
- C1104
- L1306
- L2228
- G3507
- G3519
The PAC is generated at https://github.com/mspm0-rs
Diffstat (limited to 'examples/mspm0g3507/src')
| -rw-r--r-- | examples/mspm0g3507/src/bin/blinky.rs | 27 | ||||
| -rw-r--r-- | examples/mspm0g3507/src/bin/button.rs | 35 |
2 files changed, 62 insertions, 0 deletions
diff --git a/examples/mspm0g3507/src/bin/blinky.rs b/examples/mspm0g3507/src/bin/blinky.rs new file mode 100644 index 000000000..11eee2d80 --- /dev/null +++ b/examples/mspm0g3507/src/bin/blinky.rs | |||
| @@ -0,0 +1,27 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_mspm0::{ | ||
| 7 | gpio::{Level, Output}, | ||
| 8 | Config, | ||
| 9 | }; | ||
| 10 | use embassy_time::Timer; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | let p = embassy_mspm0::init(Config::default()); | ||
| 17 | |||
| 18 | let mut led1 = Output::new(p.PA0, Level::Low); | ||
| 19 | led1.set_inversion(true); | ||
| 20 | |||
| 21 | loop { | ||
| 22 | Timer::after_millis(400).await; | ||
| 23 | |||
| 24 | info!("Toggle"); | ||
| 25 | led1.toggle(); | ||
| 26 | } | ||
| 27 | } | ||
diff --git a/examples/mspm0g3507/src/bin/button.rs b/examples/mspm0g3507/src/bin/button.rs new file mode 100644 index 000000000..1d9a37c5c --- /dev/null +++ b/examples/mspm0g3507/src/bin/button.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | #![no_std] | ||
| 2 | #![no_main] | ||
| 3 | |||
| 4 | use defmt::*; | ||
| 5 | use embassy_executor::Spawner; | ||
| 6 | use embassy_mspm0::{ | ||
| 7 | gpio::{Input, Level, Output, Pull}, | ||
| 8 | Config, | ||
| 9 | }; | ||
| 10 | use {defmt_rtt as _, panic_halt as _}; | ||
| 11 | |||
| 12 | #[embassy_executor::main] | ||
| 13 | async fn main(_spawner: Spawner) -> ! { | ||
| 14 | info!("Hello world!"); | ||
| 15 | |||
| 16 | let p = embassy_mspm0::init(Config::default()); | ||
| 17 | |||
| 18 | let led1 = p.PA0; | ||
| 19 | let s2 = p.PB21; | ||
| 20 | |||
| 21 | let mut led1 = Output::new(led1, Level::Low); | ||
| 22 | |||
| 23 | let mut s2 = Input::new(s2, Pull::Up); | ||
| 24 | |||
| 25 | // led1 is active low | ||
| 26 | led1.set_high(); | ||
| 27 | |||
| 28 | loop { | ||
| 29 | s2.wait_for_falling_edge().await; | ||
| 30 | |||
| 31 | info!("Switch 2 was pressed"); | ||
| 32 | |||
| 33 | led1.toggle(); | ||
| 34 | } | ||
| 35 | } | ||
