use csr::virtual_leds for SFP0..3 LED indication #244

Merged
sb10q merged 10 commits from morgan/artiq-zynq:feature into master 2023-08-28 16:08:11 +08:00
Showing only changes of commit 097cfd9996 - Show all commits

View File

@ -108,8 +108,9 @@ static mut LAST_VIRTUAL_LED_STATUS: u8 = 0;
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
fn wait_for_virtual_leds_change() -> nb::Result<(), Void> {
unsafe {
morgan marked this conversation as resolved Outdated
Outdated
Review

The only unsafe line is the next one, no?

The only unsafe line is the next one, no?

LAST_VIRTUAL_LED_STATUS is a static mut. So it need an unsafe too

```LAST_VIRTUAL_LED_STATUS``` is a static mut. So it need an unsafe too
Outdated
Review

I don't think this should be gated on has_drtio.

I don't think this should be gated on has_drtio.
if pl::csr::virtual_leds::status_read() != LAST_VIRTUAL_LED_STATUS {
LAST_VIRTUAL_LED_STATUS = pl::csr::virtual_leds::status_read();
let current = pl::csr::virtual_leds::status_read();
if current != LAST_VIRTUAL_LED_STATUS {
morgan marked this conversation as resolved Outdated

Could save a CSR call by getting the value before the if

Could save a CSR call by getting the value before the ``if``
LAST_VIRTUAL_LED_STATUS = current;
Ok(())
} else {
Err(nb::Error::WouldBlock)
@ -124,7 +125,6 @@ async fn async_rtio_led() {
let mut io_expander1 = io_expander::IoExpander::new(i2c1, 1).unwrap();
morgan marked this conversation as resolved Outdated
Outdated
Review

Just inline it.

 block_async!(|| {
   let current = unsafe { pl::csr::virtual_leds::status_read() };
   ...
Just inline it. ``` block_async!(|| { let current = unsafe { pl::csr::virtual_leds::status_read() }; ... ```
loop {
let _ = block_async!(wait_for_virtual_leds_change()).await;
morgan marked this conversation as resolved Outdated

Debug leftover? Remove pls

Debug leftover? Remove pls
info!("switching");
io_expander0.service().expect("I2C I/O expander #0 service failed");
io_expander1.service().expect("I2C I/O expander #1 service failed");
}