Currently Non-working JTAG programmer

Dependencies:   mbed

Revision:
0:a23e8a7c9275
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/ports.c	Thu Jun 28 13:36:55 2012 +0000
@@ -0,0 +1,91 @@
+/*******************************************************/
+/* file: ports.c                                       */
+/* abstract:  This file contains the routines to       */
+/*            output values on the JTAG ports, to read */
+/*            the TDO bit, and to read a byte of data  */
+/*            from the prom                            */
+/* Revisions:                                          */
+/* 12/01/2008:  Same code as before (original v5.01).  */
+/*              Updated comments to clarify instructions.*/
+/*              Add print in setPort for xapp058_example.exe.*/
+/*******************************************************/
+#include "ports.h"
+/*#include "prgispx.h"*/
+#include "mbed.h"
+DigitalOut TMS_pin(p5);
+DigitalOut TDI_pin(p6);
+DigitalOut TCK_pin(p7);
+DigitalIn  TDO_pin(p8);
+
+extern FILE *fp;
+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 */
+
+/*BYTE *xsvf_data=0;*/
+
+
+/* setPort:  Implement to set the named JTAG signal (p) to the new value (v).*/
+/* if in debugging mode, then just set the variables */
+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;
+        TMS_pin = val;
+    }
+    if (p==TDI)
+    {
+        g_iTDI = val;
+        TDI_pin = val;
+    }
+    if (p==TCK)
+    {
+        g_iTCK = val;
+        TCK_pin = val;
+        printf( "TCK = %d;  TMS = %d;  TDI = %d\n", g_iTCK, g_iTMS, g_iTDI );
+    }
+}
+
+
+/* toggle tck LH.  No need to modify this code.  It is output via setPort. */
+void pulseClock()
+{
+    setPort(TCK,0);  /* set the TCK port to low  */
+    setPort(TCK,1);  /* set the TCK port to high */
+}
+
+
+/* readByte:  Implement to source the next byte from your XSVF file location */
+/* read in a byte of data from the prom */
+void readByte(unsigned char *data)
+{
+    /* pretend reading using a file */
+    *data   = (unsigned char)fgetc( fp );
+
+}
+
+/* readTDOBit:  Implement to return the current value of the JTAG TDO signal.*/
+/* read the TDO bit from port */
+unsigned char readTDOBit()
+{
+    /* You must return the current value of the JTAG TDO signal. */
+    return( (unsigned char) TDO_pin );
+}
+
+/* waitTime:  Implement as follows: */
+/* REQUIRED:  This function must consume/wait at least the specified number  */
+/*            of microsec, interpreting microsec as a number of microseconds.*/
+/* REQUIRED FOR SPARTAN/VIRTEX FPGAs and indirect flash programming:         */
+/*            This function must pulse TCK for at least microsec times,      */
+/*            interpreting microsec as an integer value.                     */
+/* RECOMMENDED IMPLEMENTATION:  Pulse TCK at least microsec times AND        */
+/*                              continue pulsing TCK until the microsec wait */
+/*                              requirement is also satisfied.               */
+void waitTime(long microsec)
+{
+    wait(microsec);
+}