From 53b972ef45906e0740d9f0535109cf8822627adf Mon Sep 17 00:00:00 2001 From: Tomek CEDRO Date: Thu, 28 Jul 2011 14:48:03 +0200 Subject: IF/TRANSFER: interface->transfer() function is now fixed and verified to work correctly. Updated prototype to support LSB/MSB-first shift direction. --- src/jtag/drivers/ft2232.c | 42 +++++++++++++++++++++++++++--------------- src/jtag/interface.h | 2 +- 2 files changed, 28 insertions(+), 16 deletions(-) diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index f37dd09a..df5c5e35 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -714,24 +714,26 @@ int ft2232_bitbang(void *device, char *signal_name, int GETnSET, int *value){ } -/** Transfer bits in/out stored in char array starting from LSB/[0], - * if you want to make MSB-first shift put data in reverse order into array. +/** Transfer bits in/out stored in char array starting from LSB first or MSB first, + * alternatively if you want to make MSB-first shift on LSB-first mode put data + * in reverse order into input/output array. * \param *device void pointer to pass driver details to the function. * \param bits is the number of bits (char array elements) to transfer. * \param *mosidata pointer to char array with data to be send. * \param *misodata pointer to char array with data to be received. + * \param nLSBfirst if zero shift data LSB-first, otherwise MSB-first. * \return number of bits sent on success, or ERROR_FAIL on failure. */ -int ft2232_transfer(void *device, int bits, char *mosidata, char *misodata){ - uint8_t buf[3]; - int retval, bit; +int ft2232_transfer(void *device, int bits, char *mosidata, char *misodata, int nLSBfirst){ + uint8_t buf[3]; + int retval, bit, i; uint32_t bytes_written, bytes_read; //No optimization for now, simply send one bit from one char element. for (bit=0;bit