// #include <Windows.h> 元はWindows用
#include <stdio.h>
#include <stdint.h>
#include "ftd2xx.h"
FT_STATUS ftStatus;
FT_HANDLE ftHandle;
DWORD w_data_len = 3; //write 3 bytes
DWORD data_written; // number of bytes written
UCHAR Mask = 0x0F; //00001111 Set D7-D4 input, D3-D0 output [input (0) and output (1)]
UCHAR Mode = 0x04; //0x04 = synchronous bit-bang
DWORD RxBytes; //number of bytes to be read from the device
DWORD BytesReceived; //number of bytes read from the device
uint8_t RxBuffer[8]; //buffer to receive data from FT-X device
uint8_t data_out[8]; //buffer for data to be sent to FT-X device
unsigned int i;
int main()
{
ftStatus = FT_Open(0, &ftHandle);
ftStatus |= FT_SetUSBParameters(ftHandle, 4096, 4096); // Set USB transfer sizes
ftStatus |= FT_SetChars(ftHandle, false, 0, false, 0); // Disable event characters
ftStatus |= FT_SetTimeouts(ftHandle, 5000, 5000); // Set read/write timeouts to 5 sec
ftStatus |= FT_SetLatencyTimer(ftHandle, 16); // Latency timer at default 16ms
ftStatus |= FT_SetFlowControl(ftHandle, FT_FLOW_NONE, 0x11, 0x13);
ftStatus |= FT_SetBaudRate(ftHandle, 62500); //bit rate is x16 this value = 1M
<以下略>