From d7e08bb4776f3b21e486475aa458c24d60492a5e Mon Sep 17 00:00:00 2001 From: din Date: Fri, 5 Sep 2025 17:56:39 -0500 Subject: [PATCH] added to aciotest --- src/main/aciodrv/Module.mk | 2 +- src/main/aciodrv/mdxf.c | 41 ++++++++++++++++++++++++++++++++ src/main/aciodrv/mdxf.h | 14 +++++++++++ src/main/aciotest/Module.mk | 1 + src/main/aciotest/main.c | 8 +++++++ src/main/aciotest/mdxf.c | 47 +++++++++++++++++++++++++++++++++++++ src/main/aciotest/mdxf.h | 14 +++++++++++ 7 files changed, 126 insertions(+), 1 deletion(-) create mode 100644 src/main/aciodrv/mdxf.c create mode 100644 src/main/aciodrv/mdxf.h create mode 100644 src/main/aciotest/mdxf.c create mode 100644 src/main/aciotest/mdxf.h diff --git a/src/main/aciodrv/Module.mk b/src/main/aciodrv/Module.mk index 0aad3e3..8239d51 100644 --- a/src/main/aciodrv/Module.mk +++ b/src/main/aciodrv/Module.mk @@ -10,4 +10,4 @@ src_aciodrv := \ panb.c \ rvol.c \ port.c \ - + mdxf.c \ diff --git a/src/main/aciodrv/mdxf.c b/src/main/aciodrv/mdxf.c new file mode 100644 index 0000000..cbd59a8 --- /dev/null +++ b/src/main/aciodrv/mdxf.c @@ -0,0 +1,41 @@ +#include "mdxf.h" + +#define LOG_MODULE "aciodrv-mdxf" + +#include +#include + +#include "aciodrv/device.h" + +#include "util/log.h" + +bool aciodrv_mdxf_init(struct aciodrv_device_ctx *device, uint8_t node_id) +{ + log_assert(device); + + return true; +} + +bool aciodrv_mdxf_poll( + struct aciodrv_device_ctx *device, + uint8_t node_id, + const struct ac_io_mdxf_poll_in *pin) +{ + struct ac_io_message msg = {0}; + + msg.addr = node_id + 1; + msg.cmd.code = ac_io_u16(AC_IO_CMD_MDXF_POLL); + msg.cmd.nbytes = 0; + + aciodrv_send_and_recv( + device, + &msg, + offsetof(struct ac_io_message, cmd.raw) + + sizeof(struct ac_io_mdxf_poll_in) + 1); + + if (pin != NULL) { + memcpy(pin, &msg.cmd.mdxf_poll_in, sizeof(*pin)); + } + + return true; +} \ No newline at end of file diff --git a/src/main/aciodrv/mdxf.h b/src/main/aciodrv/mdxf.h new file mode 100644 index 0000000..e2ad8ec --- /dev/null +++ b/src/main/aciodrv/mdxf.h @@ -0,0 +1,14 @@ +#ifndef ACIODRV_MDXF_H +#define ACIODRV_MDXF_H + +#include "acio/mdxf.h" +#include "aciodrv/device.h" + +bool aciodrv_mdxf_init(struct aciodrv_device_ctx *device, uint8_t node_id); + +bool aciodrv_mdxf_poll( + struct aciodrv_device_ctx *device, + uint8_t node_id, + const struct ac_io_mdxf_poll_in *pout); + +#endif \ No newline at end of file diff --git a/src/main/aciotest/Module.mk b/src/main/aciotest/Module.mk index af04652..2476b56 100644 --- a/src/main/aciotest/Module.mk +++ b/src/main/aciotest/Module.mk @@ -13,4 +13,5 @@ src_aciotest := \ rvol.c \ bi2a-iidx.c \ bi2a-sdvx.c \ + mdxf.c \ main.c \ diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c index 4a301c4..961b4ec 100644 --- a/src/main/aciotest/main.c +++ b/src/main/aciotest/main.c @@ -12,6 +12,7 @@ #include "aciotest/handler.h" #include "aciotest/icca.h" #include "aciotest/kfca.h" +#include "aciotest/mdxf.h" #include "aciotest/panb.h" #include "aciotest/rvol.h" @@ -40,6 +41,13 @@ static bool aciotest_assign_handler( return true; } + if (product_type == AC_IO_NODE_TYPE_MDXF) { + handler->init = aciotest_mdxf_handler_init; + handler->update = aciotest_mdxf_handler_update; + + return true; + } + if (product_type == AC_IO_NODE_TYPE_PANB) { handler->init = aciotest_panb_handler_init; handler->update = aciotest_panb_handler_update; diff --git a/src/main/aciotest/mdxf.c b/src/main/aciotest/mdxf.c new file mode 100644 index 0000000..5649d0e --- /dev/null +++ b/src/main/aciotest/mdxf.c @@ -0,0 +1,47 @@ +#include "aciotest/mdxf.h" + +#include "acio/acio.h" + +#include +#include +#include + +#include "aciodrv/mdxf.h" + +#define MDXF_PANEL_FLAGS(var) \ + ((var) & 0b1000 ? 'U' : '-'), ((var) & 0b0100 ? 'D' : '-'), \ + ((var) & 0b0010 ? 'L' : '-'), ((var) & 0b0001 ? 'R' : '-') + +bool aciotest_mdxf_handler_init( + struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx) +{ + *ctx = malloc(sizeof(uint32_t)); + *((uint32_t *) *ctx) = 0; + + return aciodrv_mdxf_init(device, node_id); +} + +bool aciotest_mdxf_handler_update( + struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx) +{ + struct ac_io_mdxf_poll_in pin; + + if (!aciodrv_mdxf_poll(device, node_id, &pin)) { + return false; + } + + printf( + ">>> MDXF (DDR) P%d:\n" + "Foot Up %c%c%c%c\n" + "Foot Down %c%c%c%c\n" + "Foot Left %c%c%c%c\n" + "Foot Right %c%c%c%c\n" + "\n", + node_id + 1, + MDXF_PANEL_FLAGS(pin.panel.up), + MDXF_PANEL_FLAGS(pin.panel.down), + MDXF_PANEL_FLAGS(pin.panel.left), + MDXF_PANEL_FLAGS(pin.panel.right)); + + return true; +} diff --git a/src/main/aciotest/mdxf.h b/src/main/aciotest/mdxf.h new file mode 100644 index 0000000..cba1cd4 --- /dev/null +++ b/src/main/aciotest/mdxf.h @@ -0,0 +1,14 @@ +#ifndef ACIOTEST_MDXF_H +#define ACIOTEST_MDXF_H + +#include +#include + +#include "aciodrv/device.h" + +bool aciotest_mdxf_handler_init( + struct aciodrv_device_ctx *device, uint8_t node_id, void **ctx); +bool aciotest_mdxf_handler_update( + struct aciodrv_device_ctx *device, uint8_t node_id, void *ctx); + +#endif