diff options
author | Tomek CEDRO <cederom@tlen.pl> | 2011-06-23 02:54:38 +0200 |
---|---|---|
committer | Tomek CEDRO <cederom@tlen.pl> | 2011-06-23 02:54:38 +0200 |
commit | 71f9339384b39e1f603dd26f490e8aba5d7628e6 (patch) | |
tree | c58f7b01ab440a058244a0116dc72b3b8d66008b | |
parent | 3ba938a8310595ea351891a1a24586af8d411d28 (diff) | |
download | openocd+libswd-71f9339384b39e1f603dd26f490e8aba5d7628e6.tar.gz openocd+libswd-71f9339384b39e1f603dd26f490e8aba5d7628e6.tar.bz2 openocd+libswd-71f9339384b39e1f603dd26f490e8aba5d7628e6.tar.xz openocd+libswd-71f9339384b39e1f603dd26f490e8aba5d7628e6.zip |
FT2232: Added test implementation for transfer() function transfering bits in/out of the char array from/to the interface pins.
-rw-r--r-- | src/jtag/drivers/ft2232.c | 33 |
1 files changed, 33 insertions, 0 deletions
diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index d16d4d6a..7db7bdd2 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -694,6 +694,39 @@ 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. + * \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. + * \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; + uint32_t bytes_written, bytes_read; + + //No optimization for now, simply send one bit from one char element. + for (bit=0;bit<bits;bit++){ + buf[0]=0x3e; // Clock Data Bits In and Out LSb first. + buf[1]=1; // One bit per element. + buf[2]=mosidata[bit]; // Take data from supplied array. + retval=ft2232_write(buf, 3, &bytes_written); + if (retval<0){ + LOG_ERROR("ft2232_write() returns %d", retval); + return ERROR_FAIL; + } + retval=ft2232_read((uint8_t *)&misodata[bit], 1, &bytes_read); + if (retval<0){ + LOG_ERROR("ft2232_read() returns %d", retval); + return ERROR_FAIL; + } + } + return bit; +} + + static bool ft2232_device_is_highspeed(void) { #if BUILD_FT2232_FTD2XX == 1 |