2017-10-31 17:14:54 +01:00
|
|
|
#include <stdio.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
|
2019-11-08 18:52:55 +01:00
|
|
|
#if 0
|
2017-10-31 17:14:54 +01:00
|
|
|
#include <libopencm3/stm32/gpio.h>
|
2019-11-08 18:52:55 +01:00
|
|
|
#endif
|
2017-10-31 17:14:54 +01:00
|
|
|
|
|
|
|
#include <console.h>
|
|
|
|
#include <led.h>
|
|
|
|
|
|
|
|
extern struct led leds[];
|
|
|
|
extern size_t nleds;
|
|
|
|
|
|
|
|
int shell_led(struct console *con, size_t argc, const char **argv)
|
|
|
|
{
|
|
|
|
size_t led_id = 0;
|
|
|
|
int state = 0;
|
|
|
|
|
|
|
|
if (argc >= 2)
|
|
|
|
state = (strcmp(argv[1], "on") == 0);
|
|
|
|
|
|
|
|
if (argc >= 1)
|
|
|
|
led_id = strtoul(argv[0], NULL, 0);
|
|
|
|
|
2017-12-18 17:47:11 +01:00
|
|
|
if (led_id >= nleds) {
|
2017-10-31 17:14:54 +01:00
|
|
|
fprintf(con->fp, "error: unknown LED ID %d\n", led_id);
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
if (state) {
|
|
|
|
led_enable(leds + led_id);
|
|
|
|
} else {
|
|
|
|
led_disable(leds + led_id);
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|