diff --git a/src/main/aciotest/Module.mk b/src/main/aciotest/Module.mk index 43bfe5b..4af9fae 100644 --- a/src/main/aciotest/Module.mk +++ b/src/main/aciotest/Module.mk @@ -6,4 +6,5 @@ libs_aciotest := \ src_aciotest := \ icca.c \ + kfca.c \ main.c \ diff --git a/src/main/aciotest/kfca.c b/src/main/aciotest/kfca.c new file mode 100644 index 0000000..e024578 --- /dev/null +++ b/src/main/aciotest/kfca.c @@ -0,0 +1,75 @@ + #include "aciotest/kfca.h" + +#include "acio/acio.h" + +#include +#include +#include + +#include "aciodrv/kfca.h" + +bool aciotest_kfca_handler_init(uint8_t node_id, void** ctx) +{ + *ctx = malloc(sizeof(uint32_t)); + *((uint32_t*) *ctx) = 0; + + return aciodrv_kfca_init(node_id); +} + +bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx) +{ + struct ac_io_kfca_poll_in pin; + struct ac_io_kfca_poll_out pout; + + static int gpio_test_pin = 0; + static int gpio_test_counter = 0; + + memset(&pout, 0, sizeof(pout)); + pout.gpio |= 1 << gpio_test_pin; + pout.gpio = ac_io_u32(pout.gpio); + + if (!aciodrv_kfca_poll(node_id, &pout, &pin)) { + return false; + } + + pin.adc[0] = ac_io_u16(pin.adc[0]); + pin.adc[1] = ac_io_u16(pin.adc[1]); + + pin.gpio[0] = ac_io_u16(pin.gpio[0]); + pin.gpio[1] = ac_io_u16(pin.gpio[1]); + + printf(">>> KFCA %d: GPIO ON %d\n" + "BTN A B C D: %d %d %d %d\n" + "FX-L R: %d %d\n" + "VOL L: %d\n" + "VOL R: %d\n" + "START COIN TEST SERV REC HP: %d %d %d %d %d %d\n", + node_id, gpio_test_pin, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_A, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_B, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_C, + pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_D, + pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_L, + pin.gpio[1] & AC_IO_KFCA_IN_GPIO_1_FX_R, + (pin.adc[0] >> 6) & 0x3FF, + (pin.adc[1] >> 6) & 0x3FF, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_START, + (pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_COIN, + (pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_TEST, + (pin.gpio_sys) & AC_IO_KFCA_IN_GPIO_SYS_SERVICE, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_RECORDER, + pin.gpio[0] & AC_IO_KFCA_IN_GPIO_0_HEADPHONE + ); + + ++gpio_test_counter; + if (gpio_test_counter >= 4) { + gpio_test_counter = 0; + ++gpio_test_pin; + + if (gpio_test_pin >= 16) { + gpio_test_pin = 0; + } + } + + return true; +} diff --git a/src/main/aciotest/kfca.h b/src/main/aciotest/kfca.h new file mode 100644 index 0000000..215ab67 --- /dev/null +++ b/src/main/aciotest/kfca.h @@ -0,0 +1,10 @@ +#ifndef ACIOTEST_KFCA_H +#define ACIOTEST_KFCA_H + +#include +#include + +bool aciotest_kfca_handler_init(uint8_t node_id, void** ctx); +bool aciotest_kfca_handler_update(uint8_t node_id, void* ctx); + +#endif diff --git a/src/main/aciotest/main.c b/src/main/aciotest/main.c index 21045f7..8bce23d 100644 --- a/src/main/aciotest/main.c +++ b/src/main/aciotest/main.c @@ -8,6 +8,7 @@ #include "aciotest/handler.h" #include "aciotest/icca.h" +#include "aciotest/kfca.h" #include "util/log.h" @@ -29,6 +30,13 @@ static bool aciotest_assign_handler(char product[4], return true; } + if (!memcmp(product, "KFCA", 4)){ + handler->init = aciotest_kfca_handler_init; + handler->update = aciotest_kfca_handler_update; + + return true; + } + return false; }