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
36
37
38
39
//! A loopback device. Send characters, and you should see
//! the exact same characters sent back. The LED toggles for
//! every exchanged character.
//!
//! Baud: 115200bps.
#![no_main]
#![no_std]
use eh02::{
blocking::serial::Write,
serial::{Read, Write as NbWrite},
};
/// Change me to affect the kind of serial writes
/// that the example tests. If this is zero, the example
/// uses the non-blocking write. Otherwise, it uses the
/// blocking write of a buffer this size.
const ECHO_RESPONSE_SIZE: usize = 0;
#[imxrt_rt::entry]
fn main() -> ! {
let (
_,
board::Specifics {
led, mut console, ..
},
) = board::new();
loop {
led.toggle();
let byte = nb::block!(console.read()).unwrap();
if ECHO_RESPONSE_SIZE == 0 {
nb::block!(NbWrite::write(&mut console, byte)).unwrap();
} else {
let response: [u8; ECHO_RESPONSE_SIZE] = [byte; ECHO_RESPONSE_SIZE];
console.bwrite_all(&response).unwrap();
}
}
}