swd: Convert API to asynchronous
[openocd.git] / src / jtag / drivers / cmsis_dap_usb.c
index 8c815230d475d199976f624677540139b44785fc..180a91b40b4293e234564420d8eae4c99c0eed45 100644 (file)
@@ -479,8 +479,13 @@ static int cmsis_dap_cmd_DAP_Delay(uint16_t delay_us)
 }
 #endif
 
-static int cmsis_dap_swd_read_reg(uint8_t cmd, uint32_t *value)
+static int queued_retval;
+
+static void cmsis_dap_swd_read_reg(struct adiv5_dap *dap, uint8_t cmd, uint32_t *value)
 {
+       if (queued_retval != ERROR_OK)
+               return;
+
        uint8_t *buffer = cmsis_dap_handle->packet_buffer;
        int retval;
        uint32_t val;
@@ -497,7 +502,8 @@ static int cmsis_dap_swd_read_reg(uint8_t cmd, uint32_t *value)
        /* TODO - need better response checking */
        if (retval != ERROR_OK || buffer[1] != 0x01) {
                LOG_ERROR("CMSIS-DAP: Read Error (0x%02" PRIx8 ")", buffer[2]);
-               return buffer[2];
+               queued_retval = buffer[2];
+               return;
        }
 
        val = le_to_h_u32(&buffer[3]);
@@ -506,11 +512,14 @@ static int cmsis_dap_swd_read_reg(uint8_t cmd, uint32_t *value)
        if (value)
                *value = val;
 
-       return retval;
+       queued_retval = retval;
 }
 
-static int cmsis_dap_swd_write_reg(uint8_t cmd, uint32_t value)
+static void cmsis_dap_swd_write_reg(struct adiv5_dap *dap, uint8_t cmd, uint32_t value)
 {
+       if (queued_retval != ERROR_OK)
+               return;
+
        uint8_t *buffer = cmsis_dap_handle->packet_buffer;
 
        DEBUG_IO("CMSIS-DAP: Write Reg 0x%02" PRIx8 " 0x%08" PRIx32, cmd, value);
@@ -531,6 +540,13 @@ static int cmsis_dap_swd_write_reg(uint8_t cmd, uint32_t value)
                retval = buffer[2];
        }
 
+       queued_retval = retval;
+}
+
+static int cmsis_dap_swd_run(struct adiv5_dap *dap)
+{
+       int retval = queued_retval;
+       queued_retval = ERROR_OK;
        return retval;
 }
 
@@ -994,9 +1010,10 @@ static const struct command_registration cmsis_dap_command_handlers[] = {
 };
 
 static const struct swd_driver cmsis_dap_swd_driver = {
-       .init       = cmsis_dap_swd_init,
-       .read_reg   = cmsis_dap_swd_read_reg,
-       .write_reg  = cmsis_dap_swd_write_reg,
+       .init = cmsis_dap_swd_init,
+       .read_reg = cmsis_dap_swd_read_reg,
+       .write_reg = cmsis_dap_swd_write_reg,
+       .run = cmsis_dap_swd_run,
 };
 
 const char *cmsis_dap_transport[] = {"cmsis-dap", NULL};

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)