1
0
Fork 0

cxp upconn fw: add trigger ack test

This commit is contained in:
morgan 2024-09-02 16:07:39 +08:00
parent 30fb241fda
commit 4a88ba2d46
1 changed files with 40 additions and 3 deletions

View File

@ -3,6 +3,37 @@ use libboard_zynq::{println, timer::GlobalTimer};
use crate::pl::csr; use crate::pl::csr;
pub fn trigger_ack_test(timer: &mut GlobalTimer) {
const LEN: usize = 4 * 8;
let mut pak_arr: [u8; LEN] = [0; LEN];
unsafe {
csr::cxp::txtrig_ack_write(1); // send IO ack
let mut i: usize = 0;
while csr::cxp::txtrig_dout_valid_read() == 1 {
pak_arr[i] = csr::cxp::txtrig_dout_pak_read();
// println!("received {:#04X}", pak_arr[i]);
csr::cxp::txtrig_inc_write(1);
i += 1;
}
println!("arr = [");
for i in 0..(LEN / 4) {
println!(
"{:#03} {:#04X} {:#04X} {:#04X} {:#04X},",
i + 1,
pak_arr[i * 4],
pak_arr[i * 4 + 1],
pak_arr[i * 4 + 2],
pak_arr[i * 4 + 3]
)
}
println!("]");
println!("============================================");
}
}
pub fn pipeline_test(timer: &mut GlobalTimer) { pub fn pipeline_test(timer: &mut GlobalTimer) {
let arr = [ let arr = [
// 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08 // 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08
@ -24,10 +55,13 @@ pub fn pipeline_test(timer: &mut GlobalTimer) {
csr::cxp::txcore_din_pak_write(*a); csr::cxp::txcore_din_pak_write(*a);
} }
// wait for pipelining
timer.delay_us(1);
let mut i: usize = 0; let mut i: usize = 0;
while csr::cxp::txcore_dout_valid_read() == 1 { while csr::cxp::txcore_dout_valid_read() == 1 {
pak_arr[i] = csr::cxp::txcore_dout_pak_read(); pak_arr[i] = csr::cxp::txcore_dout_pak_read();
println!("received {:#04X}", pak_arr[i]); // println!("received {:#04X}", pak_arr[i]);
csr::cxp::txcore_inc_write(1); csr::cxp::txcore_inc_write(1);
i += 1; i += 1;
} }
@ -35,14 +69,16 @@ pub fn pipeline_test(timer: &mut GlobalTimer) {
println!("arr = ["); println!("arr = [");
for i in 0..(LEN / 4) { for i in 0..(LEN / 4) {
println!( println!(
" {:#04X} {:#04X} {:#04X} {:#04X},", "{:#03} {:#04X} {:#04X} {:#04X} {:#04X},",
i + 1,
pak_arr[i * 4], pak_arr[i * 4],
pak_arr[i * 4 + 1], pak_arr[i * 4 + 1],
pak_arr[i * 4 + 2], pak_arr[i * 4 + 2],
pak_arr[i * 4 + 3] pak_arr[i * 4 + 3]
) )
} }
println!("]") println!("]");
println!("============================================");
} }
} }
@ -95,6 +131,7 @@ pub fn tx_test(timer: &mut GlobalTimer) {
) )
} }
println!("]"); println!("]");
println!("============================================");
timer.delay_us(2_000_000); timer.delay_us(2_000_000);
} }
} }