[wip] add serial configuration
This commit is contained in:
parent
bf6d3f7f16
commit
d588405d28
|
@ -0,0 +1,30 @@
|
||||||
|
# Connecting RPi3 UART
|
||||||
|
|
||||||
|
## Using cp2104 usb-to-ttl converter
|
||||||
|
|
||||||
|
Download drivers from: https://www.silabs.com/products/development-tools/software/usb-to-uart-bridge-vcp-drivers
|
||||||
|
|
||||||
|
Install `minicom`: `brew install minicom`
|
||||||
|
|
||||||
|
Configure minicom to use `/dev/tty.SLAB_USBtoUART` port.
|
||||||
|
|
||||||
|
Connect rpi wires to cp2014:
|
||||||
|
|
||||||
|
```
|
||||||
|
UART0
|
||||||
|
|
||||||
|
FUNC | GPIO | PIN # | MODE | Wire color
|
||||||
|
------+--------+---------+--------+------------
|
||||||
|
RXD0 | GPIO15 | 10 | Alt0 | Brown
|
||||||
|
TXD0 | GPIO14 | 8 | Alt0 | Red
|
||||||
|
```
|
||||||
|
|
||||||
|
```
|
||||||
|
MiniUart (UART1)
|
||||||
|
|
||||||
|
FUNC | GPIO | PIN # | MODE | Wire color
|
||||||
|
------+--------+---------+--------+------------
|
||||||
|
RXD1 | GPIO15 | 10 | Alt5 | Brown
|
||||||
|
TXD1 | GPIO14 | 8 | Alt5 | Red
|
||||||
|
GND | GND | 6 | | Green
|
||||||
|
```
|
71
src/main.rs
71
src/main.rs
|
@ -55,41 +55,52 @@ use platform::{
|
||||||
/// The global console. Output of the print! and println! macros.
|
/// The global console. Output of the print! and println! macros.
|
||||||
static CONSOLE: sync::NullLock<devices::Console> = sync::NullLock::new(devices::Console::new());
|
static CONSOLE: sync::NullLock<devices::Console> = sync::NullLock::new(devices::Console::new());
|
||||||
|
|
||||||
// Kernel entry point
|
fn init_jlink_rtt() {
|
||||||
// arch crate is responsible for calling this
|
|
||||||
fn kmain() -> ! {
|
|
||||||
// let gpio = GPIO::new_default();
|
|
||||||
|
|
||||||
// let uart = platform::MiniUart::new_default();
|
|
||||||
// uart.init(&gpio);
|
|
||||||
// CONSOLE.lock(|c| {
|
|
||||||
// // Moves uart into the global CONSOLE. It is not accessible
|
|
||||||
// // anymore for the remaining parts of kernel_entry().
|
|
||||||
// c.replace_with(uart.into());
|
|
||||||
// });
|
|
||||||
|
|
||||||
// let uart = platform::PL011Uart::new_default();
|
|
||||||
|
|
||||||
// let mut mbox = platform::mailbox::Mailbox::new();
|
|
||||||
|
|
||||||
// match uart.init(&mut mbox, &gpio) {
|
|
||||||
// Ok(_) => {
|
|
||||||
// CONSOLE.lock(|c| {
|
|
||||||
// // Moves uart into the global CONSOLE. It is not accessible
|
|
||||||
// // anymore for the remaining parts of kernel_entry().
|
|
||||||
// c.replace_with(uart.into());
|
|
||||||
// });
|
|
||||||
// }
|
|
||||||
// Err(_) => endless_sleep(),
|
|
||||||
// }
|
|
||||||
|
|
||||||
CONSOLE.lock(|c| {
|
CONSOLE.lock(|c| {
|
||||||
c.replace_with(Output::new().into());
|
c.replace_with(Output::new().into());
|
||||||
});
|
});
|
||||||
|
|
||||||
jtag_dbg_wait();
|
println!("\n[0] JLink RTT is live!");
|
||||||
|
}
|
||||||
|
|
||||||
println!("\n[0] UART is live!");
|
fn init_uart_serial() {
|
||||||
|
let gpio = GPIO::new_default();
|
||||||
|
|
||||||
|
let uart = platform::MiniUart::new_default();
|
||||||
|
uart.init(&gpio);
|
||||||
|
CONSOLE.lock(|c| {
|
||||||
|
// Moves uart into the global CONSOLE. It is not accessible
|
||||||
|
// anymore for the remaining parts of kernel_entry().
|
||||||
|
c.replace_with(uart.into());
|
||||||
|
});
|
||||||
|
|
||||||
|
println!("[0] MiniUART is live!");
|
||||||
|
|
||||||
|
let uart = platform::PL011Uart::new_default();
|
||||||
|
|
||||||
|
let mut mbox = platform::mailbox::Mailbox::new();
|
||||||
|
|
||||||
|
match uart.init(&mut mbox, &gpio) {
|
||||||
|
Ok(_) => {
|
||||||
|
CONSOLE.lock(|c| {
|
||||||
|
// Moves uart into the global CONSOLE. It is not accessible
|
||||||
|
// anymore for the remaining parts of kernel_entry().
|
||||||
|
c.replace_with(uart.into());
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Err(_) => endless_sleep(), // @todo ignore error because MiniUart is still there?
|
||||||
|
}
|
||||||
|
|
||||||
|
println!("[0] UART0 is live!");
|
||||||
|
}
|
||||||
|
|
||||||
|
// Kernel entry point
|
||||||
|
// arch crate is responsible for calling this
|
||||||
|
fn kmain() -> ! {
|
||||||
|
init_jlink_rtt();
|
||||||
|
|
||||||
|
// init_uart_serial();
|
||||||
|
// jtag_dbg_wait();
|
||||||
|
|
||||||
extern "C" {
|
extern "C" {
|
||||||
static __exception_vectors_start: u64;
|
static __exception_vectors_start: u64;
|
||||||
|
|
Loading…
Reference in New Issue