X-Git-Url: https://git.gag.com/?a=blobdiff_plain;f=src%2Fjtag%2Fdrivers%2Fbuspirate.c;h=51ace615fe7522421a836c86058ce9524c1943ce;hb=c6460ea36d7eeaf4a0fe4fb1a4c65bb21547afbe;hp=642ad12f44cedcb77e449e233e7f58bdb8ea669c;hpb=08ee7bb982b16742f52cfdc6c649d82ffa2eb177;p=fw%2Fopenocd diff --git a/src/jtag/drivers/buspirate.c b/src/jtag/drivers/buspirate.c index 642ad12f4..51ace615f 100644 --- a/src/jtag/drivers/buspirate.c +++ b/src/jtag/drivers/buspirate.c @@ -473,51 +473,51 @@ COMMAND_HANDLER(buspirate_handle_port_command) } -static const struct command_registration buspirate_command_handlers[] = { +static const struct command_registration buspirate_subcommand_handlers[] = { { - .name = "buspirate_adc", + .name = "adc", .handler = &buspirate_handle_adc_command, .mode = COMMAND_EXEC, .help = "reads voltages on adc pins", .usage = "", }, { - .name = "buspirate_vreg", + .name = "vreg", .usage = "<1|0>", .handler = &buspirate_handle_vreg_command, .mode = COMMAND_CONFIG, .help = "changes the state of voltage regulators", }, { - .name = "buspirate_pullup", + .name = "pullup", .usage = "<1|0>", .handler = &buspirate_handle_pullup_command, .mode = COMMAND_CONFIG, .help = "changes the state of pullup", }, { - .name = "buspirate_led", + .name = "led", .usage = "<1|0>", .handler = &buspirate_handle_led_command, .mode = COMMAND_EXEC, .help = "changes the state of led", }, { - .name = "buspirate_speed", + .name = "speed", .usage = "", .handler = &buspirate_handle_speed_command, .mode = COMMAND_CONFIG, .help = "speed of the interface", }, { - .name = "buspirate_mode", + .name = "mode", .usage = "", .handler = &buspirate_handle_mode_command, .mode = COMMAND_CONFIG, .help = "pin mode of the interface", }, { - .name = "buspirate_port", + .name = "port", .usage = "/dev/ttyUSB0", .handler = &buspirate_handle_port_command, .mode = COMMAND_CONFIG, @@ -526,6 +526,17 @@ static const struct command_registration buspirate_command_handlers[] = { COMMAND_REGISTRATION_DONE }; +static const struct command_registration buspirate_command_handlers[] = { + { + .name = "buspirate", + .mode = COMMAND_ANY, + .help = "perform buspirate management", + .chain = buspirate_subcommand_handlers, + .usage = "", + }, + COMMAND_REGISTRATION_DONE +}; + static const struct swd_driver buspirate_swd = { .init = buspirate_swd_init, .switch_seq = buspirate_swd_switch_seq, @@ -800,7 +811,7 @@ static void buspirate_tap_append(int tms, int tdi) int bit_index = tap_chain_index % 8; uint8_t bit = 1 << bit_index; - if (0 == bit_index) { + if (bit_index == 0) { /* Let's say that the TAP shift operation wants to shift 9 bits, so we will be sending to the Bus Pirate a bit count of 9 but still full 16 bits (2 bytes) of shift data. @@ -1178,13 +1189,13 @@ static int buspirate_serial_setspeed(int fd, char speed, cc_t timeout) /* set the serial port parameters */ fcntl(fd, F_SETFL, 0); - if (0 != tcgetattr(fd, &t_opt)) + if (tcgetattr(fd, &t_opt) != 0) return -1; - if (0 != cfsetispeed(&t_opt, baud)) + if (cfsetispeed(&t_opt, baud) != 0) return -1; - if (0 != cfsetospeed(&t_opt, baud)) + if (cfsetospeed(&t_opt, baud) != 0) return -1; t_opt.c_cflag |= (CLOCAL | CREAD); @@ -1206,7 +1217,7 @@ static int buspirate_serial_setspeed(int fd, char speed, cc_t timeout) /* Note that, in the past, TCSANOW was used below instead of TCSADRAIN, and CMD_UART_SPEED did not work properly then, at least with the Bus Pirate v3.5 (USB). */ - if (0 != tcsetattr(fd, TCSADRAIN, &t_opt)) { + if (tcsetattr(fd, TCSADRAIN, &t_opt) != 0) { /* According to the Linux documentation, this is actually not enough to detect errors, you need to call tcgetattr() and check that all changes have been performed successfully. */