vsllink: Add SWD support
[openocd.git] / src / jtag / drivers / versaloon / usbtoxxx / usbtoswd.c
index b8d27af9b4320b6d7574e591d0ee82d01e7258c8..cd9d51c03eb733a7704e502ebfa743d8b9082cc8 100644 (file)
@@ -30,7 +30,7 @@
 #include "usbtoxxx.h"
 #include "usbtoxxx_internal.h"
 
-RESULT usbtoswd_callback(void *p, uint8_t *src, uint8_t *processed)
+RESULT usbtoswd_read_callback(void *p, uint8_t *src, uint8_t *processed)
 {
        struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
 
@@ -40,6 +40,18 @@ RESULT usbtoswd_callback(void *p, uint8_t *src, uint8_t *processed)
        return ERROR_OK;
 }
 
+RESULT usbtoswd_write_callback(void *p, uint8_t *src, uint8_t *processed)
+{
+       struct versaloon_pending_t *pending = (struct versaloon_pending_t *)p;
+
+       if (pending->extra_data != NULL)
+               *((uint8_t *)pending->extra_data) = src[0];
+
+       /* mark it processed to ignore other input data */
+       *processed = 1;
+       return ERROR_OK;
+}
+
 RESULT usbtoswd_init(uint8_t interface_index)
 {
        return usbtoxxx_init_command(USB_TO_SWD, interface_index);
@@ -69,7 +81,8 @@ RESULT usbtoswd_config(uint8_t interface_index, uint8_t trn, uint16_t retry,
        return usbtoxxx_conf_command(USB_TO_SWD, interface_index, cfg_buf, 5);
 }
 
-RESULT usbtoswd_seqout(uint8_t interface_index, uint8_t *data, uint16_t bitlen)
+RESULT usbtoswd_seqout(uint8_t interface_index, const uint8_t *data,
+       uint16_t bitlen)
 {
        uint16_t bytelen = (bitlen + 7) >> 3;
 
@@ -130,14 +143,16 @@ RESULT usbtoswd_transact(uint8_t interface_index, uint8_t request,
                memset(buff + 1, 0, 4);
 
        versaloon_set_extra_data(ack);
-       versaloon_set_callback(usbtoswd_callback);
        if (request & 0x04) {
                /* read */
-               return usbtoxxx_inout_command(USB_TO_SWD, interface_index, buff, 5, 5,
-                       (uint8_t *)data, 1, 4, 0);
+               versaloon_set_callback(usbtoswd_read_callback);
        } else {
                /* write */
-               return usbtoxxx_inout_command(USB_TO_SWD, interface_index, buff, 5, 5,
-                       NULL, 0, 0, 0);
+               versaloon_set_callback(usbtoswd_write_callback);
        }
+
+       /* Input buffer must be passed even for write operations. Otherwise
+        * the callback function is not called and ack value is not set. */
+       return usbtoxxx_inout_command(USB_TO_SWD, interface_index, buff, 5, 5,
+               (uint8_t *)data, 1, 4, 0);
 }

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)