29 lines
546 B
Rust
29 lines
546 B
Rust
pub struct Buttons {}
|
|
|
|
impl Buttons
|
|
{
|
|
pub unsafe fn get_button(button_id: u8) -> bool
|
|
{
|
|
unsafe { *LED_IP_ADDRESS >> (button_id) & 0b1 == 0b1 }
|
|
}
|
|
}
|
|
|
|
pub struct Leds {}
|
|
|
|
impl Leds
|
|
{
|
|
pub unsafe fn set_led(led_id: u8, state: bool)
|
|
{
|
|
if state
|
|
{
|
|
unsafe { *LED_IP_ADDRESS |= (state as u32) << (led_id + 4) }
|
|
}
|
|
else
|
|
{
|
|
unsafe { *LED_IP_ADDRESS &= !((state as u32) << (led_id + 4)) }
|
|
}
|
|
}
|
|
}
|
|
|
|
pub const LED_IP_ADDRESS: *mut u32 = 0x30000000 as *mut u32;
|