CVS: jtag/hardware_access HIL.c, 1.9, 1.10 HIL.def, 1.4, 1.5 HIL.h, 1.6, 1.7 makefile, 1.7, 1.8

Chris Liechti <[email protected]> Sun, 03 Sep 2006 08:34:02 -0700
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/jtag/hardware_access
In directory sc8-pr-cvs7.sourceforge.net:/tmp/cvs-serv22820/jtag/hardware_access

Modified Files:
	HIL.c HIL.def HIL.h makefile 
Log Message:
HIL:
- add slowdown option to HIL.dll
- on windows, create import library instead of static link lib
- cleanups

MSP430mspgcc:
- dll (windows) accidently statically linked HIL.dll, dyncamic link now

Index: HIL.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/hardware_access/HIL.c,v
retrieving revision 1.9
retrieving revision 1.10
diff -u -w -d -r1.9 -r1.10
--- HIL.c	6 Aug 2006 03:28:06 -0000	1.9
+++ HIL.c	3 Sep 2006 15:33:59 -0000	1.10
@@ -33,7 +33,7 @@
 /* Usually /dev/ppi0 will do all the job. But...
    using HIL_DIRECTIO might work better...*/
 #endif
-#else
+#elif defined WIN32
 #warning Buiding for WIN32!!!
 #include <stdlib.h>
 #include <windows.h>
@@ -48,6 +48,8 @@
 #define DATAOFF 0
 #define STATOFF 1
 #define CTRLOFF 2
+#else
+#error unknown arch.
 #endif
 
 #include "HIL.h"
@@ -96,6 +98,7 @@
 #endif
 
 static unsigned int protocol = JTAG;
+static unsigned long slowdown_value = 0;
 
 // (Local) Function prototypes. -----------------------------------------------
 
@@ -155,6 +158,28 @@
     ClrTCK();
     SetTCK();
 }
+#include <stdio.h>
+// configurable timer called after changing one of the outputs, used to
+// manually slow down the communication
+static void slowdown(void)
+{
+    if (slowdown_value) {
+        #ifdef WIN32
+        LARGE_INTEGER target;
+        LARGE_INTEGER now;
+        QueryPerformanceCounter(&target);
+        //we're lazy, use a double so that we don't have to care about overflows
+        //~ printf("*** %e\n", (double) target.QuadPart);
+        target.QuadPart += (double)freq.QuadPart*slowdown_value/1000000;
+        //~ printf("*** %e\n",  (double)target.QuadPart);
+        do {
+            QueryPerformanceCounter(&now);
+        } while (now.QuadPart < target.QuadPart);
+        #else
+        usleep(slowdown_value);
+        #endif
+    }
+}
 
 /* ----------------------------------------------------------------------------
 Function:
@@ -715,12 +740,14 @@
     case POS_EDGE:
         portData &= ~TCK;
         ioctl(fd, PPWDATA, &portData);
+        slowdown();
         portData |=  TCK;
         ioctl(fd, PPWDATA, &portData);
         break;
     case NEG_EDGE:
         portData |=  TCK;
         ioctl(fd, PPWDATA, &portData);
+        slowdown();
         portData &= ~TCK;
         ioctl(fd, PPWDATA, &portData);
         break;
@@ -737,10 +764,12 @@
         break;
     case POS_EDGE:
         out_byte(port_base + DATAOFF, portData &= ~TCK);
+        slowdown();
         out_byte(port_base + DATAOFF, portData |=  TCK);
         break;
     case NEG_EDGE:
         out_byte(port_base + DATAOFF, portData |=  TCK);
+        slowdown();
         out_byte(port_base + DATAOFF, portData &= ~TCK);
         break;
     default:
@@ -748,6 +777,7 @@
         break;
     }
 #endif
+    slowdown();
 }
 
 /* ----------------------------------------------------------------------------
@@ -775,6 +805,7 @@
 #else
     out_byte(port_base + DATAOFF, portData);
 #endif
+    slowdown();
 }
 
 /* ----------------------------------------------------------------------------
@@ -802,6 +833,7 @@
 #else
     out_byte(port_base + DATAOFF, portData);
 #endif
+    slowdown();
 }
 
 /* ----------------------------------------------------------------------------
@@ -829,6 +861,7 @@
 #else
     out_byte(port_base + DATAOFF, portData);
 #endif
+    slowdown();
 }
 
 /* ----------------------------------------------------------------------------
@@ -857,12 +890,14 @@
 	case POS_EDGE:
 	    portData &= ~TCLK;
 	    ioctl(fd, PPWDATA, &portData);
+            slowdown();
 	    portData |=  TCLK;
 	    ioctl(fd, PPWDATA, &portData);
 	    break;
 	case NEG_EDGE:
 	    portData |=  TCLK;
 	    ioctl(fd, PPWDATA, &portData);
+            slowdown();
 	    portData &= ~TCLK;
 	    ioctl(fd, PPWDATA, &portData);
 	    break;
@@ -879,10 +914,12 @@
         break;
     case POS_EDGE:
         out_byte(port_base + DATAOFF, portData &= ~TCLK);
+        slowdown();
         out_byte(port_base + DATAOFF, portData |=  TCLK);
         break;
     case NEG_EDGE:
         out_byte(port_base + DATAOFF, portData |=  TCLK);
+        slowdown();
         out_byte(port_base + DATAOFF, portData &= ~TCLK);
         break;
     default:
@@ -890,6 +927,7 @@
         break;
     }
 #endif
+    slowdown();
 }
 
 /* ----------------------------------------------------------------------------
@@ -938,6 +976,7 @@
 #else
     out_byte(port_base + CTRLOFF, portCtrl);
 #endif
+    slowdown();
     /* Delay to allow for voltage supervisor/reset delay (if present). */
     if (state)
         HIL_DelayMSec(DEFAULT_RSTDELAY);
