OpenCores
URL https://opencores.org/ocsvn/openrisc/openrisc/trunk

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [or_debug_proxy/] [includes/] [FT2232c.h] - Blame information for rev 854

Go to most recent revision | Details | Compare with Previous | View Log

Line No. Rev Author Line
1 39 julius
/*++
2
 
3
FTC MPSSE Interface DLLs - Copyright © FTDI Ltd. 2009
4
 
5
 
6
The source code to the FTCI2C, FTCJTAG and FTCSPI DLLs is provided as-is and no warranty is made as to its function or reliability.
7
 
8
This source code may be freely modified and redistributed, provided that the FTDI Ltd. copyright notice remains intact.
9
 
10
Copyright (c) 2005  Future Technology Devices International Ltd.
11
 
12
Module Name:
13
 
14
    FT2232c.h
15
 
16
Abstract:
17
 
18
    FT2232C Dual Type Devices Base Class Declaration/Definition.
19
 
20
Environment:
21
 
22
    kernel & user mode
23
 
24
Revision History:
25
 
26
    07/02/05    kra           Created.
27
    25/08/05    kra           Windows 2000 Professional always sets the USB buffer size to 4K ie 4096
28
        19/11/08        Rene Baumann  Port FTCJTAG to Linux.
29
 
30
--*/
31
 
32
#ifndef FT2232c_H
33
#define FT2232c_H
34
 
35
//#include <windows.h>
36
 
37
#include "ftd2xx.h"
38
 
39
typedef DWORD FTC_HANDLE;
40
typedef ULONG FTC_STATUS;
41
 
42
#define FTC_SUCCESS 0  //FTC_OK
43
#define FTC_INVALID_HANDLE 1 //FTC_INVALID_HANDLE
44
#define FTC_DEVICE_NOT_FOUND 2 //FTC_DEVICE_NOT_FOUND
45
#define FTC_DEVICE_NOT_OPENED 3 //FTC_DEVICE_NOT_OPENED
46
#define FTC_IO_ERROR 4 //FTC_IO_ERROR
47
#define FTC_INSUFFICIENT_RESOURCES 5 //FTC_INSUFFICIENT_RESOURCES
48
 
49
#define FTC_FAILED_TO_COMPLETE_COMMAND 20
50
#define FTC_FAILED_TO_SYNCHRONIZE_DEVICE_MPSSE 21
51
#define FTC_INVALID_DEVICE_NAME_INDEX 22
52
#define FTC_NULL_DEVICE_NAME_BUFFER_POINTER 23
53
#define FTC_DEVICE_NAME_BUFFER_TOO_SMALL 24
54
#define FTC_INVALID_DEVICE_NAME 25
55
#define FTC_INVALID_LOCATION_ID 26
56
#define FTC_DEVICE_IN_USE 27
57
#define FTC_TOO_MANY_DEVICES 28
58
 
59
#define MAX_NUM_DEVICE_NAME_CHARS 64
60
#define MAX_NUM_SERIAL_NUMBER_CHARS 16
61
 
62
typedef struct Ft_Device_Data{
63
        DWORD dwProcessId;                                                            // process identifier of the calling process ie application
64
  char  szDeviceName[MAX_NUM_DEVICE_NAME_CHARS];    // pointer to the name of a FT2232C dual type device
65
  DWORD dwLocationID;                               // the location identifier of a FT2232C dual type device
66
  DWORD hDevice;                                    // handle to the opened and initialized FT2232C dual type device
67
}FTC_DEVICE_DATA, *PFTC_DEVICE_DATA;
68
 
69
typedef DWORD FT2232CDeviceIndexes[MAX_NUM_DEVICES];
70
 
71
#define DEVICE_STRING_BUFF_SIZE 64
72
 
73
#define DEVICE_CHANNEL_A " A"
74
 
75
typedef char SerialNumber[MAX_NUM_SERIAL_NUMBER_CHARS];
76
 
77
const BYTE DEVICE_LATENCY_TIMER_VALUE = 16; // 16 milliseconds
78
 
79
#define OUTPUT_BUFFER_SIZE 131071  // 128K bytes
80
 
