Dependencies:   mbed

Committer:
monpjc
Date:
Sat Jun 30 13:17:05 2012 +0000
Revision:
0:1be76329b246
removed returns for debug and corrected usages of fp in main()

Who changed what in which revision?

UserRevisionLine numberNew contents of line
monpjc 0:1be76329b246 1 /*******************************************************/
monpjc 0:1be76329b246 2 /* file: ports.c */
monpjc 0:1be76329b246 3 /* abstract: This file contains the routines to */
monpjc 0:1be76329b246 4 /* output values on the JTAG ports, to read */
monpjc 0:1be76329b246 5 /* the TDO bit, and to read a byte of data */
monpjc 0:1be76329b246 6 /* from the prom */
monpjc 0:1be76329b246 7 /* Revisions: */
monpjc 0:1be76329b246 8 /* 12/01/2008: Same code as before (original v5.01). */
monpjc 0:1be76329b246 9 /* Updated comments to clarify instructions.*/
monpjc 0:1be76329b246 10 /* Add print in setPort for xapp058_example.exe.*/
monpjc 0:1be76329b246 11 /*******************************************************/
monpjc 0:1be76329b246 12 #include "ports.h"
monpjc 0:1be76329b246 13 /*#include "prgispx.h"*/
monpjc 0:1be76329b246 14 #include "mbed.h"
monpjc 0:1be76329b246 15 DigitalOut TMS_pin(p5);
monpjc 0:1be76329b246 16 DigitalOut TDI_pin(p6);
monpjc 0:1be76329b246 17 DigitalOut TCK_pin(p7);
monpjc 0:1be76329b246 18 DigitalIn TDO_pin(p8);
monpjc 0:1be76329b246 19
monpjc 0:1be76329b246 20 extern FILE *fp;
monpjc 0:1be76329b246 21 static int g_iTCK = 0; /* For xapp058_example .exe */
monpjc 0:1be76329b246 22 static int g_iTMS = 0; /* For xapp058_example .exe */
monpjc 0:1be76329b246 23 static int g_iTDI = 0; /* For xapp058_example .exe */
monpjc 0:1be76329b246 24
monpjc 0:1be76329b246 25 /*BYTE *xsvf_data=0;*/
monpjc 0:1be76329b246 26
monpjc 0:1be76329b246 27
monpjc 0:1be76329b246 28 /* setPort: Implement to set the named JTAG signal (p) to the new value (v).*/
monpjc 0:1be76329b246 29 /* if in debugging mode, then just set the variables */
monpjc 0:1be76329b246 30 void setPort(short p,short val)
monpjc 0:1be76329b246 31 {
monpjc 0:1be76329b246 32 /* Printing code for the xapp058_example.exe. You must set the specified
monpjc 0:1be76329b246 33 JTAG signal (p) to the new value (v). See the above, old Win95 code
monpjc 0:1be76329b246 34 as an implementation example. */
monpjc 0:1be76329b246 35 if (p==TMS)
monpjc 0:1be76329b246 36 {
monpjc 0:1be76329b246 37 g_iTMS = val;
monpjc 0:1be76329b246 38 TMS_pin = val;
monpjc 0:1be76329b246 39 }
monpjc 0:1be76329b246 40 if (p==TDI)
monpjc 0:1be76329b246 41 {
monpjc 0:1be76329b246 42 g_iTDI = val;
monpjc 0:1be76329b246 43 TDI_pin = val;
monpjc 0:1be76329b246 44 }
monpjc 0:1be76329b246 45 if (p==TCK)
monpjc 0:1be76329b246 46 {
monpjc 0:1be76329b246 47 g_iTCK = val;
monpjc 0:1be76329b246 48 TCK_pin = val;
monpjc 0:1be76329b246 49 printf( "TCK = %d; TMS = %d; TDI = %d\n", g_iTCK, g_iTMS, g_iTDI );
monpjc 0:1be76329b246 50 }
monpjc 0:1be76329b246 51 }
monpjc 0:1be76329b246 52
monpjc 0:1be76329b246 53
monpjc 0:1be76329b246 54 /* toggle tck LH. No need to modify this code. It is output via setPort. */
monpjc 0:1be76329b246 55 void pulseClock()
monpjc 0:1be76329b246 56 {
monpjc 0:1be76329b246 57 setPort(TCK,0); /* set the TCK port to low */
monpjc 0:1be76329b246 58 setPort(TCK,1); /* set the TCK port to high */
monpjc 0:1be76329b246 59 }
monpjc 0:1be76329b246 60
monpjc 0:1be76329b246 61
monpjc 0:1be76329b246 62 /* readByte: Implement to source the next byte from your XSVF file location */
monpjc 0:1be76329b246 63 /* read in a byte of data from the prom */
monpjc 0:1be76329b246 64 void readByte(unsigned char *data)
monpjc 0:1be76329b246 65 {
monpjc 0:1be76329b246 66 /* pretend reading using a file */
monpjc 0:1be76329b246 67 *data = (unsigned char)fgetc( fp );
monpjc 0:1be76329b246 68
monpjc 0:1be76329b246 69 }
monpjc 0:1be76329b246 70
monpjc 0:1be76329b246 71 /* readTDOBit: Implement to return the current value of the JTAG TDO signal.*/
monpjc 0:1be76329b246 72 /* read the TDO bit from port */
monpjc 0:1be76329b246 73 unsigned char readTDOBit()
monpjc 0:1be76329b246 74 {
monpjc 0:1be76329b246 75 /* You must return the current value of the JTAG TDO signal. */
monpjc 0:1be76329b246 76 return( (unsigned char) TDO_pin );
monpjc 0:1be76329b246 77 }
monpjc 0:1be76329b246 78
monpjc 0:1be76329b246 79 /* waitTime: Implement as follows: */
monpjc 0:1be76329b246 80 /* REQUIRED: This function must consume/wait at least the specified number */
monpjc 0:1be76329b246 81 /* of microsec, interpreting microsec as a number of microseconds.*/
monpjc 0:1be76329b246 82 /* REQUIRED FOR SPARTAN/VIRTEX FPGAs and indirect flash programming: */
monpjc 0:1be76329b246 83 /* This function must pulse TCK for at least microsec times, */
monpjc 0:1be76329b246 84 /* interpreting microsec as an integer value. */
monpjc 0:1be76329b246 85 /* RECOMMENDED IMPLEMENTATION: Pulse TCK at least microsec times AND */
monpjc 0:1be76329b246 86 /* continue pulsing TCK until the microsec wait */
monpjc 0:1be76329b246 87 /* requirement is also satisfied. */
monpjc 0:1be76329b246 88 void waitTime(long microsec)
monpjc 0:1be76329b246 89 {
monpjc 0:1be76329b246 90 wait(microsec);
monpjc 0:1be76329b246 91 }