if(JTAG_channels[chn].mode==JTAG_MODE_BOUNDARY)JTAG_channels[chn].mode=JTAG_MODE_SAMPLE;//should write the last byte before reading - or buffer data will be just lost
// write data data bytes from buffer, read data, optionally compare/abort
// return: 0- OK, !=0 - readback mismatch error
// modified so it reads data in-place of the written one
// send/receive bits, raising TMS during the last one (if last==1). If number of bits are not multiple of 8, lower bits of the last byte will not be used.
intjtag_write_bits(intchn,
unsignedchar*buf,// data to write
intlen,// number of bytes to write
intcheck,// compare readback data with previously written, abort on mismatch