aarch64: can run on the real raspi3

master
equation314 6 years ago
parent 2e094d08bc
commit 632baedabd

@ -116,8 +116,12 @@ impl Gpio<Uninitialized> {
/// Enables the alternative function `function` for `self`. Consumes self /// Enables the alternative function `function` for `self`. Consumes self
/// and returns a `Gpio` structure in the `Alt` state. /// and returns a `Gpio` structure in the `Alt` state.
pub fn into_alt(self, function: Function) -> Gpio<Alt> { pub fn into_alt(self, function: Function) -> Gpio<Alt> {
self.registers.FSEL[(self.pin / 10) as usize] let select = (self.pin / 10) as usize;
.write((function as u32) << (3 * (self.pin % 10))); let offset = 3 * (self.pin % 10) as usize;
let mut value = self.registers.FSEL[select].read();
value &= !(0b111 << offset);
value |= (function as u32) << offset;
self.registers.FSEL[select].write(value);
self.transition() self.transition()
} }

@ -5,9 +5,12 @@ extern crate bcm2837;
pub mod serial; pub mod serial;
pub fn init() { pub fn init() {
assert_has_not_been_called!("board::init must be called only once"); // FIXME
// assert_has_not_been_called!("board::init must be called only once");
serial::SERIAL_PORT.lock().init(); unsafe {
serial::SERIAL_PORT.init();
}
println!("Hello Raspberry Pi!"); println!("Hello Raspberry Pi!");
} }

@ -20,7 +20,8 @@ impl SerialPort {
/// Init a newly created SerialPort, can only be called once. /// Init a newly created SerialPort, can only be called once.
pub fn init(&mut self) { pub fn init(&mut self) {
assert_has_not_been_called!("SerialPort::init must be called only once"); // FIXME
// assert_has_not_been_called!("SerialPort::init must be called only once");
self.mu = Some(MiniUart::new()); self.mu = Some(MiniUart::new());
} }
@ -70,4 +71,7 @@ impl fmt::Write for SerialPort {
} }
} }
pub static SERIAL_PORT: Mutex<SerialPort> = Mutex::new(SerialPort::new()); // FIXME
// pub static SERIAL_PORT: Mutex<SerialPort> = Mutex::new(SerialPort::new());
pub static mut SERIAL_PORT: SerialPort = SerialPort::new();

@ -4,9 +4,15 @@ use core::fmt::{Arguments, Write};
use super::board::serial::{SerialRead, SERIAL_PORT}; use super::board::serial::{SerialRead, SERIAL_PORT};
pub fn getchar() -> char { pub fn getchar() -> char {
SERIAL_PORT.lock().receive() as char // FIXME
unsafe {
SERIAL_PORT.receive() as char
}
} }
pub fn putfmt(fmt: Arguments) { pub fn putfmt(fmt: Arguments) {
SERIAL_PORT.lock().write_fmt(fmt).unwrap() // FIXME
unsafe {
SERIAL_PORT.write_fmt(fmt).unwrap()
}
} }

@ -17,7 +17,8 @@ pub extern "C" fn rust_main() -> ! {
board::init(); board::init();
// First init log mod, so that we can print log info. // First init log mod, so that we can print log info.
::logging::init(); // FIXME
// ::logging::init();
super::fs::show_logo(); super::fs::show_logo();

Loading…
Cancel
Save