diff options
Diffstat (limited to 'src/modules/gpio_led')
-rw-r--r-- | src/modules/gpio_led/gpio_led.c | 41 |
1 files changed, 17 insertions, 24 deletions
diff --git a/src/modules/gpio_led/gpio_led.c b/src/modules/gpio_led/gpio_led.c index f5f3dea76..93a29a851 100644 --- a/src/modules/gpio_led/gpio_led.c +++ b/src/modules/gpio_led/gpio_led.c @@ -91,8 +91,7 @@ int gpio_led_main(int argc, char *argv[]) #endif #ifdef CONFIG_ARCH_BOARD_PX4FMU_V2 errx(1, "usage: gpio_led {start|stop} [-p <n>]\n" - "\t-p\tUse pin:\n" - "\t\tn\tAUX OUT pin number (default: 1)\n" + "\t-p <n>\tUse specified AUX OUT pin number (default: 1)" ); #endif @@ -108,6 +107,14 @@ int gpio_led_main(int argc, char *argv[]) /* by default use GPIO_EXT_1 on FMUv1 and GPIO_SERVO_1 on FMUv2 */ int pin = 1; + /* pin name to display */ +#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 + char *pin_name = "PX4FMU GPIO_EXT1"; +#endif +#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2 + char pin_name[] = "AUX OUT 1"; +#endif + if (argc > 2) { if (!strcmp(argv[2], "-p")) { #ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 @@ -115,26 +122,32 @@ int gpio_led_main(int argc, char *argv[]) if (!strcmp(argv[3], "1")) { use_io = false; pin = GPIO_EXT_1; + pin_name = "PX4FMU GPIO_EXT1"; } else if (!strcmp(argv[3], "2")) { use_io = false; pin = GPIO_EXT_2; + pin_name = "PX4FMU GPIO_EXT2"; } else if (!strcmp(argv[3], "a1")) { use_io = true; pin = PX4IO_P_SETUP_RELAYS_ACC1; + pin_name = "PX4IO ACC1"; } else if (!strcmp(argv[3], "a2")) { use_io = true; pin = PX4IO_P_SETUP_RELAYS_ACC2; + pin_name = "PX4IO ACC2"; } else if (!strcmp(argv[3], "r1")) { use_io = true; pin = PX4IO_P_SETUP_RELAYS_POWER1; + pin_name = "PX4IO RELAY1"; } else if (!strcmp(argv[3], "r2")) { use_io = true; pin = PX4IO_P_SETUP_RELAYS_POWER2; + pin_name = "PX4IO RELAY2"; } else { errx(1, "unsupported pin: %s", argv[3]); @@ -146,7 +159,8 @@ int gpio_led_main(int argc, char *argv[]) if (n >= 1 && n <= 6) { use_io = false; - pin = n; + pin = 1 << (n - 1); + snprintf(pin_name, sizeof(pin_name), "AUX OUT %d", n); } else { errx(1, "unsupported pin: %s", argv[3]); @@ -166,27 +180,6 @@ int gpio_led_main(int argc, char *argv[]) } else { gpio_led_started = true; - char pin_name[24]; - -#ifdef CONFIG_ARCH_BOARD_PX4FMU_V1 - - if (use_io) { - if (pin & (PX4IO_P_SETUP_RELAYS_ACC1 | PX4IO_P_SETUP_RELAYS_ACC2)) { - sprintf(pin_name, "PX4IO ACC%i", (pin >> 3)); - - } else { - sprintf(pin_name, "PX4IO RELAY%i", pin); - } - - } else { - sprintf(pin_name, "PX4FMU GPIO_EXT%i", pin); - } - -#endif -#ifdef CONFIG_ARCH_BOARD_PX4FMU_V2 - sprintf(pin_name, "AUX OUT %i", pin); -#endif - warnx("start, using pin: %s", pin_name); } |