use csr::virtual_leds for SFP0..3 LED indication #244
@ -108,8 +108,9 @@ static mut LAST_VIRTUAL_LED_STATUS: u8 = 0;
|
|||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
||||||
fn wait_for_virtual_leds_change() -> nb::Result<(), Void> {
|
fn wait_for_virtual_leds_change() -> nb::Result<(), Void> {
|
||||||
unsafe {
|
unsafe {
|
||||||
morgan marked this conversation as resolved
Outdated
|
|||||||
if pl::csr::virtual_leds::status_read() != LAST_VIRTUAL_LED_STATUS {
|
let current = pl::csr::virtual_leds::status_read();
|
||||||
LAST_VIRTUAL_LED_STATUS = pl::csr::virtual_leds::status_read();
|
if current != LAST_VIRTUAL_LED_STATUS {
|
||||||
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``
|
|||||||
|
LAST_VIRTUAL_LED_STATUS = current;
|
||||||
Ok(())
|
Ok(())
|
||||||
} else {
|
} else {
|
||||||
Err(nb::Error::WouldBlock)
|
Err(nb::Error::WouldBlock)
|
||||||
@ -124,7 +125,6 @@ async fn async_rtio_led() {
|
|||||||
let mut io_expander1 = io_expander::IoExpander::new(i2c1, 1).unwrap();
|
let mut io_expander1 = io_expander::IoExpander::new(i2c1, 1).unwrap();
|
||||||
morgan marked this conversation as resolved
Outdated
sb10q
commented
Just inline it.
Just inline it.
```
block_async!(|| {
let current = unsafe { pl::csr::virtual_leds::status_read() };
...
```
|
|||||||
loop {
|
loop {
|
||||||
let _ = block_async!(wait_for_virtual_leds_change()).await;
|
let _ = block_async!(wait_for_virtual_leds_change()).await;
|
||||||
morgan marked this conversation as resolved
Outdated
mwojcik
commented
Debug leftover? Remove pls Debug leftover? Remove pls
|
|||||||
info!("switching");
|
|
||||||
io_expander0.service().expect("I2C I/O expander #0 service failed");
|
io_expander0.service().expect("I2C I/O expander #0 service failed");
|
||||||
io_expander1.service().expect("I2C I/O expander #1 service failed");
|
io_expander1.service().expect("I2C I/O expander #1 service failed");
|
||||||
}
|
}
|
||||||
|
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.