From 447a615dc33f324d44c73b282174be44e876cf41 Mon Sep 17 00:00:00 2001 From: oharboe Date: Fri, 24 Apr 2009 16:24:55 +0000 Subject: Zach Welch add TAP_SCAN_BYTES macro (1 of 2) git-svn-id: svn://svn.berlios.de/openocd/trunk@1524 b42882b7-edfa-0310-969c-e2dbd0fdcd60 --- src/jtag/jlink.c | 2 +- src/jtag/jtag.h | 3 +++ 2 files changed, 4 insertions(+), 1 deletion(-) 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 */ -- cgit v1.2.3