1
0
Fork 0

proto FW: add memory write test

proto FW: fix compilation error
This commit is contained in:
morgan 2024-09-25 16:59:11 +08:00
parent a5c0e3b71b
commit b48fc06fa3
1 changed files with 37 additions and 1 deletions

View File

@ -1,10 +1,12 @@
use core::slice;
use core_io::{Error as IoError, Write};
use crc::crc32;
use embedded_hal::prelude::_embedded_hal_blocking_delay_DelayUs;
use io::Cursor;
use libboard_zynq::{println, timer::GlobalTimer};
use crate::pl::csr;
use crate::{mem::mem::CXP_MEM, pl::csr};
const MAX_PACKET: usize = 128;
const DATA_MAXSIZE: usize = /*max size*/MAX_PACKET - /*Tag*/4 - /*Op code & length*/4 - /*addr*/4 - /*CRC*/4 ;
@ -243,3 +245,37 @@ pub fn downconn_send_test_packet() {
while csr::cxp::downconn_testseq_busy_read() == 1 {}
}
}
pub fn ram_writer_send(packet: &Packet) -> Result<(), Error> {
unsafe {
// TODO: put this in mem group
while csr::cxp::transmitter_cxp_tx_read() == 1 {}
let ptr = CXP_MEM[0].base as *mut u32;
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, 0x200 as usize));
packet.write_to(&mut writer)?;
csr::cxp::transmitter_cxp_tx_word_len_write(writer.position() as u8 / 4);
csr::cxp::transmitter_cxp_tx_write(1);
while csr::cxp::transmitter_cxp_tx_read() == 1 {}
// read the fifo
const LEN: usize = 10;
let mut pak_arr: [u32; LEN] = [0; LEN];
let mut k_arr: [u8; LEN] = [0; LEN];
let mut i: usize = 0;
while csr::cxp::transmitter_debug_out_dout_valid_read() == 1 {
pak_arr[i] = csr::cxp::transmitter_debug_out_dout_pak_read();
k_arr[i] = csr::cxp::transmitter_debug_out_kout_pak_read();
// println!("received {:#04X}", pak_arr[i]);
csr::cxp::transmitter_debug_out_inc_write(1);
i += 1;
if i == LEN {
break;
}
}
print_packetu32(&pak_arr, &k_arr);
}
Ok(())
}