forked from M-Labs/artiq
1
0
Fork 0

hmc7043: automatically determine output groups

This commit is contained in:
Sebastien Bourdeauducq 2018-08-18 11:43:23 +08:00
parent c498b28f88
commit f75a317446
1 changed files with 9 additions and 5 deletions

View File

@ -287,11 +287,15 @@ pub mod hmc7043 {
write(0xA0, 0xdf); // Unexplained high-performance mode write(0xA0, 0xdf); // Unexplained high-performance mode
// Enable required output groups // Enable required output groups
write(0x4, (1 << 0) | let mut output_group_en = 0;
(1 << 1) | for channel in 0..OUTPUT_CONFIG.len() {
(1 << 3) | let enabled = OUTPUT_CONFIG[channel].0;
(1 << 4) | if enabled {
(1 << 5)); 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(0x5c, (HMC_SYSREF_DIV & 0xff) as u8); // Set SYSREF timer divider
write(0x5d, ((HMC_SYSREF_DIV & 0x0f) >> 8) as u8); write(0x5d, ((HMC_SYSREF_DIV & 0x0f) >> 8) as u8);