@@ -1022,10 +1061,10 @@
 */
 void WINAPI HIL_StartTimer(void)
 {
-#if defined(HIL_PPDEV)  ||  defined(HIL_DIRECTIO)
-    gettimeofday(&_tstart, &tz);
-#else
+#ifdef WIN32
     QueryPerformanceCounter(&_tstart);
+#else
+    gettimeofday(&_tstart, &tz);
 #endif
 }
 
@@ -1046,7 +1085,10 @@
 */
 ULONG WINAPI HIL_ReadTimer(void)
 {
-#if defined(HIL_PPDEV)  ||  defined(HIL_DIRECTIO)
+#ifdef WIN32
+    QueryPerformanceCounter(&_tend);
+    return (1000*(_tend.QuadPart - _tstart.QuadPart))/(freq.QuadPart);
+#else
     long long t1;
     long long t2;
 
@@ -1054,9 +1096,6 @@
     t1 = ((long long) _tstart.tv_sec)*1000 + _tstart.tv_usec/1000;
     t2 = ((long long) _tend.tv_sec)*1000 + _tend.tv_usec/1000;
     return t2 - t1;
-#else
-    QueryPerformanceCounter(&_tend);
-    return (1000*(_tend.QuadPart - _tstart.QuadPart))/(freq.QuadPart);
 #endif
 }
 
@@ -1193,15 +1232,88 @@
     return STATUS_OK;
 }
 
+/* ----------------------------------------------------------------------------
+Function:
+ STATUS_T WINAPI HIL_sbw_ExecuteFuseBlow();
+
+Description:
+ Blow the JTAG fuse on Spy-Bi-Wire devices.
+ NOT supported with the simple parallel port interface!
+
+Parameters:
+ None
+
+Returns:
+ STATUS_OK:    Success
+ STATUS_ERROR: failure
+
+Notes:
+*/
 WINAPI void HIL_sbw_ExecuteFuseBlow(void)
 {
 }
 
