forked from M-Labs/artiq-zynq
proto fw: add loopback event packet
This commit is contained in:
parent
2774c8b7a0
commit
c6413d44e5
|
@ -187,6 +187,16 @@ pub enum UpConnPacket {
|
||||||
length: u8,
|
length: u8,
|
||||||
data: [u8; DATA_MAXSIZE],
|
data: [u8; DATA_MAXSIZE],
|
||||||
},
|
},
|
||||||
|
Event {
|
||||||
|
conn_id: u32,
|
||||||
|
packet_tag: u8,
|
||||||
|
length: u16,
|
||||||
|
event_size: u16,
|
||||||
|
namespace: u8,
|
||||||
|
event_id: u16,
|
||||||
|
timestamp: u64,
|
||||||
|
data: [u8; 253],
|
||||||
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
impl UpConnPacket {
|
impl UpConnPacket {
|
||||||
|
@ -251,6 +261,43 @@ impl UpConnPacket {
|
||||||
let checksum = get_cxp_crc(&writer.get_ref()[4..writer.position()]);
|
let checksum = get_cxp_crc(&writer.get_ref()[4..writer.position()]);
|
||||||
writer.write_u32(checksum)?;
|
writer.write_u32(checksum)?;
|
||||||
}
|
}
|
||||||
|
UpConnPacket::Event {
|
||||||
|
conn_id,
|
||||||
|
packet_tag,
|
||||||
|
length,
|
||||||
|
event_size,
|
||||||
|
namespace,
|
||||||
|
event_id,
|
||||||
|
timestamp,
|
||||||
|
data,
|
||||||
|
} => {
|
||||||
|
let id_bytes = conn_id.to_be_bytes();
|
||||||
|
let length_bytes = length.to_be_bytes();
|
||||||
|
|
||||||
|
// event packet header
|
||||||
|
writer.write_4x_u8(0x07)?;
|
||||||
|
|
||||||
|
writer.write_4x_u8(id_bytes[0])?;
|
||||||
|
writer.write_4x_u8(id_bytes[1])?;
|
||||||
|
writer.write_4x_u8(id_bytes[2])?;
|
||||||
|
writer.write_4x_u8(id_bytes[3])?;
|
||||||
|
|
||||||
|
writer.write_4x_u8(packet_tag)?;
|
||||||
|
|
||||||
|
writer.write_4x_u8(length_bytes[0])?;
|
||||||
|
writer.write_4x_u8(length_bytes[1])?;
|
||||||
|
|
||||||
|
// event message
|
||||||
|
let ev_size = event_size.to_be_bytes();
|
||||||
|
let p2: u8 = ((namespace & 0b11) << 6) | ((event_id & 0xF00) >> 8) as u8;
|
||||||
|
let p3: u8 = (event_id & 0xFF) as u8;
|
||||||
|
writer.write_all(&[ev_size[0], ev_size[1], p2, p3])?;
|
||||||
|
writer.write_all(×tamp.to_be_bytes())?;
|
||||||
|
writer.write_all(&data[0..event_size as usize])?;
|
||||||
|
|
||||||
|
let checksum = get_cxp_crc(&writer.get_ref()[4..writer.position()]);
|
||||||
|
writer.write_u32(checksum)?;
|
||||||
|
}
|
||||||
_ => {}
|
_ => {}
|
||||||
}
|
}
|
||||||
Ok(())
|
Ok(())
|
||||||
|
@ -383,7 +430,6 @@ pub fn print_packetu32(pak: &[u32], k: &[u8]) {
|
||||||
|
|
||||||
pub fn downconn_debug_send(channel: usize, packet: &UpConnPacket) -> Result<(), Error> {
|
pub fn downconn_debug_send(channel: usize, packet: &UpConnPacket) -> Result<(), Error> {
|
||||||
unsafe {
|
unsafe {
|
||||||
// TODO: put this in mem group
|
|
||||||
while (CXP[channel].downconn_command_tx_read)() == 1 {}
|
while (CXP[channel].downconn_command_tx_read)() == 1 {}
|
||||||
let ptr = CXP_LOOPBACK_MEM[0].base as *mut u32;
|
let ptr = CXP_LOOPBACK_MEM[0].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, BUF_LEN));
|
||||||
|
|
Loading…
Reference in New Issue