43 lines
1.0 KiB
Rust
43 lines
1.0 KiB
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
use core::arch::asm;
|
|
|
|
use fpga_lib::{
|
|
interface::{Buttons, Leds},
|
|
panic_handler,
|
|
register::X31,
|
|
vga::{BLACK, BLUE, FONT_WIDTH, GREEN, RED, VGA, WHITE},
|
|
};
|
|
|
|
panic_handler! {}
|
|
|
|
#[unsafe(no_mangle)]
|
|
pub extern "C" fn main() -> !
|
|
{
|
|
loop
|
|
{
|
|
unsafe {
|
|
VGA::draw_string(10, 10, "Running RUST !", GREEN);
|
|
VGA::draw_string(10, 23, "LedIp state :", RED);
|
|
|
|
for i in 0..4
|
|
{
|
|
VGA::draw_char(10 + i * 16, 46, 'B', RED);
|
|
VGA::draw_char(16 + i * 16, 46, (b'0' + i as u8) as char, RED);
|
|
|
|
if Buttons::get_button(i as u8)
|
|
{
|
|
Leds::set_led(i as u8, true);
|
|
VGA::draw_char_bg(10 + i * 16, 59, '1', GREEN, BLACK);
|
|
}
|
|
else
|
|
{
|
|
Leds::set_led(i as u8, false);
|
|
VGA::draw_char_bg(10 + i * 16, 59, '0', RED, BLACK);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
}
|