mirror of
https://github.com/italicsjenga/gba.git
synced 2024-12-24 03:11:29 +11:00
51c870281c
* Add Serial and GPIO registers and implement embedded_hal traits Use VolAddress and phantom_fields to populate the SIOCNT, RCNT, and SIODATA8 registers. Implement embedded_hal serial traits around an empty SioSerial struct. Hide serial read and write traits behind a "serial" feature flag to make embedded-hal and nb dependencies optional. * UART echo example Enable the serial feature for this example. Provide a pinout diagram to assist people with wiring up a USB to UART adapter.
32 lines
606 B
Rust
32 lines
606 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
// _ 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;
|
|
SioSerial::init(BaudRate::Bps115200);
|
|
|
|
loop {
|
|
if let Ok(c) = block!(serial.read()) {
|
|
block!(serial.write(c)).ok();
|
|
}
|
|
}
|
|
}
|