Remove FSF address from GPL notices
[openocd.git] / src / jtag / drivers / versaloon / usbtoxxx / usbtoswd.c
index 196b507a9eb3274576af44791d9e9ec75da30f7f..ef1b675f79c007c8c6867d1a48f90349b190c447 100644 (file)
@@ -12,9 +12,7 @@
  *   GNU General Public License for more details.                          *
  *                                                                         *
  *   You should have received a copy of the GNU General Public License     *
- *   along with this program; if not, write to the                         *
- *   Free Software Foundation, Inc.,                                       *
- *   51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.           *
+ *   along with this program.  If not, see <http://www.gnu.org/licenses/>. *
  ***************************************************************************/
 
 #ifdef HAVE_CONFIG_H
 #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;
 
-       processed = processed;
+       if (pending->extra_data != NULL)
+               *((uint8_t *)pending->extra_data) = src[0];
+
+       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;
 }
 
@@ -71,7 +79,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;
 
@@ -132,14 +141,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)