gba/examples/uart_echo.rs
Michael Mogenson 00897a0657
SioSerial improvements (#100)
Make a few improvements to the SioSerial struct:
- Have init() return Self. It's more ergonomic to create and initialize
the empty struct in one call.
- Enable FIFO. The GBA has a 4-byte UART FIFO. This makes it less
likely to lose received bytes.
- Derive Clone on SioSerial so it can be split and shared with an
interrupt.
- Derive Debug on SioError so results can be unwrapped.
2021-01-12 14:42:56 -07:00

31 lines
600 B
Rust

#![no_std]
#![feature(start)]
// _ Link Cable Pinout
// ___/ \___ 1: VCC - 3.3V
// / \ 2: SO - TX
// | 1 3 5 | 3: SI - RX
// | 2 4 6 | 4: SD
// |_________| 5: SC
// 6: GND
use embedded_hal::prelude::*;
use gba::io::sio::{BaudRate, SioSerial};
use nb::block;
#[panic_handler]
fn panic(_info: &core::panic::PanicInfo) -> ! {
loop {}
}
#[start]
fn main(_argc: isize, _argv: *const *const u8) -> isize {
let mut serial = SioSerial::init(BaudRate::Bps115200);
loop {
if let Ok(c) = block!(serial.read()) {
block!(serial.write(c)).ok();
}
}
}