aboutsummaryrefslogtreecommitdiff
path: root/src/helper
diff options
context:
space:
mode:
authorSpencer Oliver <spen@spen-soft.co.uk>2012-11-12 15:06:37 +0000
committerSpencer Oliver <spen@spen-soft.co.uk>2012-12-23 21:46:20 +0000
commitadb8ec32dc7439aa3e34ab19f026e390ec129c10 (patch)
tree2537842bfc568e3e0d6ca0176052553f0bccb30d /src/helper
parentc7a6f065d2a48730e05eb95bb44ca6a7032d2a31 (diff)
downloadriscv-openocd-adb8ec32dc7439aa3e34ab19f026e390ec129c10.zip
riscv-openocd-adb8ec32dc7439aa3e34ab19f026e390ec129c10.tar.gz
riscv-openocd-adb8ec32dc7439aa3e34ab19f026e390ec129c10.tar.bz2
icdi: add TI icdi interface
This is the new proprietary interface replacing the older FTDI based adapters. It is currently fitted to the ek-lm4f232 and Stellaris LaunchPad. Change-Id: I794ad79e31ff61ec8e9f49530aca9308025c0b60 Signed-off-by: Spencer Oliver <spen@spen-soft.co.uk> Reviewed-on: http://openocd.zylin.com/922 Tested-by: jenkins
Diffstat (limited to 'src/helper')
-rw-r--r--src/helper/binarybuffer.c27
-rw-r--r--src/helper/binarybuffer.h5
2 files changed, 32 insertions, 0 deletions
diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c
index d98fa16..a90ec7b 100644
--- a/src/helper/binarybuffer.c
+++ b/src/helper/binarybuffer.c
@@ -370,3 +370,30 @@ void bit_copy_discard(struct bit_copy_queue *q)
free(qe);
}
}
+
+int unhexify(char *bin, const char *hex, int count)
+{
+ int i, tmp;
+
+ for (i = 0; i < count; i++) {
+ if (sscanf(hex + (2 * i), "%02x", &tmp) != 1)
+ return i;
+ bin[i] = tmp;
+ }
+
+ return i;
+}
+
+int hexify(char *hex, const char *bin, int count, int out_maxlen)
+{
+ int i, cmd_len = 0;
+
+ /* May use a length, or a null-terminated string as input. */
+ if (count == 0)
+ count = strlen(bin);
+
+ for (i = 0; i < count; i++)
+ cmd_len += snprintf(hex + cmd_len, out_maxlen - cmd_len, "%02x", bin[i]);
+
+ return cmd_len;
+}
diff --git a/src/helper/binarybuffer.h b/src/helper/binarybuffer.h
index cc0be57..633ed9e 100644
--- a/src/helper/binarybuffer.h
+++ b/src/helper/binarybuffer.h
@@ -156,4 +156,9 @@ int bit_copy_queued(struct bit_copy_queue *q, uint8_t *dst, unsigned dst_offset,
void bit_copy_execute(struct bit_copy_queue *q);
void bit_copy_discard(struct bit_copy_queue *q);
+/* functions to convert to/from hex encoded buffer
+ * used in ti-icdi driver and gdb server */
+int unhexify(char *bin, const char *hex, int count);
+int hexify(char *hex, const char *bin, int count, int out_maxlen);
+
#endif /* BINARYBUFFER_H */