1
0
Fork 0

cxp upconn firmware: packet testing

This commit is contained in:
morgan 2024-07-23 16:40:17 +08:00
parent 1cbf91de95
commit c0c498a995
1 changed files with 42 additions and 0 deletions

View File

@ -0,0 +1,42 @@
use embedded_hal::prelude::_embedded_hal_blocking_delay_DelayUs;
use libboard_zynq::timer::GlobalTimer;
pub use crate::cxp_proto;
use crate::pl::{csr, csr::CXP};
pub fn tx_test(channel: usize, timer: &mut GlobalTimer) {
const LEN: usize = 4 * 30;
let mut pak_arr: [u8; LEN] = [0; LEN];
unsafe {
// cxp_proto::read_u32(channel, 0x00).expect("Cannot Write CoaXpress Register");
// cxp_proto::write_u64(channel, 0x00, 0x01);
// cxp_proto::send(channel, &cxp_proto::Packet::EventAck { packet_tag: 0x04 }).expect("Cannot send CoaXpress packet");
// cxp_proto::send(channel, &cxp_proto::Packet::TestPacket).expect("Cannot send CoaXpress packet");
timer.delay_us(2); // send one word
// DEBUG: Trigger packet
(CXP[channel].upconn_trig_delay_write)(0x86);
(CXP[channel].upconn_linktrigger_write)(0x00);
(CXP[channel].upconn_trig_stb_write)(1); // send trig
// DEBUG: Trigger ACK packet
// CXP[channel].upconn_ack_write(1);
timer.delay_us(20);
csr::cxp_phys::upconn_tx_enable_write(0);
// Collect data
let mut i: usize = 0;
while csr::cxp_phys::upconn_tx0_debug_buf_dout_valid_read() == 1 {
pak_arr[i] = csr::cxp_phys::upconn_tx0_debug_buf_dout_pak_read();
csr::cxp_phys::upconn_tx0_debug_buf_inc_write(1);
i += 1;
if i == LEN {
break;
}
}
cxp_proto::print_packet(&pak_arr);
}
}