+ .name = "usb",
+ .handler = &jlink_handle_config_usb_address_command,
+ .mode = COMMAND_EXEC,
+ .help = "set the USB address",
+ .usage = "[0-3]",
+ },
+ {
+ .name = "targetpower",
+ .handler = &jlink_handle_config_target_power_command,
+ .mode = COMMAND_EXEC,
+ .help = "set the target power supply",
+ .usage = "[on|off]"
+ },
+ {
+ .name = "mac",
+ .handler = &jlink_handle_config_mac_address_command,
+ .mode = COMMAND_EXEC,
+ .help = "set the MAC Address",
+ .usage = "[ff:ff:ff:ff:ff:ff]",
+ },
+ {
+ .name = "ip",
+ .handler = &jlink_handle_config_ip_address_command,
+ .mode = COMMAND_EXEC,
+ .help = "set the IP address, where A.B.C.D is the IP address, "
+ "E the bit of the subnet mask, F.G.H.I the subnet mask",
+ .usage = "[A.B.C.D[/E] [F.G.H.I]]",
+ },
+ {
+ .name = "reset",
+ .handler = &jlink_handle_config_reset_command,
+ .mode = COMMAND_EXEC,
+ .help = "undo configuration changes"
+ },
+ {
+ .name = "write",
+ .handler = &jlink_handle_config_write_command,
+ .mode = COMMAND_EXEC,
+ .help = "write configuration to the device"
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+static const struct command_registration jlink_subcommand_handlers[] = {
+ {
+ .name = "jtag",
+ .handler = &jlink_handle_jlink_jtag_command,
+ .mode = COMMAND_EXEC,
+ .help = "select the JTAG command version",
+ .usage = "[2|3]",
+ },
+ {
+ .name = "targetpower",
+ .handler = &jlink_handle_target_power_command,
+ .mode = COMMAND_EXEC,
+ .help = "set the target power supply",
+ .usage = "<on|off>"
+ },
+ {
+ .name = "freemem",
+ .handler = &jlink_handle_free_memory_command,
+ .mode = COMMAND_EXEC,
+ .help = "show free device memory"
+ },
+ {
+ .name = "hwstatus",
+ .handler = &jlink_handle_hwstatus_command,
+ .mode = COMMAND_EXEC,
+ .help = "show the hardware status"
+ },
+ {
+ .name = "usb",
+ .handler = &jlink_usb_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set the USB address of the device that should be used",
+ .usage = "<0-3>"
+ },
+ {
+ .name = "serial",
+ .handler = &jlink_serial_command,
+ .mode = COMMAND_CONFIG,
+ .help = "set the serial number of the device that should be used",
+ .usage = "<serial number>"
+ },
+ {
+ .name = "config",
+ .handler = &jlink_handle_config_command,
+ .mode = COMMAND_EXEC,
+ .help = "access the device configuration. If no argument is given "
+ "this will show the device configuration",
+ .chain = jlink_config_subcommand_handlers,
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+static const struct command_registration jlink_command_handlers[] = {
+ {
+ .name = "jlink",
+ .mode = COMMAND_ANY,
+ .help = "perform jlink management",
+ .chain = jlink_subcommand_handlers,
+ },
+ COMMAND_REGISTRATION_DONE
+};
+
+static int jlink_swd_init(void)
+{
+ iface = JAYLINK_TIF_SWD;
+
+ return ERROR_OK;
+}
+
+static void jlink_swd_write_reg(uint8_t cmd, uint32_t value, uint32_t ap_delay_clk)
+{
+ assert(!(cmd & SWD_CMD_RnW));
+ jlink_swd_queue_cmd(cmd, NULL, value, ap_delay_clk);
+}
+
+static void jlink_swd_read_reg(uint8_t cmd, uint32_t *value, uint32_t ap_delay_clk)
+{
+ assert(cmd & SWD_CMD_RnW);
+ jlink_swd_queue_cmd(cmd, value, 0, ap_delay_clk);