From bea80d0c1ed411d51e83834d57a81cc3cfb4d14e Mon Sep 17 00:00:00 2001 From: morgan Date: Thu, 3 Oct 2024 15:45:32 +0800 Subject: [PATCH] downconn: loopback rx packet --- src/libboard_artiq/src/cxp_downconn.rs | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/libboard_artiq/src/cxp_downconn.rs b/src/libboard_artiq/src/cxp_downconn.rs index 3d6af4f..7b982ad 100644 --- a/src/libboard_artiq/src/cxp_downconn.rs +++ b/src/libboard_artiq/src/cxp_downconn.rs @@ -43,16 +43,22 @@ pub fn loopback_testing(channel: usize, timer: &mut GlobalTimer, speed: CXP_SPEE cxp_proto::downconn_debug_send_trig_ack(channel); + const MAX_PACKET: usize = 128; + const DATA_MAXSIZE: usize = /*max size*/MAX_PACKET - /*Tag*/4 - /*Op code & length*/4 - /*addr*/4 - /*CRC*/4 ; + let data: u32 = 0x11; + let mut data_slice: [u8; DATA_MAXSIZE] = [0; DATA_MAXSIZE]; + data_slice[..4].clone_from_slice(&data.to_be_bytes()); cxp_proto::downconn_debug_send( channel, - &cxp_proto::Packet::CtrlRead { - addr: 0x00, + &cxp_proto::Packet::CtrlAckLoopback { + ackcode: 0x00, length: 0x04, + data: data_slice, }, ) .expect("loopback gtx tx error"); - timer.delay_us(200); // wait packet has arrive at RX async fifo + timer.delay_us(1000); // wait packet has arrive at RX async fifo (CXP[channel].downconn_tx_stb_write)(0); info!("trig ack = {}", (CXP[channel].downconn_trigger_ack_read)()); @@ -63,7 +69,7 @@ pub fn loopback_testing(channel: usize, timer: &mut GlobalTimer, speed: CXP_SPEE info!("test error = {}", (CXP[channel].downconn_test_error_read)()); info!("packet type = {:#06X}", (CXP[channel].downconn_packet_type_read)()); - cxp_proto::receive(channel); + cxp_proto::receive(channel).expect("loopback gtx rx error"); // DEBUG: print loopback packets const LEN: usize = 20; let mut pak_arr: [u32; LEN] = [0; LEN];