forked from M-Labs/artiq-zynq
ctrl: fix compilation err & use ctrl pak maxsize
This commit is contained in:
parent
d9ddd25dc4
commit
8699ecd3bb
@ -4,11 +4,10 @@ use byteorder::{ByteOrder, NetworkEndian};
|
||||
use io::Cursor;
|
||||
use libboard_zynq::{println, time::Milliseconds, timer::GlobalTimer};
|
||||
|
||||
use crate::{cxp_proto::{print_packet, Error, RXPacket, TXPacket, DATA_MAXSIZE},
|
||||
use crate::{cxp_proto::{print_packet, Error, RXPacket, TXPacket, CTRL_PACKET_MAXSIZE, DATA_MAXSIZE},
|
||||
mem::mem::CXP_MEM,
|
||||
pl::csr::CXP};
|
||||
|
||||
const BUF_LEN: usize = 0x800;
|
||||
const TRANSMISSION_TIMEOUT: u64 = 200;
|
||||
|
||||
fn packet_pending(channel: u8) -> bool {
|
||||
@ -21,9 +20,10 @@ fn receive(channel: u8) -> Result<Option<RXPacket>, Error> {
|
||||
unsafe {
|
||||
let read_buffer_ptr = (CXP[channel].rx_read_ptr_read)() as usize;
|
||||
println!("buffer ptr = {}", read_buffer_ptr);
|
||||
let ptr = (CXP_MEM[channel].base + CXP_MEM[channel].size / 2 + read_buffer_ptr * BUF_LEN) as *mut u32;
|
||||
let ptr =
|
||||
(CXP_MEM[channel].base + CXP_MEM[channel].size / 2 + read_buffer_ptr * CTRL_PACKET_MAXSIZE) as *mut u32;
|
||||
|
||||
let mut reader = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, BUF_LEN));
|
||||
let mut reader = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, CTRL_PACKET_MAXSIZE));
|
||||
let packet_type = (CXP[channel].rx_packet_type_read)();
|
||||
println!("packet_type = {}", packet_type);
|
||||
// DEBUG:
|
||||
@ -60,14 +60,14 @@ fn send_data_packet(channel: u8, packet: &TXPacket) -> Result<(), Error> {
|
||||
unsafe {
|
||||
while (CXP[channel].tx_writer_busy_read)() == 1 {}
|
||||
let ptr = CXP_MEM[channel].base as *mut u32;
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, BUF_LEN));
|
||||
let mut writer = Cursor::new(slice::from_raw_parts_mut(ptr as *mut u8, CTRL_PACKET_MAXSIZE));
|
||||
|
||||
packet.write_to(&mut writer)?;
|
||||
// DEBUG:
|
||||
// println!("TX MEM after writing");
|
||||
// print_packet(&writer.get_ref()[0..40]);
|
||||
|
||||
(CXP[channel].tx_writer_word_len_write)(writer.position() as u16 / 4);
|
||||
(CXP[channel].tx_writer_word_len_write)((writer.position() / 4) as u8);
|
||||
(CXP[channel].tx_writer_stb_write)(1);
|
||||
}
|
||||
|
||||
@ -92,7 +92,7 @@ pub fn send_test_packet(channel: u8) -> Result<(), Error> {
|
||||
pub fn rx_debug_mem_print(channel: u8) {
|
||||
unsafe {
|
||||
let ptr = CXP_MEM[channel as usize].base as *mut u32;
|
||||
let arr = slice::from_raw_parts_mut(ptr as *mut u8, BUF_LEN * 4);
|
||||
let arr = slice::from_raw_parts_mut(ptr as *mut u8, CTRL_PACKET_MAXSIZE * 4);
|
||||
print_packet(arr);
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user