summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/jtag/jlink.c2
-rw-r--r--src/jtag/jtag.h3
2 files changed, 4 insertions, 1 deletions
diff --git a/src/jtag/jlink.c b/src/jtag/jlink.c
index 8626b18c..1269fa84 100644
--- a/src/jtag/jlink.c
+++ b/src/jtag/jlink.c
@@ -672,7 +672,7 @@ static int jlink_tap_execute(void)
return ERROR_OK;
// number of full bytes (plus one if some would be left over)
- byte_length = tap_length / 8 + !!(tap_length % 8);
+ byte_length = TAP_SCAN_BYTES(tap_length);
usb_out_buffer[0] = EMU_CMD_HW_JTAG3;
usb_out_buffer[1] = 0;
diff --git a/src/jtag/jtag.h b/src/jtag/jtag.h
index 2a7d8561..a14edb48 100644
--- a/src/jtag/jtag.h
+++ b/src/jtag/jtag.h
@@ -217,6 +217,9 @@ typedef void* error_handler_t; /* Later on we can delete error_handler_t, but k
struct scan_field_s;
typedef int (*in_handler_t)(u8* in_value, void* priv, struct scan_field_s* field);
+/// @brief calculates number of bytes required to hold @a n TAP scan bits
+#define TAP_SCAN_BYTES(n) (((n) / 8) + !!((n) % 8))
+
typedef struct scan_field_s
{
jtag_tap_t* tap; /* tap pointer this instruction refers to */