use csr::virtual_leds for SFP0..3 LED indication #244
@ -104,29 +104,14 @@ async fn report_async_rtio_errors() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
static mut LAST_VIRTUAL_LED_STATUS: u8 = 0;
|
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
|
||||||
async fn io_expanders_service(
|
async fn io_expanders_service(
|
||||||
i2c_bus: RefCell<&mut libboard_zynq::i2c::I2c>,
|
i2c_bus: RefCell<&mut libboard_zynq::i2c::I2c>,
|
||||||
io_expander0: RefCell<io_expander::IoExpander>,
|
io_expander0: RefCell<io_expander::IoExpander>,
|
||||||
morgan marked this conversation as resolved
Outdated
|
|||||||
io_expander1: RefCell<io_expander::IoExpander>,
|
io_expander1: RefCell<io_expander::IoExpander>,
|
||||||
) {
|
) {
|
||||||
morgan marked this conversation as resolved
Outdated
mwojcik
commented
Could save a CSR call by getting the value before the Could save a CSR call by getting the value before the ``if``
|
|||||||
loop {
|
loop {
|
||||||
let _ = block_async!((|| -> nb::Result<(), Void> {
|
task::r#yield().await;
|
||||||
unsafe {
|
|
||||||
let current = pl::csr::virtual_leds::status_read();
|
|
||||||
if current != LAST_VIRTUAL_LED_STATUS {
|
|
||||||
LAST_VIRTUAL_LED_STATUS = current;
|
|
||||||
Ok(())
|
|
||||||
} else {
|
|
||||||
Err(nb::Error::WouldBlock)
|
|
||||||
}
|
|
||||||
}
|
|
||||||
})())
|
|
||||||
.await;
|
|
||||||
|
|
||||||
io_expander0
|
io_expander0
|
||||||
.borrow_mut()
|
.borrow_mut()
|
||||||
.service(&mut i2c_bus.borrow_mut())
|
.service(&mut i2c_bus.borrow_mut())
|
||||||
sb10q
commented
I don't think this entire block_async is any useful. It also duplicates logic and breaks abstraction layers. Anyway just remove it. I don't think this entire block_async is any useful. It also duplicates logic and breaks abstraction layers. Anyway just remove it.
morgan
commented
The block_async prevent "io_expanders_service" from locking up the whole cpu. As it blocks the loop from running over and over again. The block_async prevent "io_expanders_service" from locking up the whole cpu. As it blocks the loop from running over and over again.
|
|||||||
@ -192,7 +177,7 @@ pub fn main_core0() {
|
|||||||
|
|
||||||
task::spawn(report_async_rtio_errors());
|
task::spawn(report_async_rtio_errors());
|
||||||
|
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
task::spawn(io_expanders_service(
|
task::spawn(io_expanders_service(
|
||||||
RefCell::new(i2c_bus),
|
RefCell::new(i2c_bus),
|
||||||
RefCell::new(io_expander0),
|
RefCell::new(io_expander0),
|
||||||
|
@ -671,7 +671,7 @@ pub extern "C" fn main_core0() -> i32 {
|
|||||||
for mut rep in repeaters.iter_mut() {
|
for mut rep in repeaters.iter_mut() {
|
||||||
rep.service(&routing_table, rank, &mut timer);
|
rep.service(&routing_table, rank, &mut timer);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
{
|
{
|
||||||
io_expander0
|
io_expander0
|
||||||
.service(&mut i2c)
|
.service(&mut i2c)
|
||||||
@ -717,7 +717,7 @@ pub extern "C" fn main_core0() -> i32 {
|
|||||||
for mut rep in repeaters.iter_mut() {
|
for mut rep in repeaters.iter_mut() {
|
||||||
rep.service(&routing_table, rank, &mut timer);
|
rep.service(&routing_table, rank, &mut timer);
|
||||||
}
|
}
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(feature = "target_kasli_soc")]
|
||||||
{
|
{
|
||||||
io_expander0
|
io_expander0
|
||||||
.service(&mut i2c)
|
.service(&mut i2c)
|
||||||
|
Loading…
Reference in New Issue
Block a user
The only unsafe line is the next one, no?
LAST_VIRTUAL_LED_STATUS
is a static mut. So it need an unsafe tooI don't think this should be gated on has_drtio.