From 907325aa12108ebee1b3c04911146499da1cd0a3 Mon Sep 17 00:00:00 2001 From: Michael Ossmann Date: Thu, 14 Feb 2013 17:23:45 -0700 Subject: [PATCH] CPLD JTAG GPIO --- firmware/common/hackrf_core.h | 1 + firmware/common/xapp058/README | 4 +++- firmware/common/xapp058/ports.c | 35 ++++++++++++++++++++++++++++----- 3 files changed, 34 insertions(+), 6 deletions(-) diff --git a/firmware/common/hackrf_core.h b/firmware/common/hackrf_core.h index dd6b20a7..1a0ffad5 100644 --- a/firmware/common/hackrf_core.h +++ b/firmware/common/hackrf_core.h @@ -234,6 +234,7 @@ extern "C" #define BOOT2_STATE GPIO_STATE(GPIO5, PIN_BOOT2) #define BOOT3_STATE GPIO_STATE(GPIO1, PIN_BOOT3) #define MIXER_SDATA_STATE GPIO_STATE(PORT_MIXER_SDATA, PIN_MIXER_SDATA) +#define CPLD_TDO_STATE GPIO_STATE(PORT_CPLD_TDO, PIN_CPLD_TDO) /* TODO add other Pins */ diff --git a/firmware/common/xapp058/README b/firmware/common/xapp058/README index 9889495b..e723a966 100644 --- a/firmware/common/xapp058/README +++ b/firmware/common/xapp058/README @@ -1,4 +1,4 @@ -The code in this directory is taken from: +The code in this directory was originally is taken from: http://www.xilinx.com/support/documentation/application_notes/xapp058.zip (v.5.01) @@ -8,3 +8,5 @@ what you want, no warranty. (BSD I guess...)" Refer to XAPP058 for more information: http://www.xilinx.com/support/documentation/application_notes/xapp058.pdf + +This software has been modified for HackRF. diff --git a/firmware/common/xapp058/ports.c b/firmware/common/xapp058/ports.c index d4b35cc9..c054c74c 100644 --- a/firmware/common/xapp058/ports.c +++ b/firmware/common/xapp058/ports.c @@ -12,11 +12,13 @@ #include "ports.h" /*#include "prgispx.h"*/ -#include "stdio.h" +//#include "stdio.h" +#include "hackrf_core.h" + extern FILE *in; -static int g_iTCK = 0; /* For xapp058_example .exe */ -static int g_iTMS = 0; /* For xapp058_example .exe */ -static int g_iTDI = 0; /* For xapp058_example .exe */ +//static int g_iTCK = 0; /* For xapp058_example .exe */ +//static int g_iTMS = 0; /* For xapp058_example .exe */ +//static int g_iTDI = 0; /* For xapp058_example .exe */ #ifdef WIN95PP #include "conio.h" @@ -95,6 +97,7 @@ void setPort(short p,short val) /* Printing code for the xapp058_example.exe. You must set the specified JTAG signal (p) to the new value (v). See the above, old Win95 code as an implementation example. */ +/* if (p==TMS) g_iTMS = val; if (p==TDI) @@ -103,6 +106,25 @@ void setPort(short p,short val) g_iTCK = val; printf( "TCK = %d; TMS = %d; TDI = %d\n", g_iTCK, g_iTMS, g_iTDI ); } +*/ + if (p==TMS) + if (val) + gpio_set(PORT_CPLD_TMS, PIN_CPLD_TMS); + else + gpio_clear(PORT_CPLD_TMS, PIN_CPLD_TMS); + if (p==TDI) + if (val) + gpio_set(PORT_CPLD_TDI, PIN_CPLD_TDI); + else + gpio_clear(PORT_CPLD_TDI, PIN_CPLD_TDI); + if (p==TCK) + if (val) + gpio_set(PORT_CPLD_TCK, PIN_CPLD_TCK); + else + gpio_clear(PORT_CPLD_TCK, PIN_CPLD_TCK); + + /* conservative delay */ + delay(20000); } @@ -139,7 +161,10 @@ unsigned char readTDOBit() } #endif /* You must return the current value of the JTAG TDO signal. */ - return( (unsigned char) 0 ); + //return( (unsigned char) 0 ); + + delay(2000); + return CPLD_TDO_STATE; } /* waitTime: Implement as follows: */