X-Git-Url: https://jxself.org/git/?a=blobdiff_plain;f=tools%2Fcarlu%2Fsrc%2Ftest.c;h=bf49559fa057ee44908da1e4746eb05d263382dc;hb=12cc2cc355d1dce3d50c78e0f680b3cda0c73dfe;hp=8d3e310a57023689b42a5836ac52efd4bcb4423e;hpb=13859edfa20c4b84b575f8e872636fd8cdd81d7f;p=carl9170fw.git diff --git a/tools/carlu/src/test.c b/tools/carlu/src/test.c index 8d3e310..bf49559 100644 --- a/tools/carlu/src/test.c +++ b/tools/carlu/src/test.c @@ -1,9 +1,9 @@ /* - * carl9170user - userspace testing utility for ar9170 devices + * carlu - userspace testing utility for ar9170 devices * * Various tests * - * Copyright 2009, 2010 Christian Lamparter + * Copyright 2009-2011 Christian Lamparter * * This program is free software; you can redistribute it and/or modify * it under the terms of the GNU General Public License as published by @@ -83,12 +83,9 @@ static int carlu_loopback_cmd(struct carlu *ar __unused, dbg("received tx feedback (%d).\n", n); for (i = 0; i < n; i++) { - dbg("cookie:%x success:%d rix:%d tries:%d queue:%d\n", - cmd->tx_status[i].cookie, - cmd->tx_status[i].success, - cmd->tx_status[i].rix, - cmd->tx_status[i].tries, - cmd->tx_status[i].queue); + dbg("cookie:%x info:%x\n", + cmd->_tx_status[i].cookie, + cmd->_tx_status[i].info); } return -1; @@ -193,3 +190,48 @@ 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 = cmd; \ + if ((__err)) \ + 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); +} + +int carlu_random_test(struct carlu *ar) +{ + uint32_t buf[4096]; + int err, i; + + err = carlu_cmd_mem_watch(ar, AR9170_RAND_REG_NUM, sizeof(buf), buf); + if (err) + return err; + + for (i = 0; i < ARRAY_SIZE(buf); i++) + info("%.2x %.2x ", buf[i] & 0xff, buf[i] >> 8); + + info("\n"); +}