aboutsummaryrefslogtreecommitdiff
path: root/examples/mspm0l1306/src/bin/uart.rs
diff options
context:
space:
mode:
Diffstat (limited to 'examples/mspm0l1306/src/bin/uart.rs')
-rw-r--r--examples/mspm0l1306/src/bin/uart.rs35
1 files changed, 35 insertions, 0 deletions
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
8use defmt::*;
9use embassy_executor::Spawner;
10use embassy_mspm0::uart::{Config, Uart};
11use {defmt_rtt as _, panic_halt as _};
12
13#[embassy_executor::main]
14async 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}