satman: repeater fixes, missing code

This commit is contained in:
mwojcik 2021-08-26 15:20:33 +02:00
parent cb3f0a404c
commit 9b2b1dadaa

View File

@ -5,6 +5,8 @@ use libboard_artiq::{pl::csr};
use libboard_zynq::time::Milliseconds;
use libboard_zynq::timer::GlobalTimer;
use embedded_hal::prelude::_embedded_hal_blocking_delay_DelayUs;
#[cfg(has_drtio_routing)]
fn rep_link_rx_up(repno: u8) -> bool {
let repno = repno as usize;
@ -84,12 +86,12 @@ impl Repeater {
self.state = RepeaterState::Failed;
return;
}
if let Err(e) = self.load_routing_table(routing_table) {
if let Err(e) = self.load_routing_table(routing_table, timer) {
error!("[REP#{}] failed to load routing table ({})", self.repno, e);
self.state = RepeaterState::Failed;
return;
}
if let Err(e) = self.set_rank(rank + 1) {
if let Err(e) = self.set_rank(rank + 1, timer) {
error!("[REP#{}] failed to set rank ({})", self.repno, e);
self.state = RepeaterState::Failed;
return;
@ -167,7 +169,7 @@ impl Repeater {
}
fn recv_aux_timeout(&self, timeout: u32, timer: GlobalTimer) -> Result<drtioaux::Packet, drtioaux::Error<!>> {
let max_time = timer.get_time() + timeout as u64;
let max_time = timer.get_time() + Milliseconds(timeout);
loop {
if !rep_link_rx_up(self.repno) {
return Err(drtioaux::Error::LinkDown);
@ -230,9 +232,9 @@ impl Repeater {
Ok(())
}
pub fn load_routing_table(&self, routing_table: &drtio_routing::RoutingTable) -> Result<(), drtioaux::Error<!>> {
pub fn load_routing_table(&self, routing_table: &drtio_routing::RoutingTable, timer: GlobalTimer) -> Result<(), drtioaux::Error<!>> {
for i in 0..drtio_routing::DEST_COUNT {
self.set_path(i as u8, &routing_table.0[i])?;
self.set_path(i as u8, &routing_table.0[i], timer)?;
}
Ok(())
}