81
typedef BYTE OutputByteBuffer[OUTPUT_BUFFER_SIZE];
82
typedef OutputByteBuffer *POutputByteBuffer;
83
 
84
#define INPUT_BUFFER_SIZE 131071  // 128K bytes
85
 
86
typedef BYTE InputByteBuffer[INPUT_BUFFER_SIZE];
87
typedef InputByteBuffer *PInputByteBuffer;
88
 
89
#define CONVERT_1MS_TO_100NS 10000
90
 
91
#define MAX_COMMAND_TIMEOUT_PERIOD 5000  // 5 seconds
92
 
93
// 25/08/05 - Windows 2000 Professional always sets the USB buffer size to 4K ie 4096
94
#define MAX_NUM_BYTES_USB_WRITE 4096 //32768 // 32KB
95
#define MAX_NUM_BYTES_USB_WRITE_READ 4096 //32768 // 32KB
96
#define MAX_NUM_BYTES_USB_READ 32768 // 32KB
97
 
98
#define DEBUG_LIST_DEVICE  0
99
 
100
const BYTE MPSSE_INTERFACE_MASK   = '\x00';
101
const BYTE RESET_MPSSE_INTERFACE = '\x00';
102
const BYTE ENABLE_MPSSE_INTERFACE = '\x02';
103
 
104
const __uint16_t  DEVICE_OPENED_FLAG = '\x0001';
105
 
106
const int BASE_CLOCK_FREQUENCY_12_MHZ = 12000000;
107
 
108
const BYTE AA_ECHO_CMD_1 = '\xAA';
109
const BYTE AB_ECHO_CMD_2 = '\xAB';
110
 
111
const BYTE TURN_ON_LOOPBACK_CMD = '\x84';
112
const BYTE TURN_OFF_LOOPBACK_CMD = '\x85';
113
 
114
const BYTE BAD_COMMAND_RESPONSE = '\xFA';
115
 
116
 
117
 
