use csr::virtual_leds for SFP0..3 LED indication #244
@ -119,10 +119,8 @@ fn wait_for_virtual_leds_change() -> nb::Result<(), Void> {
|
|||||||
}
|
}
|
||||||
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
#[cfg(all(feature = "target_kasli_soc", has_drtio))]
|
||||||
async fn async_rtio_led() {
|
async fn async_rtio_led() {
|
||||||
morgan marked this conversation as resolved
Outdated
|
|||||||
let i2c0 = unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() };
|
let mut io_expander0 = io_expander::IoExpander::new(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, 0).unwrap();
|
||||||
let i2c1 = unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() };
|
let mut io_expander1 = io_expander::IoExpander::new(unsafe { (&mut i2c::I2C_BUS).as_mut().unwrap() }, 1).unwrap();
|
||||||
sb10q
commented
It's confusing to create IO expander objects, which also should be singletons and do more than controlling LEDs, into a function whose name indicates it is about LEDs. It's confusing to create IO expander objects, which also should be singletons and do more than controlling LEDs, into a function whose name indicates it is about LEDs.
sb10q
commented
As I told you before, those I/O expander objects should be created only once in the entire firmware. Additionally, you create them once with As I told you before, those I/O expander objects should be created only once in the entire firmware.
Additionally, you create them once with ``i2c::I2C_BUS`` and once with ``&mut *i2c_ptr``, which is inconsistent.
|
|||||||
let mut io_expander0 = io_expander::IoExpander::new(i2c0, 0).unwrap();
|
|
||||||
let mut io_expander1 = io_expander::IoExpander::new(i2c1, 1).unwrap();
|
|
||||||
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
sb10q
commented
Just inline it.
Just inline it.
```
block_async!(|| {
let current = unsafe { pl::csr::virtual_leds::status_read() };
...
```
|
|||||||
io_expander0.service().expect("I2C I/O expander #0 service failed");
|
io_expander0.service().expect("I2C I/O expander #0 service failed");
|
||||||
|
@ -660,7 +660,6 @@ pub extern "C" fn main_core0() -> i32 {
|
|||||||
let mut i2c0 = I2c::i2c0();
|
let mut i2c0 = I2c::i2c0();
|
||||||
sb10q
commented
Better than before but is there really no other solution than disabling the borrow checker? Better than before but is there really no other solution than disabling the borrow checker?
|
|||||||
let mut i2c1 = I2c::i2c0();
|
let mut i2c1 = I2c::i2c0();
|
||||||
i2c0.init().expect("I2C0 initialization failed");
|
i2c0.init().expect("I2C0 initialization failed");
|
||||||
i2c1.init().expect("I2C1 initialization failed");
|
|
||||||
let mut io_expander0 = io_expander::IoExpander::new(&mut i2c0, 0).unwrap();
|
let mut io_expander0 = io_expander::IoExpander::new(&mut i2c0, 0).unwrap();
|
||||||
let mut io_expander1 = io_expander::IoExpander::new(&mut i2c1, 1).unwrap();
|
let mut io_expander1 = io_expander::IoExpander::new(&mut i2c1, 1).unwrap();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user
async_
in the name sounds redundant since this is declared ``async fn