1
0
Fork 0

cxp upconn firmware: low speed serial setup

testing: add trigger & trigger ack CSR to test tranmission prioirty
upconn: add some upconn error for control flow
upconn: add control packet writer
control packet: add u32 & u64 register control
control packet: add CRC calculation & packet type inserter in fw
This commit is contained in:
morgan 2024-07-23 16:40:17 +08:00
parent 4d03154e63
commit 6daf653f73
2 changed files with 51 additions and 0 deletions

View File

@ -0,0 +1,48 @@
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[channel].upconn_clk_reset_write)(1);
// CXP[channel].upconn_bitrate2x_enable_write(1);
(CXP[channel].upconn_clk_reset_write)(0);
(CXP[channel].upconn_tx_enable_write)(1);
timer.delay_us(2); // send one word
// 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);
// 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);
(CXP[channel].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);
}
}

View File

@ -42,6 +42,9 @@ pub mod si5324;
pub mod si549;
use core::{cmp, str};
#[cfg(has_cxp_phys)]
pub mod cxp_upconn;
pub fn identifier_read(buf: &mut [u8]) -> &str {
unsafe {
pl::csr::identifier::address_write(0);