kasli: implement virtual LEDs

pull/1447/head
Sebastien Bourdeauducq 2020-05-07 19:07:43 +08:00
parent b83afedf43
commit 35f1814235
1 changed files with 5 additions and 2 deletions

View File

@ -1,4 +1,5 @@
use i2c;
use csr;
pub struct IoExpander {
busno: u8,
@ -80,8 +81,10 @@ impl IoExpander {
pub fn service(&mut self) -> Result<(), &'static str> {
for (led, port, bit) in self.virtual_led_mapping.iter() {
// TODO: get level from gateware
self.set(*port, *bit, false);
let level = unsafe {
(csr::virtual_leds::status_read() >> led) & 1
};
self.set(*port, *bit, level != 0);
}
if self.out_target != self.out_current {