use COMMAND_REGISTER macro
[openocd.git] / src / jtag / presto.c
index 0972223387a9238926901ec44252e63bfe3caead..f22bd9eb862e487794aa26cb6a1b11973b24b2e2 100644 (file)
 #error "BUG: either FTD2XX and LIBFTDI has to be used"
 #endif
 
-static int presto_jtag_speed(int speed);
-static int presto_jtag_khz(int khz, int *jtag_speed);
-static int presto_jtag_speed_div(int speed, int *khz);
-static int presto_jtag_register_commands(struct command_context_s *cmd_ctx);
-static int presto_jtag_init(void);
-static int presto_jtag_quit(void);
-
-jtag_interface_t presto_interface =
-{
-       .name = "presto",
-       .execute_queue = bitq_execute_queue,
-       .speed = presto_jtag_speed,
-       .khz = presto_jtag_khz,
-       .speed_div = presto_jtag_speed_div,
-       .register_commands = presto_jtag_register_commands,
-       .init = presto_jtag_init,
-       .quit = presto_jtag_quit,
-};
-
-static int presto_bitq_out(int tms, int tdi, int tdo_req);
-static int presto_bitq_flush(void);
-static int presto_bitq_sleep(unsigned long us);
-static int presto_bitq_reset(int trst, int srst);
-static int presto_bitq_in_rdy(void);
-static int presto_bitq_in(void);
-
-static bitq_interface_t presto_bitq =
-{
-       .out = presto_bitq_out,
-       .flush = presto_bitq_flush,
-       .sleep = presto_bitq_sleep,
-       .reset = presto_bitq_reset,
-       .in_rdy = presto_bitq_in_rdy,
-       .in = presto_bitq_in,
-};
-
 /* -------------------------------------------------------------------------- */
 
 #define FT_DEVICE_NAME_LEN 64
@@ -86,8 +50,7 @@ static bitq_interface_t presto_bitq =
 
 #define BUFFER_SIZE (64*62)
 
-typedef struct presto_s
-{
+struct presto {
 #if BUILD_PRESTO_FTD2XX == 1
        FT_HANDLE handle;
        FT_STATUS status;
@@ -117,11 +80,10 @@ typedef struct presto_s
        int jtag_tdi_count;
 
        int jtag_speed;
+};
 
-} presto_t;
-
-static presto_t presto_state;
-static presto_t *presto = &presto_state;
+static struct presto presto_state;
+static struct presto *presto = &presto_state;
 
 static uint8_t presto_init_seq[] =
 {
@@ -701,6 +663,15 @@ static int presto_bitq_reset(int trst, int srst)
        return 0;
 }
 
+static struct bitq_interface presto_bitq = {
+               .out = &presto_bitq_out,
+               .flush = &presto_bitq_flush,
+               .sleep = &presto_bitq_sleep,
+               .reset = &presto_bitq_reset,
+               .in_rdy = &presto_bitq_in_rdy,
+               .in = &presto_bitq_in,
+       };
+
 /* -------------------------------------------------------------------------- */
 
 static int presto_jtag_khz(int khz, int *jtag_speed)
@@ -752,13 +723,13 @@ static int presto_jtag_speed(int speed)
 
 static char *presto_serial;
 
-static int presto_handle_serial_command(struct command_context_s *cmd_ctx, char *cmd, char **args, int argc)
+COMMAND_HANDLER(presto_handle_serial_command)
 {
-       if (argc == 1)
+       if (CMD_ARGC == 1)
        {
                if (presto_serial)
                        free(presto_serial);
-               presto_serial = strdup(args[0]);
+               presto_serial = strdup(CMD_ARGV[0]);
        }
        else
        {
@@ -768,9 +739,9 @@ static int presto_handle_serial_command(struct command_context_s *cmd_ctx, char
        return ERROR_OK;
 }
 
-static int presto_jtag_register_commands(struct command_context_s *cmd_ctx)
+static int presto_jtag_register_commands(struct command_context *cmd_ctx)
 {
-       register_command(cmd_ctx, NULL, "presto_serial", presto_handle_serial_command,
+       COMMAND_REGISTER(cmd_ctx, NULL, "presto_serial", presto_handle_serial_command,
                COMMAND_CONFIG, NULL);
        return ERROR_OK;
 }
@@ -809,3 +780,14 @@ static int presto_jtag_quit(void)
 
        return ERROR_OK;
 }
+
+struct jtag_interface presto_interface = {
+               .name = "presto",
+               .execute_queue = &bitq_execute_queue,
+               .speed = &presto_jtag_speed,
+               .khz = &presto_jtag_khz,
+               .speed_div = &presto_jtag_speed_div,
+               .register_commands = &presto_jtag_register_commands,
+               .init = &presto_jtag_init,
+               .quit = &presto_jtag_quit,
+       };

Linking to existing account procedure

If you already have an account and want to add another login method you MUST first sign in with your existing account and then change URL to read https://review.openocd.org/login/?link to get to this page again but this time it'll work for linking. Thank you.

SSH host keys fingerprints

1024 SHA256:YKx8b7u5ZWdcbp7/4AeXNaqElP49m6QrwfXaqQGJAOk gerrit-code-review@openocd.zylin.com (DSA)
384 SHA256:jHIbSQa4REvwCFG4cq5LBlBLxmxSqelQPem/EXIrxjk gerrit-code-review@openocd.org (ECDSA)
521 SHA256:UAOPYkU9Fjtcao0Ul/Rrlnj/OsQvt+pgdYSZ4jOYdgs gerrit-code-review@openocd.org (ECDSA)
256 SHA256:A13M5QlnozFOvTllybRZH6vm7iSt0XLxbA48yfc2yfY gerrit-code-review@openocd.org (ECDSA)
256 SHA256:spYMBqEYoAOtK7yZBrcwE8ZpYt6b68Cfh9yEVetvbXg gerrit-code-review@openocd.org (ED25519)
+--[ED25519 256]--+
|=..              |
|+o..   .         |
|*.o   . .        |
|+B . . .         |
|Bo. = o S        |
|Oo.+ + =         |
|oB=.* = . o      |
| =+=.+   + E     |
|. .=o   . o      |
+----[SHA256]-----+
2048 SHA256:0Onrb7/PHjpo6iVZ7xQX2riKN83FJ3KGU0TvI0TaFG4 gerrit-code-review@openocd.zylin.com (RSA)