aboutsummaryrefslogtreecommitdiff
path: root/examples/mspm0c1104/src/bin/uart.rs
blob: da611aaacbf5b7427b8789172fbdbc9cbba81d6a (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
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));
    }
}