diff options
author | Spencer Oliver <spen@spen-soft.co.uk> | 2012-11-12 15:06:37 +0000 |
---|---|---|
committer | Spencer Oliver <spen@spen-soft.co.uk> | 2012-12-23 21:46:20 +0000 |
commit | adb8ec32dc7439aa3e34ab19f026e390ec129c10 (patch) | |
tree | 2537842bfc568e3e0d6ca0176052553f0bccb30d /src/helper/binarybuffer.c | |
parent | c7a6f065d2a48730e05eb95bb44ca6a7032d2a31 (diff) |
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/binarybuffer.c')
-rw-r--r-- | src/helper/binarybuffer.c | 27 |
1 files changed, 27 insertions, 0 deletions
diff --git a/src/helper/binarybuffer.c b/src/helper/binarybuffer.c index d98fa162..a90ec7b0 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; +} |