diff --git a/src/libboard_artiq/src/cxp.rs b/src/libboard_artiq/src/cxp.rs index 2f178b8..602a825 100644 --- a/src/libboard_artiq/src/cxp.rs +++ b/src/libboard_artiq/src/cxp.rs @@ -7,7 +7,7 @@ use log::{info, warn}; use crate::{cxp_ctrl::{read_u32, read_u64, reset_tag, send_test_packet, write_bytes_no_ack, write_u32, write_u64}, cxp_phys::{self, CXP_CHANNELS, CXP_SPEED}, cxp_proto::Error as ProtoError, - pl::csr::{cxp_frame_pipeline, CXP}}; + pl::csr::CXP}; // Bootstrap registers address const STANDARD: u32 = 0x0000; @@ -40,8 +40,8 @@ const HOST_CONNECTION_ID: u32 = 0xC001C0DE; // TODO: rename this pub enum Error { CameraNotDetected, ConnectionLost, - UnstableDownConn, - UnstableUpConn, + UnstableRX, + UnstableTX, UnsupportedSpeed(u32), UnsupportedTopology, UnsupportedVersion, @@ -59,8 +59,8 @@ impl fmt::Display for Error { match self { &Error::CameraNotDetected => write!(f, "CameraNotDetected"), &Error::ConnectionLost => write!(f, "ConnectionLost Some active channels cannot be detected"), - &Error::UnstableDownConn => write!(f, "UnstableDownConn DownConnection test failed"), - &Error::UnstableUpConn => write!(f, "UnstableUpConn UpConnection test failed"), + &Error::UnstableRX => write!(f, "UnstableRX RX connection test failed"), + &Error::UnstableTX => write!(f, "UnstableTX TX connection test failed"), &Error::UnsupportedSpeed(linerate_code) => write!( f, "UnsupportedSpeed {:#X} linerate code is not supported", @@ -89,8 +89,8 @@ pub fn setup() -> Result { fn scan_active_channels() -> u8 { let mut active_channels: u8 = 0; for ch in 0..CXP_CHANNELS { - if unsafe { (CXP[ch as usize].downconn_rx_ready_read)() } == 1 { - info!("ch#{} is up <---------------------------------", ch); + if unsafe { (CXP[ch as usize].rx_ready_read)() } == 1 { + // info!("ch#{} is up <---------------------------------", ch); active_channels += 1; } } @@ -287,7 +287,7 @@ fn set_operation_linerate(active_channels: u8, with_tag: bool, timer: &mut Globa } fn test_counter_reset(channel: u8, with_tag: bool) -> Result<(), Error> { - unsafe { (CXP[channel as usize].downconn_bootstrap_test_counts_reset_write)(1) }; + unsafe { (CXP[channel as usize].rx_bootstrap_test_counts_reset_write)(1) }; write_u32(MASTER_CHANNEL, TEST_ERROR_COUNT_SELECTOR, channel as u32, with_tag)?; write_u32(MASTER_CHANNEL, TEST_ERROR_COUNT, 0, with_tag)?; write_u64(MASTER_CHANNEL, TEST_PACKET_COUNT_TX, 0, with_tag)?; @@ -301,31 +301,31 @@ fn verify_test_result(channel: u8, with_tag: bool) -> Result<(), Error> { // Section 9.9.3 (CXP-001-2021) // verify grabber -> camera connection test result if read_u64(MASTER_CHANNEL, TEST_PACKET_COUNT_RX, with_tag)? != TX_TEST_CNT as u64 { - return Err(Error::UnstableUpConn); + return Err(Error::UnstableTX); }; if read_u32(MASTER_CHANNEL, TEST_ERROR_COUNT, with_tag)? > 0 { - return Err(Error::UnstableUpConn); + return Err(Error::UnstableTX); }; // Section 9.9.4 (CXP-001-2021) // verify camera -> grabber connection test result let camera_test_pak_cnt = read_u64(MASTER_CHANNEL, TEST_PACKET_COUNT_TX, true)?; unsafe { - if (CXP[channel as usize].downconn_bootstrap_test_packet_counter_read)() != camera_test_pak_cnt as u16 { + if (CXP[channel as usize].rx_bootstrap_test_packet_counter_read)() != camera_test_pak_cnt as u16 { info!( "CHANNEL #{} test packet cnt = {}", channel, - (CXP[channel as usize].downconn_bootstrap_test_packet_counter_read)() + (CXP[channel as usize].rx_bootstrap_test_packet_counter_read)() ); - return Err(Error::UnstableDownConn); + return Err(Error::UnstableRX); }; - if (CXP[channel as usize].downconn_bootstrap_test_error_counter_read)() > 0 { + if (CXP[channel as usize].rx_bootstrap_test_error_counter_read)() > 0 { info!( "CHANNEL #{} test packet error cnt = {}", channel, - (CXP[channel as usize].downconn_bootstrap_test_error_counter_read)() + (CXP[channel as usize].rx_bootstrap_test_error_counter_read)() ); - return Err(Error::UnstableDownConn); + return Err(Error::UnstableRX); }; }; info!("CHANNEL #{} pass testing", channel);