mspm0: blocking uart driver

This commit is contained in:
i509VCB
2025-03-22 17:52:13 -05:00
parent 954d1554d4
commit 91cde689cc
16 changed files with 1355 additions and 10 deletions

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0c110x", "rt", "time-driver-any"] }
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0c110x", "defmt", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }

View File

@@ -0,0 +1,35 @@
//! Example of using blocking uart
//!
//! This uses the virtual COM port provided on the LP-MSPM0C1104 board.
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::uart::{Config, Uart};
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Default::default());
let instance = p.UART0;
let tx = p.PA27;
let rx = p.PA26;
let config = Config::default();
let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config));
unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n"));
info!("wrote Hello, starting echo");
let mut buf = [0u8; 1];
loop {
unwrap!(uart.blocking_read(&mut buf));
unwrap!(uart.blocking_write(&buf));
}
}

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g350x", "rt", "time-driver-any"] }
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g350x", "defmt", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }

View File

@@ -0,0 +1,35 @@
//! Example of using blocking uart
//!
//! This uses the virtual COM port provided on the LP-MSPM0G3507 board.
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::uart::{Config, Uart};
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Default::default());
let instance = p.UART0;
let tx = p.PA10;
let rx = p.PA11;
let config = Config::default();
let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config));
unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n"));
info!("wrote Hello, starting echo");
let mut buf = [0u8; 1];
loop {
unwrap!(uart.blocking_read(&mut buf));
unwrap!(uart.blocking_write(&buf));
}
}

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g351x", "rt", "time-driver-any"] }
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0g351x", "defmt", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }

View File

@@ -0,0 +1,35 @@
//! Example of using blocking uart
//!
//! This uses the virtual COM port provided on the LP-MSPM0G3519 board.
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::uart::{Config, Uart};
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Default::default());
let instance = p.UART0;
let tx = p.PA10;
let rx = p.PA11;
let config = Config::default();
let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config));
unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n"));
info!("wrote Hello, starting echo");
let mut buf = [0u8; 1];
loop {
unwrap!(uart.blocking_read(&mut buf));
unwrap!(uart.blocking_write(&buf));
}
}

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l130x", "rt", "time-driver-any"] }
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l130x", "defmt", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }

View File

@@ -0,0 +1,35 @@
//! Example of using blocking uart
//!
//! This uses the virtual COM port provided on the LP-MSPM0L1306 board.
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::uart::{Config, Uart};
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Default::default());
let instance = p.UART0;
let tx = p.PA8;
let rx = p.PA9;
let config = Config::default();
let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config));
unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n"));
info!("wrote Hello, starting echo");
let mut buf = [0u8; 1];
loop {
unwrap!(uart.blocking_read(&mut buf));
unwrap!(uart.blocking_write(&buf));
}
}

View File

@@ -5,7 +5,7 @@ version = "0.1.0"
license = "MIT OR Apache-2.0"
[dependencies]
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l222x", "rt", "time-driver-any"] }
embassy-mspm0 = { version = "0.1.0", path = "../../embassy-mspm0", features = ["mspm0l222x", "defmt", "rt", "time-driver-any"] }
embassy-executor = { version = "0.7.0", path = "../../embassy-executor", features = ["arch-cortex-m", "executor-thread", "executor-interrupt"] }
embassy-sync = { version = "0.6.2", path = "../../embassy-sync", features = ["defmt"] }
embassy-time = { version = "0.4.0", path = "../../embassy-time", features = ["defmt"] }

View File

@@ -0,0 +1,35 @@
//! Example of using blocking uart
//!
//! This uses the virtual COM port provided on the LP-MSPM0L2228 board.
#![no_std]
#![no_main]
use defmt::*;
use embassy_executor::Spawner;
use embassy_mspm0::uart::{Config, Uart};
use {defmt_rtt as _, panic_halt as _};
#[embassy_executor::main]
async fn main(_spawner: Spawner) -> ! {
info!("Hello world!");
let p = embassy_mspm0::init(Default::default());
let instance = p.UART0;
let tx = p.PA10;
let rx = p.PA11;
let config = Config::default();
let mut uart = unwrap!(Uart::new_blocking(instance, rx, tx, config));
unwrap!(uart.blocking_write(b"Hello Embassy World!\r\n"));
info!("wrote Hello, starting echo");
let mut buf = [0u8; 1];
loop {
unwrap!(uart.blocking_read(&mut buf));
unwrap!(uart.blocking_write(&buf));
}
}