Control board LED status from command_prompt
This commit is contained in:
parent
4bbbddef6e
commit
e324795ab9
19
src/main.rs
19
src/main.rs
|
@ -42,6 +42,7 @@ use jlink_rtt::Output;
|
|||
use platform::{
|
||||
display::{Color, Size2d},
|
||||
gpio::GPIO,
|
||||
mailbox::{channel, Mailbox},
|
||||
power::Power,
|
||||
vc::VC,
|
||||
};
|
||||
|
@ -158,6 +159,8 @@ fn kmain() -> ! {
|
|||
b"disp" => check_display_init(),
|
||||
b"trap" => check_data_abort_trap(),
|
||||
b"map" => arch::memory::print_layout(),
|
||||
b"led on" => set_led(true),
|
||||
b"led off" => set_led(false),
|
||||
b"help" => print_help(),
|
||||
b"end" => break 'cmd_loop,
|
||||
x => println!("Unknown command {:?}, try 'help'", x),
|
||||
|
@ -175,7 +178,21 @@ fn print_help() {
|
|||
println!(" disp - try to init VC framebuffer and draw some text");
|
||||
println!(" trap - cause and recover from a data abort exception");
|
||||
println!(" map - show kernel memory layout");
|
||||
println!(" end - leave console and lock up");
|
||||
println!(" led [on|off] - change RPi LED status");
|
||||
println!(" end - leave console and reset board");
|
||||
}
|
||||
|
||||
fn set_led(enable: bool) {
|
||||
let mut mbox = Mailbox::default();
|
||||
let index = mbox.request();
|
||||
let index = mbox.set_led_on(index, enable);
|
||||
mbox.end(index);
|
||||
|
||||
mbox.call(channel::PropertyTagsArmToVc).map_err(|e| {
|
||||
println!("Mailbox call returned error {}", e);
|
||||
println!("Mailbox contents: {}", mbox);
|
||||
()
|
||||
});
|
||||
}
|
||||
|
||||
fn init_mmu() {
|
||||
|
|
|
@ -177,6 +177,8 @@ pub mod tag {
|
|||
pub const SetPalette: u32 = 0x0004_800b;
|
||||
pub const SetCursorInfo: u32 = 0x0000_8010;
|
||||
pub const SetCursorState: u32 = 0x0000_8011;
|
||||
pub const GetGpioState: u32 = 0x0003_0041;
|
||||
pub const SetGpioState: u32 = 0x0003_8041;
|
||||
pub const End: u32 = 0;
|
||||
}
|
||||
|
||||
|
@ -439,6 +441,16 @@ impl<'a> Mailbox<'a> {
|
|||
self.buffer[index + 4] = 0; // Space for response -- fb_size will be here
|
||||
index + 5
|
||||
}
|
||||
|
||||
#[inline]
|
||||
pub fn set_led_on(&mut self, index: usize, enable: bool) -> usize {
|
||||
self.buffer[index] = tag::SetGpioState;
|
||||
self.buffer[index + 1] = 8; // Buffer size // val buf size
|
||||
self.buffer[index + 2] = 0; // Response size // val size
|
||||
self.buffer[index + 3] = 130; // Pin Number
|
||||
self.buffer[index + 4] = if enable { 1 } else { 0 };
|
||||
index + 5
|
||||
}
|
||||
}
|
||||
|
||||
/// Deref to RegisterBlock
|
||||
|
|
Loading…
Reference in New Issue