added to aciotest

This commit is contained in:
din
2025-09-05 17:56:39 -05:00
parent 0d0e22de61
commit d7e08bb477
7 changed files with 126 additions and 1 deletions

View File

@@ -10,4 +10,4 @@ src_aciodrv := \
panb.c \
rvol.c \
port.c \
mdxf.c \

41
src/main/aciodrv/mdxf.c Normal file
View File

@@ -0,0 +1,41 @@
#include "mdxf.h"
#define LOG_MODULE "aciodrv-mdxf"
#include <stdio.h>
#include <string.h>
#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;
}

14
src/main/aciodrv/mdxf.h Normal file
View File

@@ -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

View File

@@ -13,4 +13,5 @@ src_aciotest := \
rvol.c \
bi2a-iidx.c \
bi2a-sdvx.c \
mdxf.c \
main.c \

View File

@@ -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;

47
src/main/aciotest/mdxf.c Normal file
View File

@@ -0,0 +1,47 @@
#include "aciotest/mdxf.h"
#include "acio/acio.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#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;
}

14
src/main/aciotest/mdxf.h Normal file
View File

@@ -0,0 +1,14 @@
#ifndef ACIOTEST_MDXF_H
#define ACIOTEST_MDXF_H
#include <stdbool.h>
#include <stdint.h>
#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