return err;
}
+int carlu_cmd_read_mem(struct carlu *ar, const uint32_t _addr,
+ uint32_t *val)
+{
+ int err;
+ __le32 msg, addr = { cpu_to_le32(_addr) };
+ err = carlusb_cmd(ar, CARL9170_CMD_RREG, (void *) &addr, sizeof(addr),
+ (void *) &msg, sizeof(msg));
+
+ *val = le32_to_cpu(msg);
+ return err;
+}
+
int carlu_cmd_read_eeprom(struct carlu *ar)
{
return err ? EXIT_FAILURE : EXIT_SUCCESS;
}
+static int carlu_run_gpio_test(void)
+{
+ struct carlu *carl = NULL;
+ int err;
+
+ err = carlu_init();
+ if (err)
+ goto out;
+
+ carl = carlusb_probe();
+ if (IS_ERR_OR_NULL(carl)) {
+ err = PTR_ERR(carl);
+ goto out;
+ }
+
+ err = carlu_gpio_test(carl);
+ if (err)
+ goto out_close;
+
+out_close:
+ carlusb_close(carl);
+
+out:
+ carlu_exit();
+ return err ? EXIT_FAILURE : EXIT_SUCCESS;
+}
+
static int carlu_run_loop_test(void)
{
struct carlu *carl;
MENU_ITEM('l', carlusb_print_known_devices, "list of all known ar9170 usb devices."),
MENU_ITEM('p', carlu_probe_all, "probe all possible devices."),
MENU_ITEM('t', carlu_run_loop_test, "run tx/rx test."),
+ MENU_ITEM('g', carlu_run_gpio_test, "flash the leds."),
};
static int show_help(void)
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);
+}
const unsigned int interval, const unsigned int min_len,
const unsigned int max_len);
+int carlu_gpio_test(struct carlu *ar);
+
#endif /* __CARL9170USER_TEST_H */