forked from M-Labs/artiq-zynq
proto fw: rename and update buffer length
proto FW: fix compilation error
This commit is contained in:
parent
19fe570924
commit
454fa455b6
|
@ -9,9 +9,8 @@ use libboard_zynq::println;
|
|||
use crate::{mem::mem::{CXP_LOOPBACK_MEM, CXP_RX_MEM, CXP_TX_MEM},
|
||||
pl::csr::CXP};
|
||||
|
||||
const MAX_PACKET: usize = 128;
|
||||
const DATA_MAXSIZE: usize = /*max size*/MAX_PACKET - /*Tag*/4 - /*Op code & length*/4 - /*addr*/4 - /*CRC*/4 ;
|
||||
const MEM_LEN: usize = 0x200;
|
||||
const BUF_LEN: usize = 0x800;
|
||||
const DATA_MAXSIZE: usize = 48;
|
||||
|
||||
#[derive(Debug)]
|
||||
pub enum Error {
|
||||
|
@ -129,9 +128,9 @@ pub fn receive(channel: usize) -> Result<Option<DownConnPacket>, Error> {
|
|||
if (CXP[channel].downconn_pending_packet_read)() == 1 {
|
||||
let read_buffer_ptr = (CXP[channel].downconn_read_ptr_read)() as usize;
|
||||
println!("buffer ptr = {}", read_buffer_ptr);
|
||||
let ptr = (CXP_RX_MEM[channel].base + read_buffer_ptr * MEM_LEN) as *mut u8;
|
||||
let ptr = (CXP_RX_MEM[channel].base + read_buffer_ptr * BUF_LEN) as *mut u8;
|
||||
|
||||
let mut reader = Cursor::new(slice::from_raw_parts_mut(ptr, MEM_LEN));
|
||||
let mut reader = Cursor::new(slice::from_raw_parts_mut(ptr, BUF_LEN));
|
||||
let packet_type = (CXP[channel].downconn_packet_type_read)();
|
||||
|
||||
let packet = DownConnPacket::read_from(&mut reader, packet_type);
|
||||
|
@ -274,11 +273,11 @@ fn send_data_packet(channel: usize, packet: &UpConnPacket) -> Result<(), Error>
|
|||
// TODO: put this in mem group
|
||||
while (CXP[channel].upconn_command_tx_read)() == 1 {}
|
||||
let ptr = CXP_TX_MEM[0].base as *mut u32;
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, MEM_LEN));
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, BUF_LEN));
|
||||
|
||||
packet.write_to(&mut writer)?;
|
||||
|
||||
(CXP[channel].upconn_command_tx_word_len_write)(writer.position() as u8 / 4);
|
||||
(CXP[channel].upconn_command_tx_word_len_write)(writer.position() as u16 / 4);
|
||||
(CXP[channel].upconn_command_tx_write)(1);
|
||||
}
|
||||
|
||||
|
@ -387,11 +386,11 @@ pub fn downconn_debug_send(channel: usize, packet: &UpConnPacket) -> Result<(),
|
|||
// TODO: put this in mem group
|
||||
while (CXP[channel].downconn_command_tx_read)() == 1 {}
|
||||
let ptr = CXP_LOOPBACK_MEM[0].base as *mut u32;
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, MEM_LEN));
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, BUF_LEN));
|
||||
|
||||
packet.write_to(&mut writer)?;
|
||||
|
||||
(CXP[channel].downconn_command_tx_word_len_write)(writer.position() as u8 / 4);
|
||||
(CXP[channel].downconn_command_tx_word_len_write)(writer.position() as u16 / 4);
|
||||
(CXP[channel].downconn_command_tx_write)(1);
|
||||
}
|
||||
|
||||
|
@ -401,7 +400,7 @@ pub fn downconn_debug_send(channel: usize, packet: &UpConnPacket) -> Result<(),
|
|||
pub fn downconn_debug_mem_print(channel: usize) {
|
||||
unsafe {
|
||||
let ptr = CXP_RX_MEM[channel].base as *mut u8;
|
||||
let arr = slice::from_raw_parts_mut(ptr, MEM_LEN * 4);
|
||||
let arr = slice::from_raw_parts_mut(ptr, BUF_LEN * 4);
|
||||
print_packet(arr);
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue