From 35f1814235a35b293d1090388d5f5d9f3b818c35 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Thu, 7 May 2020 19:07:43 +0800 Subject: [PATCH] kasli: implement virtual LEDs --- artiq/firmware/libboard_misoc/io_expander.rs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/libboard_misoc/io_expander.rs b/artiq/firmware/libboard_misoc/io_expander.rs index 0ff278a5e..136a38856 100644 --- a/artiq/firmware/libboard_misoc/io_expander.rs +++ b/artiq/firmware/libboard_misoc/io_expander.rs @@ -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 {