1
0
Fork 0

downconn fw: add ring buffer test

This commit is contained in:
morgan 2024-10-07 13:15:53 +08:00
parent 9305336ba4
commit d3e0cc2819
1 changed files with 19 additions and 13 deletions

View File

@ -43,20 +43,24 @@ pub fn loopback_testing(channel: usize, timer: &mut GlobalTimer, speed: CXP_SPEE
cxp_proto::downconn_debug_send_trig_ack(channel);
const SEND_TIMES: usize = 4;
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::UpConnPacket::CtrlAckLoopback {
ackcode: 0x00,
length: 0x04,
data: data_slice,
},
)
.expect("loopback gtx tx error");
for i in 0..SEND_TIMES {
let data: u32 = i as u32;
data_slice[..4].clone_from_slice(&data.to_be_bytes());
cxp_proto::downconn_debug_send(
channel,
&cxp_proto::UpConnPacket::CtrlAckLoopback {
ackcode: 0x00,
length: 0x04,
data: data_slice,
},
)
.expect("loopback gtx tx error");
}
timer.delay_us(1000); // wait packet has arrive at RX async fifo
(CXP[channel].downconn_tx_stb_write)(0);
@ -69,8 +73,10 @@ 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).expect("loopback gtx rx error");
cxp_proto::downconn_debug_mem_print(channel);
for _ in 0..SEND_TIMES {
cxp_proto::receive(channel).expect("loopback gtx rx error");
}
// cxp_proto::downconn_debug_mem_print(channel);
// DEBUG: print loopback packets
const LEN: usize = 20;