use global timer

This commit is contained in:
Sebastien Bourdeauducq 2020-04-25 12:59:57 +08:00
parent 2a43395bd5
commit dcb45d7466
2 changed files with 6 additions and 5 deletions

View File

@ -16,6 +16,7 @@ use libboard_zynq::{
iface::{NeighborCache, EthernetInterfaceBuilder, Routes}, iface::{NeighborCache, EthernetInterfaceBuilder, Routes},
time::Instant, time::Instant,
}, },
timer::GlobalTimer,
}; };
use libsupport_zynq::alloc::{vec, vec::Vec}; use libsupport_zynq::alloc::{vec, vec::Vec};
use libasync::{smoltcp::{Sockets, TcpStream}, task}; use libasync::{smoltcp::{Sockets, TcpStream}, task};
@ -152,7 +153,7 @@ async fn handle_connection(stream: &TcpStream, control: Rc<RefCell<kernel::Contr
const HWADDR: [u8; 6] = [0, 0x23, 0xab, 0xad, 0x1d, 0xea]; const HWADDR: [u8; 6] = [0, 0x23, 0xab, 0xad, 0x1d, 0xea];
const IPADDR: IpAddress = IpAddress::Ipv4(Ipv4Address([192, 168, 1, 52])); const IPADDR: IpAddress = IpAddress::Ipv4(Ipv4Address([192, 168, 1, 52]));
pub fn main() { pub fn main(timer: GlobalTimer) {
let eth = zynq::eth::Eth::default(HWADDR.clone()); let eth = zynq::eth::Eth::default(HWADDR.clone());
const RX_LEN: usize = 8; const RX_LEN: usize = 8;
let mut rx_descs = (0..RX_LEN) let mut rx_descs = (0..RX_LEN)
@ -205,9 +206,7 @@ pub fn main() {
moninj::start(); moninj::start();
let mut time = 0u32;
Sockets::run(&mut iface, || { Sockets::run(&mut iface, || {
time += 1; Instant::from_millis(timer.get_time().0 as i32)
Instant::from_millis(time)
}); });
} }

View File

@ -9,6 +9,7 @@ use log::info;
use libboard_zynq::{ use libboard_zynq::{
self as zynq, clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll}, self as zynq, clocks::Clocks, clocks::source::{ClockSource, ArmPll, IoPll},
timer::GlobalTimer,
}; };
use libsupport_zynq::{logger, ram}; use libsupport_zynq::{logger, ram};
@ -35,6 +36,7 @@ fn identifier_read(buf: &mut [u8]) -> &str {
#[no_mangle] #[no_mangle]
pub fn main_core0() { pub fn main_core0() {
let timer = GlobalTimer::start();
let _ = logger::init(); let _ = logger::init();
log::set_max_level(log::LevelFilter::Debug); log::set_max_level(log::LevelFilter::Debug);
info!("NAR3 starting..."); info!("NAR3 starting...");
@ -50,5 +52,5 @@ pub fn main_core0() {
info!("Detected gateware: {}", identifier_read(&mut [0; 64])); info!("Detected gateware: {}", identifier_read(&mut [0; 64]));
comms::main(); comms::main(timer);
} }