runtime: async delay instead of usual
This commit is contained in:
parent
45b9d50e70
commit
32df88c771
@ -5,7 +5,7 @@ use libboard_zynq::{timer::GlobalTimer, time::Milliseconds};
|
|||||||
use embedded_hal::blocking::delay::DelayMs;
|
use embedded_hal::blocking::delay::DelayMs;
|
||||||
use board_artiq::drtio_routing;
|
use board_artiq::drtio_routing;
|
||||||
use libcortex_a9::mutex::Mutex;
|
use libcortex_a9::mutex::Mutex;
|
||||||
use libasync::task;
|
use libasync::{task, delay::delay};
|
||||||
|
|
||||||
#[cfg(has_drtio)]
|
#[cfg(has_drtio)]
|
||||||
pub mod drtio {
|
pub mod drtio {
|
||||||
@ -24,7 +24,7 @@ pub mod drtio {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
fn link_rx_up(linkno: u8) -> bool {
|
async fn link_rx_up(linkno: u8) -> bool {
|
||||||
let linkno = linkno as usize;
|
let linkno = linkno as usize;
|
||||||
unsafe {
|
unsafe {
|
||||||
(csr::DRTIO[linkno].rx_up_read)() == 1
|
(csr::DRTIO[linkno].rx_up_read)() == 1
|
||||||
@ -34,7 +34,7 @@ pub mod drtio {
|
|||||||
async fn recv_aux_timeout(linkno: u8, timeout: u32, timer: GlobalTimer) -> Result<drtioaux::Packet, &'static str> {
|
async fn recv_aux_timeout(linkno: u8, timeout: u32, timer: GlobalTimer) -> Result<drtioaux::Packet, &'static str> {
|
||||||
let max_time = timer.get_time() + Milliseconds(timeout);
|
let max_time = timer.get_time() + Milliseconds(timeout);
|
||||||
loop {
|
loop {
|
||||||
if !link_rx_up(linkno) {
|
if !link_rx_up(linkno).await {
|
||||||
return Err("link went down");
|
return Err("link went down");
|
||||||
}
|
}
|
||||||
if timer.get_time() > max_time {
|
if timer.get_time() > max_time {
|
||||||
@ -257,7 +257,7 @@ pub mod drtio {
|
|||||||
let linkno = linkno as u8;
|
let linkno = linkno as u8;
|
||||||
if up_links[linkno as usize] {
|
if up_links[linkno as usize] {
|
||||||
/* link was previously up */
|
/* link was previously up */
|
||||||
if link_rx_up(linkno) {
|
if link_rx_up(linkno).await {
|
||||||
process_unsolicited_aux(aux_mutex, linkno, timer).await;
|
process_unsolicited_aux(aux_mutex, linkno, timer).await;
|
||||||
process_local_errors(linkno).await;
|
process_local_errors(linkno).await;
|
||||||
} else {
|
} else {
|
||||||
@ -266,7 +266,7 @@ pub mod drtio {
|
|||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
/* link was previously down */
|
/* link was previously down */
|
||||||
if link_rx_up(linkno) {
|
if link_rx_up(linkno).await {
|
||||||
info!("[LINK#{}] link RX became up, pinging", linkno);
|
info!("[LINK#{}] link RX became up, pinging", linkno);
|
||||||
let ping_count = ping_remote(aux_mutex, linkno, timer).await;
|
let ping_count = ping_remote(aux_mutex, linkno, timer).await;
|
||||||
if ping_count > 0 {
|
if ping_count > 0 {
|
||||||
@ -289,7 +289,8 @@ pub mod drtio {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
destination_survey(aux_mutex, routing_table, &up_links, up_destinations, timer).await;
|
destination_survey(aux_mutex, routing_table, &up_links, up_destinations, timer).await;
|
||||||
timer.delay_ms(200);
|
let mut countdown = timer.countdown();
|
||||||
|
delay(&mut countdown, Milliseconds(200)).await;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -309,7 +310,7 @@ pub mod drtio {
|
|||||||
for linkno in 0..csr::DRTIO.len() {
|
for linkno in 0..csr::DRTIO.len() {
|
||||||
let linkno = linkno as u8;
|
let linkno = linkno as u8;
|
||||||
if link_rx_up(linkno) {
|
if link_rx_up(linkno) {
|
||||||
let reply = task::block_on(aux_transact(io, aux_mutex, linkno,
|
let reply = task::block_on(aux_transact(aux_mutex, linkno,
|
||||||
&drtioaux::Packet::ResetRequest, timer));
|
&drtioaux::Packet::ResetRequest, timer));
|
||||||
match reply {
|
match reply {
|
||||||
Ok(drtioaux::Packet::ResetAck) => (),
|
Ok(drtioaux::Packet::ResetAck) => (),
|
||||||
|
Loading…
Reference in New Issue
Block a user