From 5ee81dc6438eaa173d94a48a205816755f49a403 Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Tue, 8 Oct 2019 10:27:04 +0800 Subject: [PATCH] satman: define constants for JdacBasicRequest reqnos --- artiq/firmware/satman/jdac_requests.rs | 4 ++++ artiq/firmware/satman/jdcg.rs | 12 +++++++----- artiq/firmware/satman/main.rs | 10 ++++++---- 3 files changed, 17 insertions(+), 9 deletions(-) create mode 100644 artiq/firmware/satman/jdac_requests.rs diff --git a/artiq/firmware/satman/jdac_requests.rs b/artiq/firmware/satman/jdac_requests.rs new file mode 100644 index 000000000..2ba120ebb --- /dev/null +++ b/artiq/firmware/satman/jdac_requests.rs @@ -0,0 +1,4 @@ +pub const INIT: u8 = 0x00; +pub const PRINT_STATUS: u8 = 0x01; +pub const PRBS: u8 = 0x02; +pub const STPL: u8 = 0x03; diff --git a/artiq/firmware/satman/jdcg.rs b/artiq/firmware/satman/jdcg.rs index 278fcb775..f7bdd8f90 100644 --- a/artiq/firmware/satman/jdcg.rs +++ b/artiq/firmware/satman/jdcg.rs @@ -1,6 +1,8 @@ use board_misoc::{csr, clock}; use board_artiq::drtioaux; +use super::jdac_requests; + pub fn jesd_reset(reset: bool) { unsafe { csr::jesd_crg::jreset_write(if reset {1} else {0}); @@ -67,17 +69,17 @@ pub fn init() { jesd_prbs(dacno, false); jesd_stpl(dacno, false); - jdac_basic_request(dacno, 0); + jdac_basic_request(dacno, jdac_requests::INIT); jesd_prbs(dacno, true); - jdac_basic_request(dacno, 2); + jdac_basic_request(dacno, jdac_requests::PRBS); jesd_prbs(dacno, false); jesd_stpl(dacno, true); - jdac_basic_request(dacno, 3); + jdac_basic_request(dacno, jdac_requests::STPL); jesd_stpl(dacno, false); - jdac_basic_request(dacno, 0); + jdac_basic_request(dacno, jdac_requests::INIT); let t = clock::get_ms(); while !jesd_ready(dacno) { @@ -87,7 +89,7 @@ pub fn init() { } } clock::spin_us(5000); - jdac_basic_request(dacno, 1); + jdac_basic_request(dacno, jdac_requests::PRINT_STATUS); if !jesd_jsync(dacno) { error!("bad SYNC"); diff --git a/artiq/firmware/satman/main.rs b/artiq/firmware/satman/main.rs index 9c8e32c93..c08e1b605 100644 --- a/artiq/firmware/satman/main.rs +++ b/artiq/firmware/satman/main.rs @@ -17,6 +17,8 @@ use board_artiq::hmc830_7043; mod repeater; #[cfg(has_jdcg)] mod jdcg; +#[cfg(any(has_ad9154, has_jdcg))] +pub mod jdac_requests; fn drtiosat_reset(reset: bool) { unsafe { @@ -299,10 +301,10 @@ fn process_aux_packet(_repeaters: &mut [repeater::Repeater], #[cfg(rtio_frequency = "150.0")] const LINERATE: u64 = 6_000_000_000; match _reqno { - 0 => board_artiq::ad9154::setup(_dacno, LINERATE).is_ok(), - 1 => { board_artiq::ad9154::status(_dacno); true }, - 2 => board_artiq::ad9154::prbs(_dacno).is_ok(), - 3 => board_artiq::ad9154::stpl(_dacno, 4, 2).is_ok(), + jdac_requests::INIT => board_artiq::ad9154::setup(_dacno, LINERATE).is_ok(), + jdac_requests::PRINT_STATUS => { board_artiq::ad9154::status(_dacno); true }, + jdac_requests::PRBS => board_artiq::ad9154::prbs(_dacno).is_ok(), + jdac_requests::STPL => board_artiq::ad9154::stpl(_dacno, 4, 2).is_ok(), _ => false } };