diff options
author | Tomek CEDRO <cederom@tlen.pl> | 2011-11-03 03:26:18 +0100 |
---|---|---|
committer | Tomek CEDRO <cederom@tlen.pl> | 2011-11-03 03:26:18 +0100 |
commit | c06e0b49f4fde00e71f5c2be57bbcfbfe09079e0 (patch) | |
tree | 441da319df480fd9d4d098e54d56d22d735d3fba | |
parent | 02498e0ed4e142a966c2bda5bfb1e8153e7a85c8 (diff) | |
parent | ad9f081b6152a9c36bfb4bf74299f6ad959088c9 (diff) | |
download | openocd_libswd-c06e0b49f4fde00e71f5c2be57bbcfbfe09079e0.tar.gz openocd_libswd-c06e0b49f4fde00e71f5c2be57bbcfbfe09079e0.tar.bz2 openocd_libswd-c06e0b49f4fde00e71f5c2be57bbcfbfe09079e0.tar.xz openocd_libswd-c06e0b49f4fde00e71f5c2be57bbcfbfe09079e0.zip |
Merge branch 'master' of ssh://repo.or.cz/srv/git/openocd/libswd
-rw-r--r-- | src/jtag/drivers/ft2232.c | 5 | ||||
-rw-r--r-- | src/target/arm_adi_v5.h | 4 | ||||
-rw-r--r-- | src/transport/swd_libswd_drv_openocd.c | 13 | ||||
-rw-r--r-- | testing/pointertest.c | 24 |
4 files changed, 37 insertions, 9 deletions
diff --git a/src/jtag/drivers/ft2232.c b/src/jtag/drivers/ft2232.c index df5c5e35..4d417899 100644 --- a/src/jtag/drivers/ft2232.c +++ b/src/jtag/drivers/ft2232.c @@ -729,6 +729,9 @@ int ft2232_transfer(void *device, int bits, char *mosidata, char *misodata, int int retval, bit, i; uint32_t bytes_written, bytes_read; + LOG_DEBUG("ft2232_transfer(device=@%p, bits=%d, mosidata=@%p, misodata=@%p, nLSDfirst=%d) ",\ + (void*)device, bits, (void*)mosidata, (void*)misodata, nLSBfirst); + //No optimization for now, simply send one bit from one char element. for (bit=0;bit<bits;bit++){ buf[0]=(nLSBfirst)?0x33:0x3b; // Clock Bits In and Out LSb or MSb first. @@ -746,6 +749,8 @@ int ft2232_transfer(void *device, int bits, char *mosidata, char *misodata, int } // FTDI MPSSE returns shift register value, our bit is MSb misodata[bit]=(misodata[bit]&(nLSBfirst?0x01:0x80))?1:0; + //USE THIS FOR WIRE-LEVEL DEBUG + //LOG_DEBUG("read 0x%02X written 0x%02X", misodata[bit], mosidata[bit]); } /* Check if MPSSE ERROR occured and print info if so. */ diff --git a/src/target/arm_adi_v5.h b/src/target/arm_adi_v5.h index c190c433..19ea0acf 100644 --- a/src/target/arm_adi_v5.h +++ b/src/target/arm_adi_v5.h @@ -41,9 +41,9 @@ #define JTAG_DP_APACC 0xB /* three-bit ACK values for SWD access (sent LSB first) */ -#define SWD_ACK_OK 0x4 +#define SWD_ACK_OK 0x1 #define SWD_ACK_WAIT 0x2 -#define SWD_ACK_FAULT 0x1 +#define SWD_ACK_FAULT 0x4 #define DPAP_WRITE 0 #define DPAP_READ 1 diff --git a/src/transport/swd_libswd_drv_openocd.c b/src/transport/swd_libswd_drv_openocd.c index acc8830c..49a1f946 100644 --- a/src/transport/swd_libswd_drv_openocd.c +++ b/src/transport/swd_libswd_drv_openocd.c @@ -62,7 +62,7 @@ int swd_drv_mosi_8(swd_ctx_t *swdctx, swd_cmd_t *cmd, char *data, int bits, int static char misodata[8], mosidata[8]; /* Split output data into char array. */ - for (i=0;i<8;i++) mosidata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(7-i)]=((1<<i)&(*data))?1:0; + for (i=0;i<8;i++) mosidata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(bits-1-i)]=((1<<i)&(*data))?1:0; /* Then send that array into interface hardware. */ res=jtag_interface->transfer(NULL, bits, mosidata, misodata, 0); if (res<0) return SWD_ERROR_DRIVER; @@ -91,7 +91,7 @@ int swd_drv_mosi_32(swd_ctx_t *swdctx, swd_cmd_t *cmd, int *data, int bits, int static char misodata[32], mosidata[32]; //UrJTAG drivers shift data LSB-First. - for (i=0;i<32;i++) mosidata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(31-i)]=((1<<i)&(*data))?1:0; + for (i=0;i<32;i++) mosidata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(bits-1-i)]=((1<<i)&(*data))?1:0; res=jtag_interface->transfer(NULL, bits, mosidata, misodata, 0); if (res<0) return SWD_ERROR_DRIVER; return i; @@ -116,12 +116,11 @@ int swd_drv_miso_8(swd_ctx_t *swdctx, swd_cmd_t *cmd, char *data, int bits, int static signed int res; static char misodata[8], mosidata[8]; - // This function sends and reveice MSb-first. - res=jtag_interface->transfer(NULL, bits, mosidata, misodata, 0); + res=jtag_interface->transfer(NULL, bits, mosidata, misodata, SWD_DIR_LSBFIRST); if (res<0) return SWD_ERROR_DRIVER; /* Now we need to reconstruct the data byte from shifted in LSBfirst byte array. */ *data=0; - for (i=0;i<bits;i++) *data|=(misodata[(nLSBfirst==SWD_DIR_LSBFIRST)?(bits-1-i):(i)]?(1<<i):0); + for (i=0;i<bits;i++) *data|=misodata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(bits-1-i)]?(1<<i):0; LOG_DEBUG("OpenOCD's swd_drv_miso_8(swdctx=@%p, cmd=@%p, data=@%p, bits=%d, nLSBfirst=0x%02X) reads: 0x%02X", (void*)swdctx, (void*)cmd, (void*)data, bits, nLSBfirst, *data); return i; } @@ -145,11 +144,11 @@ int swd_drv_miso_32(swd_ctx_t *swdctx, swd_cmd_t *cmd, int *data, int bits, int static signed int res; static char misodata[32], mosidata[32]; - res=jtag_interface->transfer(NULL, bits, mosidata, misodata, 0); + res=jtag_interface->transfer(NULL, bits, mosidata, misodata, SWD_DIR_LSBFIRST); if (res<0) return SWD_ERROR_DRIVER; /* Now we need to reconstruct the data byte from shifted in LSBfirst byte array. */ *data=0; - for (i=0;i<bits;i++) *data|=(misodata[(nLSBfirst==SWD_DIR_LSBFIRST)?(bits-1-i):(i)]?(1<<i):0); + for (i=0;i<bits;i++) *data|=(misodata[(nLSBfirst==SWD_DIR_LSBFIRST)?(i):(bits-1-i)]?(1<<i):0); LOG_DEBUG("OpenOCD's swd_drv_miso_32(swdctx=@%p, cmd=@%p, data=@%p, bits=%d, nLSBfirst=0x%02X) reads: 0x%08X", (void*)swdctx, (void*)cmd, (void*)data, bits, nLSBfirst, *data); LOG_DEBUG("OpenOCD's swd_drv_miso_32() reads: 0x%08X\n", *data); return i; diff --git a/testing/pointertest.c b/testing/pointertest.c new file mode 100644 index 00000000..0b5432e8 --- /dev/null +++ b/testing/pointertest.c @@ -0,0 +1,24 @@ +#include <stdlib.h> +#include <stdio.h> + +int f2(int *pf21, int *pf22){ + int *stuff; + stuff=(int*)calloc(1,sizeof(int)); + if (!stuff) exit(-1); + *stuff=0xDEADBEEF; + printf("stuff[@%X]=%X\n", stuff, *stuff); + *pf21=stuff; + *pf22=*stuff; + return 0; +} + +int f1(int *pf11, int *pf12){ + return f2(pf11, pf12); +} + +int main(){ + int a1=0,a2=0; + f1(&a1,&a2); + printf("a1[@%X]=%X\na2[@%X]=%X\n", &a1, a1, &a2, a2); + return 0; +} |