X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tools%2Fcarlu%2Fsrc%2Ftest.c;h=d31060d870b5fd5616a28c2065b68cbe89faaca1;hb=ddaf4f22a3161d7480d73e03adab1d619784757e;hp=30b3fb336432bfe5e9f6aea693b1c2102617c900;hpb=e72388a0aa23da8bc8e24a0cbe9d523c5a9ce294;p=carl9170fw.git diff --git a/tools/carlu/src/test.c b/tools/carlu/src/test.c index 30b3fb3..d31060d 100644 --- a/tools/carlu/src/test.c +++ b/tools/carlu/src/test.c @@ -37,6 +37,7 @@ #include "debug.h" #include "frame.h" #include "usb.h" +#include "cmd.h" void debug_test(void) { @@ -192,3 +193,33 @@ void carlu_loopback_test(struct carlu *ar, const unsigned int total_runs, ar->cmd_cb = NULL; ar->tx_cb = NULL; } + +int carlu_gpio_test(struct carlu *ar) +{ + uint32_t gpio; + +#define CHK(cmd) \ + do { \ + int __err; \ + if (__err = cmd) \ + return __err; \ + } while (0) + + CHK(carlu_cmd_read_mem(ar, AR9170_GPIO_REG_PORT_DATA, &gpio)); + info("GPIO state:%x\n", gpio); + + /* turn both LEDs on */ + CHK(carlu_cmd_write_mem(ar, AR9170_GPIO_REG_PORT_DATA, + AR9170_GPIO_PORT_LED_0 | AR9170_GPIO_PORT_LED_1)); + + SDL_Delay(700); + + CHK(carlu_cmd_read_mem(ar, AR9170_GPIO_REG_PORT_DATA, &gpio)); + info("GPIO state:%x\n", gpio); + + /* turn LEDs off everything */ + CHK(carlu_cmd_write_mem(ar, AR9170_GPIO_REG_PORT_DATA, 0)); + + CHK(carlu_cmd_read_mem(ar, AR9170_GPIO_REG_PORT_DATA, &gpio)); + info("GPIO state:%x\n", gpio); +}