118
class FT2232c
119
{
120
private:
121
  // Moved to FT2232c.cpp to avoid segmentation fault. --> UINT uiNumOpenedDevices;                                                      // Rene 
122
  // Moved to FT2232c.cpp to avoid segmentation fault. --> FTC_DEVICE_DATA OpenedDevices[MAX_NUM_DEVICES];       // Rene 
123
  // Moved to FT2232c.cpp to avoid segmentation fault. --> OutputByteBuffer OutputBuffer;                                        // Rene
124
  // Moved to FT2232c.cpp to avoid segmentation fault. --> DWORD dwNumBytesToSend;                                                       // Rene
125
 
126
 
127
  BOOLEAN    FTC_DeviceInUse(LPSTR lpDeviceName, DWORD dwLocationID);
128
  BOOLEAN    FTC_DeviceOpened(LPSTR lpDeviceName, DWORD dwLocationID, FTC_HANDLE *pftHandle);
129
  FTC_STATUS FTC_IsDeviceNameLocationIDValid(LPSTR lpDeviceName, DWORD dwLocationID);
130
 
131
  FTC_STATUS FTC_IsDeviceFT2232CType(LPSTR lpDeviceName, LPBOOL lpbFT2232CTypeDevice);
132
 
133
 
134
 
135
 
136
public:
137
  FT2232c(void);
138
  ~FT2232c(void);
139
 
140
protected:
141
  FTC_STATUS FTC_GetNumDevices(LPDWORD lpdwNumDevices, FT2232CDeviceIndexes *FT2232CIndexes);
142
  FTC_STATUS FTC_GetNumNotOpenedDevices(LPDWORD lpdwNumNotOpenedDevices, FT2232CDeviceIndexes *FT2232CIndexes);
143
  FTC_STATUS FTC_GetDeviceNameLocationID(DWORD dwDeviceIndex, LPSTR lpDeviceName, DWORD dwBufferSize, LPDWORD lpdwLocationID);
144
  FTC_STATUS FTC_OpenSpecifiedDevice(LPSTR lpDeviceName, DWORD dwLocationID, FTC_HANDLE *pftHandle);
145
  FTC_STATUS FTC_OpenDevice(FTC_HANDLE *pftHandle);
146
  FTC_STATUS FTC_CloseDevice(FTC_HANDLE ftHandle);
147
  void       FTC_GetClockFrequencyValues(DWORD dwClockFrequencyValue, LPDWORD lpdwClockFrequencyHz);
148
  FTC_STATUS FTC_SetDeviceLoopbackState(FTC_HANDLE ftHandle, BOOL bLoopbackState);
149
 
150
  void       FTC_InsertDeviceHandle(LPSTR lpDeviceName, DWORD dwLocationID, FTC_HANDLE ftHandle);
151
  FTC_STATUS FTC_IsDeviceHandleValid(FTC_HANDLE ftHandle);
152
  void       FTC_RemoveDeviceHandle(FTC_HANDLE ftHandle);
153
 
154
  FTC_STATUS FTC_ResetUSBDevicePurgeUSBInputBuffer(FTC_HANDLE ftHandle);
155
  FTC_STATUS FTC_SetDeviceUSBBufferSizes(FTC_HANDLE ftHandle, DWORD InputBufferSize, DWORD OutputBufferSize);
156
  FTC_STATUS FTC_SetDeviceSpecialCharacters(FTC_HANDLE ftHandle, BOOLEAN bEventEnabled, UCHAR EventCharacter,
157
                                            BOOLEAN bErrorEnabled, UCHAR ErrorCharacter);
158
  FTC_STATUS FTC_SetReadWriteDeviceTimeouts(FTC_HANDLE ftHandle, DWORD dwReadTimeoutmSec, DWORD dwWriteTimeoutmSec);
159
  FTC_STATUS FTC_SetDeviceLatencyTimer(FTC_HANDLE ftHandle, BYTE LatencyTimermSec);
160
  FTC_STATUS FTC_ResetMPSSEInterface(FTC_HANDLE ftHandle);
161
  FTC_STATUS FTC_EnableMPSSEInterface(FTC_HANDLE ftHandle);
162
  FTC_STATUS FTC_SendReceiveCommandFromMPSSEInterface(FTC_HANDLE ftHandle, BOOLEAN bSendEchoCommandContinuouslyOnce, BYTE EchoCommand, LPBOOL lpbCommandEchod);
163
  FTC_STATUS FTC_SynchronizeMPSSEInterface(FTC_HANDLE ftHandle);
164
  BOOLEAN    FTC_Timeout(SYSTEMTIME StartSystemTime, DWORD dwTimeoutmSecs);
165
  FTC_STATUS FTC_GetNumberBytesFromDeviceInputBuffer(FTC_HANDLE ftHandle, LPDWORD lpdwNumBytesDeviceInputBuffer);
166
 
167
  void       FTC_ClearOutputBuffer(void);
168
  DWORD      FTC_GetNumBytesInOutputBuffer(void);
169
  void       FTC_AddByteToOutputBuffer(DWORD dwOutputByte, BOOL bClearOutputBuffer);
170
  FTC_STATUS FTC_SendBytesToDevice(FTC_HANDLE ftHandle);
171
  FTC_STATUS FTC_ReadBytesFromDevice(FTC_HANDLE ftHandle, PInputByteBuffer InputBuffer,
172
                                     DWORD dwNumBytesToRead, LPDWORD lpdwNumBytesRead);
173
  FTC_STATUS FTC_ReadFixedNumBytesFromDevice(FTC_HANDLE ftHandle, PInputByteBuffer InputBuffer,
174
                                             DWORD dwNumBytesToRead, LPDWORD lpdwNumDataBytesRead);
175
  FTC_STATUS FTC_SendReadBytesToFromDevice(FTC_HANDLE ftHandle, PInputByteBuffer InputBuffer,
176
                                           DWORD dwNumBytesToRead, LPDWORD lpdwNumBytesRead);
177
 
178
  FTC_STATUS FTC_SendCommandsSequenceToDevice(FTC_HANDLE ftHandle);
179
  FTC_STATUS FTC_ReadCommandsSequenceBytesFromDevice(FTC_HANDLE ftHandle, PInputByteBuffer InputBuffer,
180
                                                     DWORD dwNumBytesToRead, LPDWORD lpdwNumBytesRead);
181
};
182
 
183
 
184
 
185
#endif  /* FT2232c_H */
186
 

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.