From cd22e42cb4802d9fac9833ab747110340fc39644 Mon Sep 17 00:00:00 2001 From: linuswck Date: Wed, 23 Aug 2023 06:21:14 +0000 Subject: [PATCH] efc: add DRTIO virtual LEDs - EFC Gateware: Add virtual_leds to rtio - EFC Firmware: io_expander is kept being serviced to update virtual_leds after init --- artiq/firmware/libboard_misoc/io_expander.rs | 1 - artiq/firmware/satman/main.rs | 12 +++++++++++- artiq/gateware/targets/efc.py | 6 ++++++ 3 files changed, 17 insertions(+), 2 deletions(-) diff --git a/artiq/firmware/libboard_misoc/io_expander.rs b/artiq/firmware/libboard_misoc/io_expander.rs index 7009e0476..e9f0a48b4 100644 --- a/artiq/firmware/libboard_misoc/io_expander.rs +++ b/artiq/firmware/libboard_misoc/io_expander.rs @@ -83,7 +83,6 @@ impl IoExpander { #[cfg(soc_platform = "efc")] pub fn new() -> Result { - // TODO: Put Virtual User LEDs L0 L1 in gateware const VIRTUAL_LED_MAPPING: [(u8, u8, u8); 2] = [(0, 0, 5), (1, 0, 6)]; let mut io_expander = IoExpander { diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index ffe3491d2..b1553000a 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -531,9 +531,15 @@ pub extern fn main() -> i32 { sysclk_setup(); + #[cfg(soc_platform = "efc")] + let mut io_expander; #[cfg(soc_platform = "efc")] { - let mut io_expander = board_misoc::io_expander::IoExpander::new().unwrap(); + io_expander = board_misoc::io_expander::IoExpander::new().unwrap(); + + // Enable LEDs + io_expander.set_oe(0, 1 << 5 | 1 << 6 | 1 << 7).unwrap(); + // Enable VADJ and P3V3_FMC io_expander.set_oe(1, 1 << 0 | 1 << 1).unwrap(); @@ -576,6 +582,8 @@ pub extern fn main() -> i32 { io_expander0.service().expect("I2C I/O expander #0 service failed"); io_expander1.service().expect("I2C I/O expander #1 service failed"); } + #[cfg(soc_platform = "efc")] + io_expander.service().expect("I2C I/O expander service failed"); hardware_tick(&mut hardware_tick_ts); } @@ -609,6 +617,8 @@ pub extern fn main() -> i32 { io_expander0.service().expect("I2C I/O expander #0 service failed"); io_expander1.service().expect("I2C I/O expander #1 service failed"); } + #[cfg(soc_platform = "efc")] + io_expander.service().expect("I2C I/O expander service failed"); hardware_tick(&mut hardware_tick_ts); if drtiosat_tsc_loaded() { info!("TSC loaded from uplink"); diff --git a/artiq/gateware/targets/efc.py b/artiq/gateware/targets/efc.py index 26d034a7d..6bf123442 100644 --- a/artiq/gateware/targets/efc.py +++ b/artiq/gateware/targets/efc.py @@ -12,6 +12,7 @@ from misoc.integration.builder import builder_args, builder_argdict from artiq.gateware.amp import AMPSoC from artiq.gateware import rtio from artiq.gateware.rtio.xilinx_clocking import fix_serdes_timing_path +from artiq.gateware.rtio.phy import ttl_simple from artiq.gateware.drtio.transceiver import eem_serdes from artiq.gateware.drtio.rx_synchronizer import XilinxRXSynchronizer from artiq.gateware.drtio import * @@ -122,6 +123,11 @@ class Satellite(BaseSoC, AMPSoC): self.rtio_channels = [] + for i in range(2): + phy = ttl_simple.Output(self.virtual_leds.get(i)) + self.submodules += phy + self.rtio_channels.append(rtio.Channel.from_phy(phy)) + self.config["HAS_RTIO_LOG"] = None self.config["RTIO_LOG_CHANNEL"] = len(self.rtio_channels) self.rtio_channels.append(rtio.LogChannel())