Rev 2940 Rev 2942
Line 1... Line 1...
1 // Include FTDI library 1 // Include FTDI library
2 #include "mlab_xvcd_port_FTDI.h" 2 #include "mlab_xvcd_port_FTDI.h"
3   3  
-   4 #ifdef WIN32
-   5  
-   6 #include <windows.h> // Windows Console Application (Sleep)
-   7  
-   8 #else
-   9  
-   10 #include <unistd.h> // sleep
-   11  
-   12 #endif
4   13  
5 // JTAG Output Pin Mask 14 // JTAG Output Pin Mask
6 #define IO_OUTPUT_MASK (PORT_TCK|PORT_TDI|PORT_TMS|PORT_LED) // Mask for all Output Pins 15 #define IO_OUTPUT_MASK (PORT_TCK|PORT_TDI|PORT_TMS|PORT_LED) // Mask for all Output Pins
7   16  
8   17  
Line 283... Line 292...
283 else 292 else
284 { 293 {
285 fprintf(stderr, "FTDI: Set USB Latency Timer Failed %d\n", ftStatus); 294 fprintf(stderr, "FTDI: Set USB Latency Timer Failed %d\n", ftStatus);
286 } 295 }
287   296  
-   297 // Fix (without this delay the next FT_Read hang for ever)
-   298 // My Linux i5 notebook requires at least 2500us
-   299 #ifdef WIN32
-   300 Sleep(10); //ms
-   301 #else
-   302 usleep(10000); //us
-   303 #endif
-   304  
288 printf("\n"); 305 printf("\n");
289 return 0; 306 return 0;
290 } 307 }
291   308  
292   309  
293 // Enable or Disable Activity LED 310 // Enable or Disable Activity LED
294 void jtagSetLED(bool LedEnable) 311 void jtagSetLED(bool LedEnable)
295 { 312 {
296   -  
297 // DBUS Connected LED (BitBang Mode) 313 // DBUS Connected LED (BitBang Mode)
298 LedMask = LedEnable ? (PORT_LED & 0xFF) : 0; // Set mask for jtagScan function 314 LedMask = LedEnable ? (0xFF & PORT_LED) : 0; // Set mask for jtagScan function
299 if (PORT_LED & 0xFF) 315 if (PORT_LED & 0xFF)
300 { 316 {
301 // Set / Reset LED Pin 317 // Set / Reset LED Pin
302 DWORD BytesWritten; 318 DWORD BytesWritten;
303 DWORD BytesReceived; 319 DWORD BytesReceived;
304 unsigned char DataOut = LedMask | (PinStatus & ~PORT_LED); // Preserve PinStatus 320 unsigned char DataOut = LedMask | (PinStatus & ~PORT_LED); // Preserve PinStatus
305 unsigned char Dummy; 321 unsigned char Dummy;
306 FT_Write(ftHandle, &DataOut, 1, &BytesWritten ); // Send 1 byte 322 FT_Write(ftHandle, &DataOut, 1, &BytesWritten ); // Send 1 byte
307 FT_Read (ftHandle, &Dummy, 1, &BytesReceived); // Read 1 byte 323 FT_Read (ftHandle, &Dummy, 1, &BytesReceived); // Read 1 byte
308 //printf("[PinStatus %x DataOut %x]", PinStatus, DataOut); -  
309 } 324 }
310   325  
311 // CBUS Connected LED (BitBang Mode) 1 and 0 state of the port 326 // CBUS Connected LED (BitBang Mode) 1 and 0 state of the port
312 const unsigned char On = ( ((PORT_LED & 0x0F00) >> 4) | ((PORT_LED & 0x0F00) >> 8) ); 327 const unsigned char On = ( ((PORT_LED & 0x0F00) >> 4) | ((PORT_LED & 0x0F00) >> 8) );
313 const unsigned char Off = ( ((PORT_LED & 0x0F00) >> 4) ); 328 const unsigned char Off = ( ((PORT_LED & 0x0F00) >> 4) );