Rev 2940 Rev 3090
1 #ifndef MLAB_XVCD_PORT_FTDI_H 1 #ifndef MLAB_XVCD_PORT_FTDI_H
2 #define MLAB_XVCD_PORT_FTDI_H 2 #define MLAB_XVCD_PORT_FTDI_H
3   3  
4   4  
5 // Pin Defs 5 // Pin Defs
6 // -------- 6 // --------
7   7  
8 // FTDI Pin Mask Definitions (valid for FT232R) 8 // FTDI Pin Mask Definitions (valid for FT232R)
9 #define DBUS0 0x0001 // Bit 0 Data Bus 9 #define DBUS0 0x0001 // Bit 0 Data Bus
10 #define DBUS1 0x0002 // Bit 1 10 #define DBUS1 0x0002 // Bit 1
11 #define DBUS2 0x0004 // Bit 2 11 #define DBUS2 0x0004 // Bit 2
12 #define DBUS3 0x0008 // Bit 3 12 #define DBUS3 0x0008 // Bit 3
13 #define DBUS4 0x0010 // Bit 4 13 #define DBUS4 0x0010 // Bit 4
14 #define DBUS5 0x0020 // Bit 5 14 #define DBUS5 0x0020 // Bit 5
15 #define DBUS6 0x0040 // Bit 6 15 #define DBUS6 0x0040 // Bit 6
16 #define DBUS7 0x0080 // Bit 7 16 #define DBUS7 0x0080 // Bit 7
17   17  
18 #define CBUS0 0x0100 // Bit 0 Control Bus 18 #define CBUS0 0x0100 // Bit 0 Control Bus
19 #define CBUS1 0x0200 // Bit 1 19 #define CBUS1 0x0200 // Bit 1
20 #define CBUS2 0x0400 // Bit 2 20 #define CBUS2 0x0400 // Bit 2
21 #define CBUS3 0x0800 // Bit 3 21 #define CBUS3 0x0800 // Bit 3
22   22  
23 #define FTDI_TXD DBUS0 // Bit 0 RS232 Signal Alias 23 #define FTDI_TXD DBUS0 // Bit 0 RS232 Signal Alias
24 #define FTDI_RXD DBUS1 // Bit 1 24 #define FTDI_RXD DBUS1 // Bit 1
25 #define FTDI_RTS DBUS2 // Bit 2 25 #define FTDI_RTS DBUS2 // Bit 2
26 #define FTDI_CTS DBUS3 // Bit 3 26 #define FTDI_CTS DBUS3 // Bit 3
27 #define FTDI_DTR DBUS4 // Bit 4 27 #define FTDI_DTR DBUS4 // Bit 4
28 #define FTDI_DSR DBUS5 // Bit 5 28 #define FTDI_DSR DBUS5 // Bit 5
29 #define FTDI_DCD DBUS6 // Bit 6 29 #define FTDI_DCD DBUS6 // Bit 6
30 #define FTDI_RI DBUS7 // Bit 7 30 #define FTDI_RI DBUS7 // Bit 7
31   31  
32   32  
33 // Includes 33 // Includes
34 // -------- 34 // --------
35 #undef UNICODE 35 #undef UNICODE
36 #define WIN32_LEAN_AND_MEAN 36 #define WIN32_LEAN_AND_MEAN
37   37  
38 #include <stdlib.h> // Standard Library (exit, atoi, ...) 38 #include <stdlib.h> // Standard Library (exit, atoi, ...)
39 #include <stdio.h> // Standard IO (printf, ...) 39 #include <stdio.h> // Standard IO (printf, ...)
40 #include "mlab_xvcd.h" // Program Config (pin defs, settings, ...) 40 #include "mlab_xvcd.h" // Program Config (pin defs, settings, ...)
41   41  
42 #ifdef WIN32 42 #ifdef WIN32
43 #include <windows.h> // Windows Console Application 43 #include <windows.h> // Windows Console Application
44 #else 44 #else
45 #include <string.h> 45 #include <string.h>
46 #endif 46 #endif
47   47  
48 // Link with library 48 // Link with library
49 #ifdef WIN32 49 #ifdef WIN32
50 #include "lib_win32\ftd2xx.h" // FTDI Library 50 #include "lib_win32\ftd2xx.h" // FTDI Library
51 #else 51 #else
52 #include "lib_linux_i386/ftd2xx.h" 52 #include "lib_linux/ftd2xx.h"
53 #endif 53 #endif
54   54  
55   55  
56 // Public Definitions 56 // Public Definitions
57 // ------------------ 57 // ------------------
58   58  
59   59  
60 // Find Mode (for port open) 60 // Find Mode (for port open)
61 #define OPEN_BY_DESCRIPTION FT_OPEN_BY_DESCRIPTION // Find device by Description String 61 #define OPEN_BY_DESCRIPTION FT_OPEN_BY_DESCRIPTION // Find device by Description String
62 #define OPEN_BY_LOCATION FT_OPEN_BY_LOCATION // Find device by Bus Location 62 #define OPEN_BY_LOCATION FT_OPEN_BY_LOCATION // Find device by Bus Location
63 #define OPEN_BY_SERIAL_NUMBER FT_OPEN_BY_SERIAL_NUMBER // Find device by it's Serial Number 63 #define OPEN_BY_SERIAL_NUMBER FT_OPEN_BY_SERIAL_NUMBER // Find device by it's Serial Number
64   64  
65 // Max Data lengt to send to FTDI as one block 65 // Max Data lengt to send to FTDI as one block
66 #define FTDI_MAX_WRITESIZE 1024 66 #define FTDI_MAX_WRITESIZE 1024
67   67  
68   68  
69 // Function Prototypes (public functions only) 69 // Function Prototypes (public functions only)
70 // ------------------------------------------- 70 // -------------------------------------------
71   71  
72 // Connect to FTDI driver 72 // Connect to FTDI driver
73 // Find the device and open driver 73 // Find the device and open driver
74 int jtagOpenPort(int findDeviceBy, char *findDeviceByStr); 74 int jtagOpenPort(int findDeviceBy, char *findDeviceByStr);
75   75  
76 // Enable or Disable Activity LED 76 // Enable or Disable Activity LED
77 void jtagSetLED(bool LedEnable); 77 void jtagSetLED(bool LedEnable);
78   78  
79 // Set port to Idle state (all zeroes) 79 // Set port to Idle state (all zeroes)
80 void jtagSetIdle(); 80 void jtagSetIdle();
81   81  
82 // Close FTDI connection 82 // Close FTDI connection
83 int jtagClosePort(); 83 int jtagClosePort();
84   84  
85 // Send data to JTAG port and bring returned data 85 // Send data to JTAG port and bring returned data
86 // Turn LED On during processing 86 // Turn LED On during processing
87 int jtagScan(const unsigned char *TMS, const unsigned char *TDI, unsigned char *TDO, unsigned int bits); 87 int jtagScan(const unsigned char *TMS, const unsigned char *TDI, unsigned char *TDO, unsigned int bits);
88   88  
89 // Check if Cable is still connected and accesible 89 // Check if Cable is still connected and accesible
90 // True is o.k. 90 // True is o.k.
91 bool CheckCable(); 91 bool CheckCable();
92   92  
93 #endif 93 #endif