From 4a1d41832bfb79de5e35b38552031b981b51d9c0 Mon Sep 17 00:00:00 2001 From: morgan Date: Tue, 15 Oct 2024 09:53:22 +0800 Subject: [PATCH] api: add cxp api support for CTRL packet --- src/libksupport/src/cxp.rs | 11 +++++++++++ src/libksupport/src/kernel/api.rs | 8 ++++++++ src/libksupport/src/lib.rs | 2 ++ 3 files changed, 21 insertions(+) create mode 100644 src/libksupport/src/cxp.rs diff --git a/src/libksupport/src/cxp.rs b/src/libksupport/src/cxp.rs new file mode 100644 index 0000000..7b7d0bf --- /dev/null +++ b/src/libksupport/src/cxp.rs @@ -0,0 +1,11 @@ +use libboard_artiq::cxp_proto; + +pub extern "C" fn cxp_readu32(channel: i32, addr: i32) { + // TODO: use artiq_raise like i2c? + cxp_proto::read_u32(channel as u8, addr as u32).expect("CXP transmission failed"); +} + +pub extern "C" fn cxp_writeu32(channel: i32, addr: i32, val: i32) { + // TODO: use artiq_raise like i2c? + cxp_proto::write_u32(channel as u8, addr as u32, val as u32).expect("CXP transmission failed"); +} diff --git a/src/libksupport/src/kernel/api.rs b/src/libksupport/src/kernel/api.rs index ef77e43..cf20fb2 100644 --- a/src/libksupport/src/kernel/api.rs +++ b/src/libksupport/src/kernel/api.rs @@ -11,6 +11,8 @@ use super::{cache, core1::rtio_get_destination_status, dma, linalg, rpc::{rpc_recv, rpc_send, rpc_send_async}}; +#[cfg(has_cxp_phys)] +use crate::cxp; use crate::{eh_artiq, i2c, rtio}; extern "C" { @@ -126,6 +128,12 @@ pub fn resolve(required: &[u8]) -> Option { #[cfg(has_drtio)] api!(subkernel_await_message = subkernel::await_message), + // CoaXPress + #[cfg(has_cxp_phys)] + api!(cxp_readu32 = cxp::cxp_readu32), + #[cfg(has_cxp_phys)] + api!(cxp_writeu32 = cxp::cxp_writeu32), + // Double-precision floating-point arithmetic helper functions // RTABI chapter 4.1.2, Table 2 api!(__aeabi_dadd), diff --git a/src/libksupport/src/lib.rs b/src/libksupport/src/lib.rs index 630f19e..a243d01 100644 --- a/src/libksupport/src/lib.rs +++ b/src/libksupport/src/lib.rs @@ -35,6 +35,8 @@ pub mod rtio; #[path = "../../../build/pl.rs"] pub mod pl; +#[cfg(has_cxp_phys)] +pub mod cxp; #[derive(Debug, Clone)] pub struct RPCException {