1
0
Fork 0

cxp upconn fw: cleanup tx_test

This commit is contained in:
morgan 2024-09-02 12:58:42 +08:00
parent 33fd84cadd
commit e9419a5958
1 changed files with 10 additions and 52 deletions

View File

@ -47,13 +47,7 @@ pub fn pipeline_test(timer: &mut GlobalTimer) {
}
pub fn tx_test(timer: &mut GlobalTimer) {
// the 8bit shift is k symbol
// const K28_1: u16 = 0x3C | (1 << 8);
// const K28_5: u16 = 0xBC | (1 << 8);
const D01_1: u16 = 0x21;
const D31_1: u16 = 0x3F;
const LEN: usize = 4 * 100;
const LEN: usize = 4 * 30;
let mut pak_arr: [u8; LEN] = [0; LEN];
unsafe {
@ -64,17 +58,20 @@ pub fn tx_test(timer: &mut GlobalTimer) {
// TODO: verify the char & word boundary thingy
for _ in 0..12 {
csr::cxp::upconn_symbol2_write(D31_1);
csr::cxp::upconn_symbol2_write(0xFF);
}
csr::cxp::upconn_tx_enable_write(1);
// Give some time for symbol2 to send b4 sending priority zero packet
timer.delay_us(1);
for _ in 0..3 {
csr::cxp::upconn_symbol0_write(D01_1);
for i in 0..6 {
csr::cxp::upconn_symbol0_write(i + 1);
}
timer.delay_us(10);
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 {
pak_arr[i] = csr::cxp::upconn_upconn_phy_debug_buf_dout_pak_read();
@ -89,7 +86,8 @@ pub fn tx_test(timer: &mut GlobalTimer) {
println!("arr = [");
for i in 0..(LEN / 4) {
println!(
" {:#04X} {:#04X} {:#04X} {:#04X},",
"{:#03} {:#04X} {:#04X} {:#04X} {:#04X},",
i + 1,
pak_arr[i * 4],
pak_arr[i * 4 + 1],
pak_arr[i * 4 + 2],
@ -97,47 +95,7 @@ pub fn tx_test(timer: &mut GlobalTimer) {
)
}
println!("]");
// for i in 0..LEN {
// arr[i] = get_encoded();
// // if csr::cxp::upconn_tx_busy_read() == 0 {
// // break;
// // };
// }
// let mut last_encoded: u16 = 0;
// for i in 0..LEN {
// if last_encoded != arr[i] {
// match arr[i] {
// 0b1010111001 | 0b0101001001 => {
// println!("D31.1")
// }
// 0b0111011001 | 0b1000101001 => {
// println!("D01.1")
// }
// 0b1101010010 | 0b0010101101 => {
// println!("D04.4")
// }
// 0b0011111010 | 0b1100000101 => {
// println!("K28.5 start idling...")
// }
// 0b0011111001 | 0b1100000110 => {
// println!("K28.1 idling...")
// }
// 0b1010101010 => {
// println!("D21.5 END idle")
// }
// _ => {
// println!("encoded = {:#012b}", arr[i])
// }
// }
// last_encoded = arr[i]
// }
// }
// println!("-------------------------------------");
timer.delay_us(2_000_000);
}
}
fn get_encoded() -> u16 {
unsafe { csr::cxp::upconn_encoded_data_read().reverse_bits() >> 6 }
}
}