Unsure if this is working, not sure if I have the tools to even know if it does. I could spend the time to actually write the packet by hand, or I could probably spend ~2x the time and get smoltcp up. Either way, the HW is validated, I am bringing up a link, I can talk to LiteEth, so past here is driver stuff
49 lines
798 B
Rust
49 lines
798 B
Rust
#![no_std]
|
|
#![no_main]
|
|
|
|
extern crate panic_halt;
|
|
|
|
use core::{arch::asm, ptr::write};
|
|
|
|
use riscv_rt::entry;
|
|
|
|
mod eth;
|
|
|
|
// use `main` as the entry point of this application
|
|
// `main` is not allowed to return
|
|
#[entry]
|
|
fn main() -> ! {
|
|
eth::init();
|
|
|
|
let blink_period = if eth::is_wishbone_correct() {
|
|
10_000_000
|
|
} else {
|
|
500_000
|
|
};
|
|
|
|
// do something here
|
|
loop {
|
|
unsafe {
|
|
//eth::tranmsit();
|
|
write_led(0);
|
|
busy_wait(blink_period);
|
|
write_led(1);
|
|
busy_wait(blink_period);
|
|
}
|
|
}
|
|
}
|
|
|
|
fn busy_wait(num_nops: u32) {
|
|
for _ in 0..num_nops {
|
|
unsafe {
|
|
asm!("nop");
|
|
}
|
|
}
|
|
}
|
|
|
|
fn write_led(val: u32) {
|
|
unsafe {
|
|
write(0x01002000 as *mut u32, val);
|
|
}
|
|
}
|