forked from M-Labs/artiq-zynq
proto fw: add rx downconn debug in
This commit is contained in:
parent
5f57cededf
commit
a87208effe
|
@ -191,3 +191,48 @@ pub fn print_packet(pak: &[u8]) {
|
|||
println!("]");
|
||||
println!("============================================");
|
||||
}
|
||||
|
||||
pub fn downconn_debug_main() {
|
||||
downconn_debug_send(&Packet::CtrlRead {
|
||||
addr: 0x00,
|
||||
length: 0x04,
|
||||
});
|
||||
|
||||
const LEN: usize = 100;
|
||||
let mut pak_arr: [u32; LEN] = [0; LEN];
|
||||
let mut i: usize = 0;
|
||||
unsafe {
|
||||
while csr::cxp::downconn_debug_out_dout_valid_read() == 1 {
|
||||
pak_arr[i] = csr::cxp::downconn_debug_out_dout_pak_read();
|
||||
// println!("received {:#04X}", pak_arr[i]);
|
||||
csr::cxp::downconn_debug_out_inc_write(1);
|
||||
i += 1;
|
||||
if i == LEN {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: turn the u32 slice back to u8
|
||||
|
||||
println!("{:#010X?}", pak_arr)
|
||||
}
|
||||
|
||||
pub fn downconn_debug_send(packet: &Packet) -> Result<(), Error> {
|
||||
let mut buffer: [u8; MAX_PACKET] = [0; MAX_PACKET];
|
||||
let mut writer = Cursor::new(&mut buffer[..]);
|
||||
|
||||
packet.write_to(&mut writer)?;
|
||||
|
||||
unsafe {
|
||||
let len = writer.position();
|
||||
csr::cxp::downconn_debug_src_len_write(len as u8);
|
||||
for data in writer.get_ref()[..len].iter() {
|
||||
while csr::cxp::downconn_debug_src_writeable_read() == 0 {}
|
||||
csr::cxp::upconn_command_data_write(*data);
|
||||
csr::cxp::downconn_debug_src_data_write(*data);
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue