Bitbang interface allows having a LED on one of the GPIO.
Let also linuxgpiod driver to specify and use the LED connection.
Change-Id: Id3d8772ee1808b92354fd073ba3947bacd8253ef
Signed-off-by: Antonio Borneo <borneo.antonio@gmail.com>
Reviewed-on: http://openocd.zylin.com/5770
Tested-by: jenkins
static int srst_gpio = -1;
static int swclk_gpio = -1;
static int swdio_gpio = -1;
static int srst_gpio = -1;
static int swclk_gpio = -1;
static int swdio_gpio = -1;
+static int led_gpio = -1;
static int gpiochip = -1;
static struct gpiod_chip *gpiod_chip;
static int gpiochip = -1;
static struct gpiod_chip *gpiod_chip;
static struct gpiod_line *gpiod_swclk;
static struct gpiod_line *gpiod_swdio;
static struct gpiod_line *gpiod_srst;
static struct gpiod_line *gpiod_swclk;
static struct gpiod_line *gpiod_swdio;
static struct gpiod_line *gpiod_srst;
+static struct gpiod_line *gpiod_led;
static int last_swclk;
static int last_swdio;
static int last_swclk;
static int last_swdio;
+static int linuxgpiod_blink(int on)
+{
+ int retval;
+
+ if (!gpiod_led)
+ return ERROR_OK;
+
+ retval = gpiod_line_set_value(gpiod_led, on);
+ if (retval < 0)
+ LOG_WARNING("Fail set led");
+ return retval;
+}
+
static struct bitbang_interface linuxgpiod_bitbang = {
.read = linuxgpiod_read,
.write = linuxgpiod_write,
.swdio_read = linuxgpiod_swdio_read,
.swdio_drive = linuxgpiod_swdio_drive,
.swd_write = linuxgpiod_swd_write,
static struct bitbang_interface linuxgpiod_bitbang = {
.read = linuxgpiod_read,
.write = linuxgpiod_write,
.swdio_read = linuxgpiod_swdio_read,
.swdio_drive = linuxgpiod_swdio_drive,
.swd_write = linuxgpiod_swd_write,
+ .blink = linuxgpiod_blink,
static int linuxgpiod_quit(void)
{
static int linuxgpiod_quit(void)
{
+ helper_release(gpiod_led);
helper_release(gpiod_srst);
helper_release(gpiod_swdio);
helper_release(gpiod_swclk);
helper_release(gpiod_srst);
helper_release(gpiod_swdio);
helper_release(gpiod_swclk);
+ if (is_gpio_valid(led_gpio)) {
+ gpiod_led = helper_get_output_line("led", led_gpio, 0);
+ if (gpiod_led == NULL)
+ goto out_error;
+ }
+
return ERROR_OK;
out_error:
return ERROR_OK;
out_error:
+COMMAND_HANDLER(linuxgpiod_handle_gpionum_led)
+{
+ if (CMD_ARGC == 1)
+ COMMAND_PARSE_NUMBER(int, CMD_ARGV[0], led_gpio);
+
+ command_print(CMD, "LinuxGPIOD num: led = %d", led_gpio);
+ return ERROR_OK;
+}
+
COMMAND_HANDLER(linuxgpiod_handle_gpiochip)
{
if (CMD_ARGC == 1)
COMMAND_HANDLER(linuxgpiod_handle_gpiochip)
{
if (CMD_ARGC == 1)
.help = "gpio number for swdio.",
.usage = "swdio",
},
.help = "gpio number for swdio.",
.usage = "swdio",
},
+ {
+ .name = "linuxgpiod_led_num",
+ .handler = linuxgpiod_handle_gpionum_led,
+ .mode = COMMAND_CONFIG,
+ .help = "gpio number for LED.",
+ .usage = "led",
+ },
{
.name = "linuxgpiod_gpiochip",
.handler = linuxgpiod_handle_gpiochip,
{
.name = "linuxgpiod_gpiochip",
.handler = linuxgpiod_handle_gpiochip,
# | TMS/SWDIO | J3.4 (PA3) | 3 |
# | TDI | J3.5 (PA4) | 4 |
# | nTRST | J3.6 (PA5) | 5 |
# | TMS/SWDIO | J3.4 (PA3) | 3 |
# | TDI | J3.5 (PA4) | 4 |
# | nTRST | J3.6 (PA5) | 5 |
+# | LED | J3.7 (PA6) | 6 |
# | GND | J3.12 (GND) | |
# +-----------+-------------+-------------+
# | GND | J3.12 (GND) | |
# +-----------+-------------+-------------+
linuxgpiod_trst_num 5
linuxgpiod_swd_nums 2 3
linuxgpiod_srst_num 0
linuxgpiod_trst_num 5
linuxgpiod_swd_nums 2 3
linuxgpiod_srst_num 0
reset_config trst_and_srst separate srst_push_pull
reset_config trst_and_srst separate srst_push_pull