1
0
Fork 0

cxp upconn fw: update csr name

This commit is contained in:
morgan 2024-09-05 11:38:35 +08:00
parent bacb446e6a
commit 20de7b0a0c
1 changed files with 16 additions and 16 deletions

View File

@ -93,10 +93,10 @@ pub fn tx_test(timer: &mut GlobalTimer) {
}
pub enum Command<T> {
ControlRead { addr: u32 },
ControlWrite { addr: u32, data: T },
ControlReadWithTag { addr: u32, tag: u8 },
ControlWriteWithTag { addr: u32, data: T, tag: u8 },
Read { addr: u32 },
Write { addr: u32, data: T },
ReadWithTag { addr: u32, tag: u8 },
WriteWithTag { addr: u32, data: T, tag: u8 },
}
pub enum Packet {
@ -109,24 +109,24 @@ impl Packet {
where W: Write {
match self {
Packet::ControlU32Reg(cmd) => match cmd {
Command::ControlRead { addr } => {
Command::Read { addr } => {
writer.write(&[0x02; 4])?;
writer.write(&[0x00, 0x00, 0x00, 0x04])?;
writer.write(&addr.to_be_bytes())?;
}
Command::ControlWrite { addr, data } => {
Command::Write { addr, data } => {
writer.write(&[0x02; 4])?;
writer.write(&[0x01, 0x00, 0x00, 0x04])?;
writer.write(&addr.to_be_bytes())?;
writer.write(&data.to_be_bytes())?;
}
Command::ControlReadWithTag { addr, tag } => {
Command::ReadWithTag { addr, tag } => {
writer.write(&[0x05; 4])?;
writer.write(&[*tag; 4])?;
writer.write(&[0x00, 0x00, 0x00, 0x04])?;
writer.write(&addr.to_be_bytes())?;
}
Command::ControlWriteWithTag { addr, data, tag } => {
Command::WriteWithTag { addr, data, tag } => {
writer.write(&[0x05; 4])?;
writer.write(&[*tag; 4])?;
writer.write(&[0x01, 0x00, 0x00, 0x04])?;
@ -135,24 +135,24 @@ impl Packet {
}
},
Packet::ControlU64Reg(cmd) => match cmd {
Command::ControlRead { addr } => {
Command::Read { addr } => {
writer.write(&[0x02; 4])?;
writer.write(&[0x00, 0x00, 0x00, 0x08])?;
writer.write(&addr.to_be_bytes())?;
}
Command::ControlWrite { addr, data } => {
Command::Write { addr, data } => {
writer.write(&[0x02; 4])?;
writer.write(&[0x01, 0x00, 0x00, 0x08])?;
writer.write(&addr.to_be_bytes())?;
writer.write(&data.to_be_bytes())?;
}
Command::ControlReadWithTag { addr, tag } => {
Command::ReadWithTag { addr, tag } => {
writer.write(&[0x05; 4])?;
writer.write(&[*tag; 4])?;
writer.write(&[0x00, 0x00, 0x00, 0x08])?;
writer.write(&addr.to_be_bytes())?;
}
Command::ControlWriteWithTag { addr, data, tag } => {
Command::WriteWithTag { addr, data, tag } => {
writer.write(&[0x05; 4])?;
writer.write(&[*tag; 4])?;
writer.write(&[0x01, 0x00, 0x00, 0x08])?;
@ -180,10 +180,10 @@ pub fn send(packet: &Packet) -> Result<(), IoError> {
unsafe {
let len = writer.position();
csr::cxp::upconn_command_din_len_write(len as u8);
csr::cxp::upconn_command_len_write(len as u8);
for data in writer.get_ref()[..len].iter() {
while csr::cxp::upconn_command_din_ready_read() == 0 {}
csr::cxp::upconn_command_din_data_write(*data);
while csr::cxp::upconn_command_writeable_read() == 0 {}
csr::cxp::upconn_command_data_write(*data);
}
}
@ -192,7 +192,7 @@ pub fn send(packet: &Packet) -> Result<(), IoError> {
pub fn pipeline_test(timer: &mut GlobalTimer) {
// CXP CRC example
send(&Packet::ControlU32Reg(Command::ControlRead { addr: 0x00 })).expect("Cannot send CoaXpress packet");
send(&Packet::ControlU32Reg(Command::Read { addr: 0x00 })).expect("Cannot send CoaXpress packet");
unsafe {
timer.delay_us(1);