runtime: use GlobalTimer

astro
Astro 2020-04-25 01:36:15 +02:00
parent 8e99c5eb7a
commit c4ce42f7a4
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};
@ -205,7 +206,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)
@ -257,9 +258,7 @@ pub fn main() {
} }
}); });
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 core::{cmp, str};
use libboard_zynq::{ use libboard_zynq::{
println, println,
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};
@ -45,8 +46,9 @@ pub fn main_core0() {
libboard_zynq::stdio::drop_uart(); // reinitialize UART after clocking change libboard_zynq::stdio::drop_uart(); // reinitialize UART after clocking change
let mut ddr = zynq::ddr::DdrRam::new(); let mut ddr = zynq::ddr::DdrRam::new();
ram::init_alloc(&mut ddr); ram::init_alloc(&mut ddr);
let timer = GlobalTimer::new();
println!("Detected gateware: {}", identifier_read(&mut [0; 64])); println!("Detected gateware: {}", identifier_read(&mut [0; 64]));
comms::main(); comms::main(timer);
} }