diff options
| author | i509VCB <[email protected]> | 2025-03-22 17:52:13 -0500 |
|---|---|---|
| committer | i509VCB <[email protected]> | 2025-03-29 00:21:29 -0500 |
| commit | 91cde689cc0c771ffeb3864eb41e88104d476b47 (patch) | |
| tree | dafaecbf60d85381bb16faee9d5bfdab90c82646 /examples | |
| parent | 954d1554d4c04a245adadb5ebd97205d1442635e (diff) | |
mspm0: blocking uart driver
Diffstat (limited to 'examples')
| -rw-r--r-- | examples/mspm0c1104/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mspm0c1104/src/bin/uart.rs | 35 | ||||
| -rw-r--r-- | examples/mspm0g3507/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mspm0g3507/src/bin/uart.rs | 35 | ||||
| -rw-r--r-- | examples/mspm0g3519/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mspm0g3519/src/bin/uart.rs | 35 | ||||
| -rw-r--r-- | examples/mspm0l1306/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mspm0l1306/src/bin/uart.rs | 35 | ||||
| -rw-r--r-- | examples/mspm0l2228/Cargo.toml | 2 | ||||
| -rw-r--r-- | examples/mspm0l2228/src/bin/uart.rs | 35 |
10 files changed, 180 insertions, 5 deletions
diff --git a/examples/mspm0c1104/Cargo.toml b/examples/mspm0c1104/Cargo.toml index 7c382482a..ba64a578d 100644 --- a/examples/mspm0c1104/Cargo.toml +++ b/examples/mspm0c1104/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0c110x", "rt", "time-driver-any"] } | 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0c110x", "defmt", "rt", "time-driver-any"] } |
| 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } |
diff --git a/examples/mspm0c1104/src/bin/uart.rs b/examples/mspm0c1104/src/bin/uart.rs new file mode 100644 index 000000000..da611aaac --- /dev/null +++ b/examples/mspm0c1104/src/bin/uart.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! Example of using blocking uart | ||
| 2 | //! | ||
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0C1104 board. | ||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_mspm0::uart::{Config, Uart}; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | |||
| 17 | let p = embassy_mspm0::init(Default::default()); | ||
| 18 | |||
| 19 | let instance = p.UART0; | ||
| 20 | let tx = p.PA27; | ||
| 21 | let rx = p.PA26; | ||
| 22 | |||
| 23 | let config = Config::default(); | ||
| 24 | let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config)); | ||
| 25 | |||
| 26 | unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n")); | ||
| 27 | info!("wrote Hello, starting echo"); | ||
| 28 | |||
| 29 | let mut buf = [0u8; 1]; | ||
| 30 | |||
| 31 | loop { | ||
| 32 | unwrap!(uart.blocking_read(&mut buf)); | ||
| 33 | unwrap!(uart.blocking_write(&buf)); | ||
| 34 | } | ||
| 35 | } | ||
diff --git a/examples/mspm0g3507/Cargo.toml b/examples/mspm0g3507/Cargo.toml index 9bc82151c..f6fed091d 100644 --- a/examples/mspm0g3507/Cargo.toml +++ b/examples/mspm0g3507/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g350x", "rt", "time-driver-any"] } | 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g350x", "defmt", "rt", "time-driver-any"] } |
| 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } |
diff --git a/examples/mspm0g3507/src/bin/uart.rs b/examples/mspm0g3507/src/bin/uart.rs new file mode 100644 index 000000000..7e7e6db0e --- /dev/null +++ b/examples/mspm0g3507/src/bin/uart.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! Example of using blocking uart | ||
| 2 | //! | ||
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0G3507 board. | ||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_mspm0::uart::{Config, Uart}; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | |||
| 17 | let p = embassy_mspm0::init(Default::default()); | ||
| 18 | |||
| 19 | let instance = p.UART0; | ||
| 20 | let tx = p.PA10; | ||
| 21 | let rx = p.PA11; | ||
| 22 | |||
| 23 | let config = Config::default(); | ||
| 24 | let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config)); | ||
| 25 | |||
| 26 | unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n")); | ||
| 27 | info!("wrote Hello, starting echo"); | ||
| 28 | |||
| 29 | let mut buf = [0u8; 1]; | ||
| 30 | |||
| 31 | loop { | ||
| 32 | unwrap!(uart.blocking_read(&mut buf)); | ||
| 33 | unwrap!(uart.blocking_write(&buf)); | ||
| 34 | } | ||
| 35 | } | ||
diff --git a/examples/mspm0g3519/Cargo.toml b/examples/mspm0g3519/Cargo.toml index a28ce2f11..1662e1f8d 100644 --- a/examples/mspm0g3519/Cargo.toml +++ b/examples/mspm0g3519/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g351x", "rt", "time-driver-any"] } | 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g351x", "defmt", "rt", "time-driver-any"] } |
| 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } |
diff --git a/examples/mspm0g3519/src/bin/uart.rs b/examples/mspm0g3519/src/bin/uart.rs new file mode 100644 index 000000000..498377c61 --- /dev/null +++ b/examples/mspm0g3519/src/bin/uart.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! Example of using blocking uart | ||
| 2 | //! | ||
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0G3519 board. | ||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_mspm0::uart::{Config, Uart}; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | |||
| 17 | let p = embassy_mspm0::init(Default::default()); | ||
| 18 | |||
| 19 | let instance = p.UART0; | ||
| 20 | let tx = p.PA10; | ||
| 21 | let rx = p.PA11; | ||
| 22 | |||
| 23 | let config = Config::default(); | ||
| 24 | let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config)); | ||
| 25 | |||
| 26 | unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n")); | ||
| 27 | info!("wrote Hello, starting echo"); | ||
| 28 | |||
| 29 | let mut buf = [0u8; 1]; | ||
| 30 | |||
| 31 | loop { | ||
| 32 | unwrap!(uart.blocking_read(&mut buf)); | ||
| 33 | unwrap!(uart.blocking_write(&buf)); | ||
| 34 | } | ||
| 35 | } | ||
diff --git a/examples/mspm0l1306/Cargo.toml b/examples/mspm0l1306/Cargo.toml index 3962eb156..609b3f205 100644 --- a/examples/mspm0l1306/Cargo.toml +++ b/examples/mspm0l1306/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l130x", "rt", "time-driver-any"] } | 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l130x", "defmt", "rt", "time-driver-any"] } |
| 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } |
diff --git a/examples/mspm0l1306/src/bin/uart.rs b/examples/mspm0l1306/src/bin/uart.rs new file mode 100644 index 000000000..95c56fdd3 --- /dev/null +++ b/examples/mspm0l1306/src/bin/uart.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! Example of using blocking uart | ||
| 2 | //! | ||
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0L1306 board. | ||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_mspm0::uart::{Config, Uart}; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | |||
| 17 | let p = embassy_mspm0::init(Default::default()); | ||
| 18 | |||
| 19 | let instance = p.UART0; | ||
| 20 | let tx = p.PA8; | ||
| 21 | let rx = p.PA9; | ||
| 22 | |||
| 23 | let config = Config::default(); | ||
| 24 | let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config)); | ||
| 25 | |||
| 26 | unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n")); | ||
| 27 | info!("wrote Hello, starting echo"); | ||
| 28 | |||
| 29 | let mut buf = [0u8; 1]; | ||
| 30 | |||
| 31 | loop { | ||
| 32 | unwrap!(uart.blocking_read(&mut buf)); | ||
| 33 | unwrap!(uart.blocking_write(&buf)); | ||
| 34 | } | ||
| 35 | } | ||
diff --git a/examples/mspm0l2228/Cargo.toml b/examples/mspm0l2228/Cargo.toml index abebcc00d..bbca011a1 100644 --- a/examples/mspm0l2228/Cargo.toml +++ b/examples/mspm0l2228/Cargo.toml | |||
| @@ -5,7 +5,7 @@ version = "0.1.0" | |||
| 5 | license = "MIT OR Apache-2.0" | 5 | license = "MIT OR Apache-2.0" |
| 6 | 6 | ||
| 7 | [dependencies] | 7 | [dependencies] |
| 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l222x", "rt", "time-driver-any"] } | 8 | embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l222x", "defmt", "rt", "time-driver-any"] } |
| 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } | 9 | embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] } |
| 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } | 10 | embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] } |
| 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } | 11 | embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] } |
diff --git a/examples/mspm0l2228/src/bin/uart.rs b/examples/mspm0l2228/src/bin/uart.rs new file mode 100644 index 000000000..a266add47 --- /dev/null +++ b/examples/mspm0l2228/src/bin/uart.rs | |||
| @@ -0,0 +1,35 @@ | |||
| 1 | //! Example of using blocking uart | ||
| 2 | //! | ||
| 3 | //! This uses the virtual COM port provided on the LP-MSPM0L2228 board. | ||
| 4 | |||
| 5 | #![no_std] | ||
| 6 | #![no_main] | ||
| 7 | |||
| 8 | use defmt::*; | ||
| 9 | use embassy_executor::Spawner; | ||
| 10 | use embassy_mspm0::uart::{Config, Uart}; | ||
| 11 | use {defmt_rtt as _, panic_halt as _}; | ||
| 12 | |||
| 13 | #[embassy_executor::main] | ||
| 14 | async fn main(_spawner: Spawner) -> ! { | ||
| 15 | info!("Hello world!"); | ||
| 16 | |||
| 17 | let p = embassy_mspm0::init(Default::default()); | ||
| 18 | |||
| 19 | let instance = p.UART0; | ||
| 20 | let tx = p.PA10; | ||
| 21 | let rx = p.PA11; | ||
| 22 | |||
| 23 | let config = Config::default(); | ||
| 24 | let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config)); | ||
| 25 | |||
| 26 | unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n")); | ||
| 27 | info!("wrote Hello, starting echo"); | ||
| 28 | |||
| 29 | let mut buf = [0u8; 1]; | ||
| 30 | |||
| 31 | loop { | ||
| 32 | unwrap!(uart.blocking_read(&mut buf)); | ||
| 33 | unwrap!(uart.blocking_write(&buf)); | ||
| 34 | } | ||
| 35 | } | ||
