Merges Cargo.toml
This commit is contained in:
@@ -1,28 +1,21 @@
|
||||
pub struct Buttons {}
|
||||
|
||||
impl Buttons
|
||||
{
|
||||
pub unsafe fn get_button(button_id: u8) -> bool
|
||||
{
|
||||
unsafe { *LED_IP_ADDRESS >> (button_id) & 0b1 == 0b1 }
|
||||
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)) }
|
||||
impl Leds {
|
||||
pub unsafe fn set_led(led_id: u8, state: bool) {
|
||||
if state {
|
||||
unsafe { *LED_IP_ADDRESS |= (state as u64) << (led_id + 4) }
|
||||
} else {
|
||||
unsafe { *LED_IP_ADDRESS &= !((state as u64) << (led_id + 4)) }
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub const LED_IP_ADDRESS: *mut u32 = 0x30000000 as *mut u32;
|
||||
pub const LED_IP_ADDRESS: *mut u64 = 0x30000000 as *mut u64;
|
||||
|
||||
@@ -8,10 +8,11 @@ pub mod vga;
|
||||
macro_rules! panic_handler {
|
||||
() => {
|
||||
#[panic_handler]
|
||||
fn panic(_info: &core::panic::PanicInfo) -> !
|
||||
{
|
||||
loop
|
||||
{}
|
||||
fn panic(_info: &core::panic::PanicInfo) -> ! {
|
||||
unsafe {
|
||||
$crate::vga::VGA::draw_string(0, 0, "PANIC !", $crate::vga::WHITE);
|
||||
}
|
||||
loop {}
|
||||
}
|
||||
};
|
||||
}
|
||||
|
||||
@@ -1,3 +1,5 @@
|
||||
use core::ptr::write_bytes;
|
||||
|
||||
use fpga_lib_macros::include_font_plate;
|
||||
|
||||
pub const VGA_ADDRESS: *mut Color = 0x80000000 as *mut Color;
|
||||
@@ -97,6 +99,9 @@ impl VGA {
|
||||
Self::draw_char(x + i as u16 * (FONT_WIDTH as u16), y, c as char, color)
|
||||
});
|
||||
}
|
||||
pub fn clear_screen(color: Color) {
|
||||
unsafe { write_bytes(VGA_ADDRESS, color.0, WIDTH * HEIGHT) };
|
||||
}
|
||||
|
||||
fn digit_count(mut val: u64) -> u64 {
|
||||
let mut i = 0;
|
||||
|
||||
Reference in New Issue
Block a user