+/* ----------------------------------------------------------------------------
+Function:
+ STATUS_T WINAPI HIL_sbw_StepPSA(Length);
+
+Description:
+ Run the checksum algorith over Length bytes?
+ NOT supported with the simple parallel port interface!
+
+Parameters:
+ Length number of bytes? to check
+
+Returns:
+ STATUS_OK:    Success
+ STATUS_ERROR: failure
+
+Notes:
+*/
 WINAPI void HIL_sbw_StepPSA(LONG Length)
 {
 }
 
+/* ----------------------------------------------------------------------------
+Function:
+ LONG WINAPI HIL_ReadTDO();
+
+Description:
+ Read state of TDO line.
+
+Parameters:
+ None
+
+Returns:
+ true/false for high/low
+
+Notes:
+*/
 LONG WINAPI HIL_ReadTDO(void)
 {
     return ReadTDO() != 0;
 }
+
+/* ----------------------------------------------------------------------------
+Function:
+ LONG WINAPI HIL_SetSlowdown();
+
+Description:
+ Configure additional delay after each output change. USed to slow down the
+ JTAG communication.
+ Use 0 to disable and try at fast as possible.
+
+Parameters:
+ Additional delay per edge in microseconds.
+
+Returns:
+ void
+
+Notes:
+ Very small values may not work as expected when the system doesn't support
+ timers at such small resolutions.
+*/
+void WINAPI HIL_SetSlowdown(LONG microseconds)
+{
+    slowdown_value = microseconds;
+}

Index: HIL.def
===================================================================
RCS file: /cvsroot/mspgcc/jtag/hardware_access/HIL.def,v
retrieving revision 1.4
retrieving revision 1.5
diff -u -w -d -r1.4 -r1.5
--- HIL.def	6 Aug 2006 03:28:06 -0000	1.4
+++ HIL.def	3 Sep 2006 15:33:59 -0000	1.5
@@ -56,3 +56,5 @@
 HIL_sbw_StepPSA=HIL_sbw_StepPSA@4
 HIL_ReadTDO@0
 HIL_ReadTDO=HIL_ReadTDO@0
\ No newline at end of file
+HIL_SetSlowdown@4
+HIL_SetSlowdown=HIL_SetSlowdown@4
\ No newline at end of file

Index: HIL.h
===================================================================
RCS file: /cvsroot/mspgcc/jtag/hardware_access/HIL.h,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- HIL.h	6 Apr 2006 14:20:30 -0000	1.6
+++ HIL.h	3 Sep 2006 15:33:59 -0000	1.7
@@ -36,33 +36,35 @@
 // Functions. -----------------------------------------------------------------
 //Note: WINAPI is removed by a #define if compiled on non Windows (see Basic_Types.h)
 
