1
0
Fork 0

cxp upconn fw: connect tx command to phy

This commit is contained in:
morgan 2024-09-05 12:17:07 +08:00
parent 4f733ffafb
commit 29cca139b3
1 changed files with 21 additions and 58 deletions

View File

@ -50,30 +50,20 @@ pub fn trigger_ack_test(timer: &mut GlobalTimer) {
}
pub fn tx_test(timer: &mut GlobalTimer) {
const LEN: usize = 4 * 30;
const LEN: usize = 4 * 20;
let mut pak_arr: [u8; LEN] = [0; LEN];
unsafe {
loop {
csr::cxp::upconn_clk_reset_write(1);
// csr::cxp::upconn_bitrate2x_enable_write(1);
csr::cxp::upconn_clk_reset_write(0);
// TODO: verify the char & word boundary thingy
for _ in 0..12 {
csr::cxp::upconn_symbol2_write(0xFF);
}
send(&Packet::ControlU32Reg(Command::Read { addr: 0x00 })).expect("Cannot send CoaXpress packet");
csr::cxp::upconn_tx_enable_write(1);
// Give some time for symbol2 to send b4 sending priority zero packet
timer.delay_us(1);
for i in 0..6 {
csr::cxp::upconn_symbol0_write(i + 1);
}
timer.delay_us(20);
csr::cxp::upconn_tx_enable_write(0);
// Collect data
let mut i: usize = 0;
while csr::cxp::upconn_upconn_phy_debug_buf_dout_valid_read() == 1 {
@ -87,8 +77,6 @@ pub fn tx_test(timer: &mut GlobalTimer) {
}
print_packet(&pak_arr);
timer.delay_us(2_000_000);
}
}
}
@ -190,31 +178,6 @@ pub fn send(packet: &Packet) -> Result<(), IoError> {
Ok(())
}
pub fn pipeline_test(timer: &mut GlobalTimer) {
// CXP CRC example
send(&Packet::ControlU32Reg(Command::Read { addr: 0x00 })).expect("Cannot send CoaXpress packet");
unsafe {
timer.delay_us(1);
const LEN: usize = 4 * 8;
let mut pak_arr: [u8; LEN] = [0; LEN];
let mut i: usize = 0;
while csr::cxp::upconn_command_dout_valid_read() == 1 {
pak_arr[i] = csr::cxp::upconn_command_dout_pak_read();
// println!("received {:#04X}", pak_arr[i]);
csr::cxp::upconn_command_inc_write(1);
i += 1;
if i == LEN {
break;
};
}
println!("data packet");
print_packet(&pak_arr);
}
}
fn print_packet(pak: &[u8]) {
println!("pak = [");
for i in 0..(pak.len() / 4) {