From f75a317446ac8856e30d4d86b7fd5ccc30e4c089 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 18 Aug 2018 11:43:23 +0800 Subject: [PATCH] hmc7043: automatically determine output groups --- artiq/firmware/libboard_artiq/hmc830_7043.rs | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/artiq/firmware/libboard_artiq/hmc830_7043.rs b/artiq/firmware/libboard_artiq/hmc830_7043.rs index 80b05fc4c..afa9c1c2a 100644 --- a/artiq/firmware/libboard_artiq/hmc830_7043.rs +++ b/artiq/firmware/libboard_artiq/hmc830_7043.rs @@ -287,11 +287,15 @@ pub mod hmc7043 { write(0xA0, 0xdf); // Unexplained high-performance mode // Enable required output groups - write(0x4, (1 << 0) | - (1 << 1) | - (1 << 3) | - (1 << 4) | - (1 << 5)); + let mut output_group_en = 0; + for channel in 0..OUTPUT_CONFIG.len() { + let enabled = OUTPUT_CONFIG[channel].0; + if enabled { + let group = channel/2; + output_group_en |= 1 << group; + } + } + write(0x4, output_group_en); write(0x5c, (HMC_SYSREF_DIV & 0xff) as u8); // Set SYSREF timer divider write(0x5d, ((HMC_SYSREF_DIV & 0x0f) >> 8) as u8);