This commit is contained in:
2026-06-18 13:32:10 +09:00
parent 82eccb559d
commit 27a5f79fcc
48 changed files with 136532 additions and 1918 deletions

View File

@@ -516,6 +516,8 @@ int main()
}
FT_HANDLE InitializeFT4222() {
#if 0
FT_HANDLE handle = NULL;
DWORD numDevs = 0;
@@ -538,29 +540,53 @@ FT_HANDLE InitializeFT4222() {
return NULL;
}
return handle;
#if 0
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
#else
FT_HANDLE handle = NULL;
DWORD numDevs = 0;
FT_STATUS ftStatus;
// 1. 장치 검색
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus != FT_OK || numDevs == 0) {
printf("FT4222 장치를 찾을 수 없습니다.\n");
return -1;
if (ftStatus != FT_OK || numDevs == 0) return NULL;
FT_DEVICE_LIST_INFO_NODE* devInfoList = (FT_DEVICE_LIST_INFO_NODE*)malloc(sizeof(FT_DEVICE_LIST_INFO_NODE) * numDevs);
if (!devInfoList) return NULL;
FT_GetDeviceInfoList(devInfoList, &numDevs);
int targetIndex = -1;
for (DWORD i = 0; i < numDevs; i++) {
if (strstr(devInfoList[i].Description, "FT4222") != NULL) {
if (!(devInfoList[i].Flags & FT_FLAGS_OPENED)) {
targetIndex = (int)i;
break;
}
}
}
free(devInfoList);
if (targetIndex == -1) return NULL;
// 2. 장치 오픈
if (FT_Open(targetIndex, &handle) != FT_OK) return NULL;
// 💡 [수정] 헤더 파일 119라인 enum 정의에 맞게 SYS_CLK_60 적용
FT4222_SetClock(handle, SYS_CLK_60);
// 💡 [수정] 구형 헤더에 없는 FT4222_SetMode/SetDataType 계열은 과감히 생략
// (I2CMaster_Init 호출 시 드라이버 내부에서 핀 맵 자동 전환됨)
// 3. 통신 타임아웃 및 버퍼 청소 (드라이버 레벨에서 1초 타임아웃 보장)
FT_SetTimeouts(handle, 1000, 1000);
FT_Purge(handle, FT_PURGE_RX | FT_PURGE_TX);
// 4. I2C 마스터 모드 초기화 (400kHz 주파수 설정)
if (FT4222_I2CMaster_Init(handle, 400) != FT4222_OK) {
printf("[ERROR] FT4222_I2CMaster_Init fail.\n");
FT_Close(handle);
return NULL;
}
ftStatus = FT_Open(0, &ftHandle);
if (ftStatus != FT_OK) {
printf("FT4222 장치 열기 실패\n");
return -1;
}
FT4222_STATUS ft4222Status = FT4222_I2CMaster_Init(ftHandle, 400); // 400kHz
if (ft4222Status != FT4222_OK) {
printf("I2C Master 초기화 실패\n");
FT_Close(ftHandle);
return -1;
}
return handle;
#endif
}