-STATUS_T WINAPI HIL_Initialize(CHAR const * port);
-STATUS_T WINAPI HIL_Open(void);
-STATUS_T WINAPI HIL_Connect(void);
-STATUS_T WINAPI HIL_Release(void);
-STATUS_T WINAPI HIL_Close(LONG vccOff);
-LONG WINAPI HIL_JTAG_IR(LONG instruction);
-LONG WINAPI HIL_TEST_VPP(LONG mode);
-LONG WINAPI HIL_JTAG_DR(LONG data, LONG bits);
-STATUS_T WINAPI HIL_VCC(LONG voltage);
-void WINAPI HIL_TST(LONG state);
-void WINAPI HIL_TCK(LONG state);
-void WINAPI HIL_TMS(LONG state);
-void WINAPI HIL_TDI(LONG state);
-void WINAPI HIL_TDO(LONG state);
-void WINAPI HIL_TCLK(LONG state);
-void WINAPI HIL_RST(LONG state);
-STATUS_T WINAPI HIL_VPP(LONG voltage);
-void WINAPI HIL_DelayMSec(LONG mSeconds);
-void WINAPI HIL_StartTimer(void);
-ULONG WINAPI HIL_ReadTimer(void);
-void WINAPI HIL_StopTimer(void);
-LONG WINAPI HIL_ReadTDO(void);
+WINAPI STATUS_T HIL_Initialize(CHAR const * port);
+WINAPI STATUS_T HIL_Open(void);
+WINAPI STATUS_T HIL_Connect(void);
+WINAPI STATUS_T HIL_Release(void);
+WINAPI STATUS_T HIL_Close(LONG vccOff);
+WINAPI LONG HIL_JTAG_IR(LONG instruction);
+WINAPI LONG HIL_TEST_VPP(LONG mode);
+WINAPI LONG HIL_JTAG_DR(LONG data, LONG bits);
+WINAPI STATUS_T HIL_VCC(LONG voltage);
+WINAPI void HIL_TST(LONG state);
+WINAPI void HIL_TCK(LONG state);
+WINAPI void HIL_TMS(LONG state);
+WINAPI void HIL_TDI(LONG state);
+WINAPI void HIL_TDO(LONG state);
+WINAPI void HIL_TCLK(LONG state);
+WINAPI void HIL_RST(LONG state);
+WINAPI STATUS_T HIL_VPP(LONG voltage);
+WINAPI void HIL_DelayMSec(LONG mSeconds);
+WINAPI void HIL_StartTimer(void);
+WINAPI ULONG HIL_ReadTimer(void);
+WINAPI void HIL_StopTimer(void);
+WINAPI LONG HIL_ReadTDO(void);
+WINAPI void HIL_SetSlowdown(LONG microseconds);
 
-void WINAPI HIL_CheckJtagFuse(void);
-void WINAPI HIL_ResetJtagTap(void);
-STATUS_T WINAPI HIL_Trace(BOOL OnOff, char *str);
-STATUS_T WINAPI HIL_SetProtocol(int protocol_id);
+WINAPI void HIL_CheckJtagFuse(void);
+WINAPI void HIL_ResetJtagTap(void);
+WINAPI STATUS_T HIL_Trace(BOOL OnOff, char *str);
+WINAPI STATUS_T HIL_Trace(BOOL OnOff, char *str);
+WINAPI STATUS_T HIL_SetProtocol(int protocol_id);
 WINAPI void HIL_sbw_StepPSA(LONG Length);
 WINAPI void HIL_sbw_ExecuteFuseBlow(void);
 

Index: makefile
===================================================================
RCS file: /cvsroot/mspgcc/jtag/hardware_access/makefile,v
retrieving revision 1.7
retrieving revision 1.8
diff -u -w -d -r1.7 -r1.8
--- makefile	13 Oct 2005 01:04:39 -0000	1.7
+++ makefile	3 Sep 2006 15:33:59 -0000	1.8
@@ -5,9 +5,10 @@
 
 #simple Windows detection over the environment
 ifdef WINDIR
-    LNOPTS   = -mno-cygwin -mdll -static -s HIL.def
+    LNOPTS   = -mno-cygwin -mdll HIL.def
     CFLAGS  += -mno-cygwin -mdll
-    targets  = libHIL.a HIL.dll
+    targets  = HIL.dll implib
+#    targets  = libHIL.a HIL.dll
 else
     CFLAGS  += -fPIC
     LNOPTS   = -fPIC -shared 
@@ -21,7 +22,7 @@
 
 CFLAGS  += -I ..
 
-.PHONY: all FORCE clean depend rmdepend implib
+.PHONY: all FORCE clean implib
 
 all: ${targets}
 


-------------------------------------------------------------------------
Using Tomcat but need to do more? Need to support web services, security?
Get stuff done quickly with pre-integrated technology to make your job easier
Download IBM WebSphere Application Server v.1.0.1 based on Apache Geronimo
http://sel.as-us.falkag.net/sel?cmd=lnk&kid=120709&bid=263057&dat=121642