forked from M-Labs/artiq-zynq
cxp upconn fw: update tx_test to use the debug fifos
This commit is contained in:
parent
b1fb90d456
commit
33fd84cadd
|
@ -53,65 +53,87 @@ pub fn tx_test(timer: &mut GlobalTimer) {
|
||||||
const D01_1: u16 = 0x21;
|
const D01_1: u16 = 0x21;
|
||||||
const D31_1: u16 = 0x3F;
|
const D31_1: u16 = 0x3F;
|
||||||
|
|
||||||
const LEN: usize = 200;
|
const LEN: usize = 4 * 100;
|
||||||
let mut arr: [u16; LEN] = [0; LEN];
|
let mut pak_arr: [u8; LEN] = [0; LEN];
|
||||||
|
|
||||||
unsafe {
|
unsafe {
|
||||||
csr::cxp::upconn_clk_reset_write(1);
|
|
||||||
// csr::cxp::upconn_bitrate2x_enable_write(1);
|
|
||||||
csr::cxp::upconn_clk_reset_write(0);
|
|
||||||
|
|
||||||
loop {
|
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
|
// TODO: verify the char & word boundary thingy
|
||||||
for _ in 0..12 {
|
for _ in 0..12 {
|
||||||
csr::cxp::upconn_symbol2_write(D31_1);
|
csr::cxp::upconn_symbol2_write(D31_1);
|
||||||
}
|
}
|
||||||
|
|
||||||
csr::cxp::upconn_tx_enable_write(1);
|
csr::cxp::upconn_tx_enable_write(1);
|
||||||
// timer.delay_us(1);
|
timer.delay_us(1);
|
||||||
|
|
||||||
for _ in 0..3 {
|
for _ in 0..3 {
|
||||||
csr::cxp::upconn_symbol0_write(D01_1);
|
csr::cxp::upconn_symbol0_write(D01_1);
|
||||||
}
|
}
|
||||||
|
timer.delay_us(10);
|
||||||
|
|
||||||
for i in 0..LEN {
|
let mut i: usize = 0;
|
||||||
arr[i] = get_encoded();
|
while csr::cxp::upconn_upconn_phy_debug_buf_dout_valid_read() == 1 {
|
||||||
// if csr::cxp::upconn_tx_busy_read() == 0 {
|
pak_arr[i] = csr::cxp::upconn_upconn_phy_debug_buf_dout_pak_read();
|
||||||
// break;
|
// println!("received {:#04X}", pak_arr[i]);
|
||||||
// };
|
csr::cxp::upconn_upconn_phy_debug_buf_inc_write(1);
|
||||||
}
|
i += 1;
|
||||||
let mut last_encoded: u16 = 0;
|
if i == LEN {
|
||||||
for i in 0..LEN {
|
break;
|
||||||
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!("-------------------------------------");
|
|
||||||
|
|
||||||
csr::cxp::upconn_tx_enable_write(0);
|
println!("arr = [");
|
||||||
|
for i in 0..(LEN / 4) {
|
||||||
|
println!(
|
||||||
|
" {:#04X} {:#04X} {:#04X} {:#04X},",
|
||||||
|
pak_arr[i * 4],
|
||||||
|
pak_arr[i * 4 + 1],
|
||||||
|
pak_arr[i * 4 + 2],
|
||||||
|
pak_arr[i * 4 + 3]
|
||||||
|
)
|
||||||
|
}
|
||||||
|
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);
|
timer.delay_us(2_000_000);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue