This commit is contained in:
2026-01-16 12:53:27 +09:00
parent d3bed70160
commit bdbf8cbbd3
5 changed files with 67 additions and 85 deletions

View File

@@ -2,10 +2,6 @@
"Version": 1, "Version": 1,
"WorkspaceRootPath": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\", "WorkspaceRootPath": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\",
"Documents": [ "Documents": [
{
"AbsoluteMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|C:\\WORK\\SRC\\0_TOOL\\PMIC_TOOL\\PMIC_CMD_TOOL\\EXTERNAL\\FT4222\\INCLUDE\\FTD2XX.H||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|solutionrelative:PMIC_CMD_TOOL\\EXTERNAL\\FT4222\\INCLUDE\\FTD2XX.H||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
},
{ {
"AbsoluteMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}", "AbsoluteMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}",
"RelativeMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|solutionrelative:PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}" "RelativeMoniker": "D:0:0:{C5541CC8-518C-4E1A-A6A8-CB37F56E9558}|PMIC_Cmd_Tool\\PMIC_Cmd_Tool.vcxproj|solutionrelative:PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp||{D0E1A5C6-B359-4E41-9B60-3365922C2A22}"
@@ -23,25 +19,12 @@
{ {
"$type": "Document", "$type": "Document",
"DocumentIndex": 0, "DocumentIndex": 0,
"Title": "ftd2xx.h",
"DocumentMoniker": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\external\\FT4222\\include\\ftd2xx.h",
"RelativeDocumentMoniker": "PMIC_Cmd_Tool\\external\\FT4222\\include\\ftd2xx.h",
"ToolTip": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\external\\FT4222\\include\\ftd2xx.h",
"RelativeToolTip": "PMIC_Cmd_Tool\\external\\FT4222\\include\\ftd2xx.h",
"ViewState": "AgIAACoAAAAAAAAAAAAAAHQBAAAdAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000680|",
"WhenOpened": "2026-01-16T02:48:28.794Z",
"EditorCaption": ""
},
{
"$type": "Document",
"DocumentIndex": 1,
"Title": "PMIC_Cmd_Tool.cpp", "Title": "PMIC_Cmd_Tool.cpp",
"DocumentMoniker": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp", "DocumentMoniker": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp",
"RelativeDocumentMoniker": "PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp", "RelativeDocumentMoniker": "PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp",
"ToolTip": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp", "ToolTip": "C:\\Work\\Src\\0_Tool\\PMIC_Tool\\PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp",
"RelativeToolTip": "PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp", "RelativeToolTip": "PMIC_Cmd_Tool\\src\\PMIC_Cmd_Tool.cpp",
"ViewState": "AgIAAAwAAAAAAAAAAAAhwCEAAAAGAAAAAAAAAA==", "ViewState": "AgIAAEUAAAAAAAAAAADwv1IAAAAkAAAAAAAAAA==",
"Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|", "Icon": "ae27a6b0-e345-4288-96df-5eaf394ee369.000677|",
"WhenOpened": "2026-01-16T02:11:14.724Z", "WhenOpened": "2026-01-16T02:11:14.724Z",
"EditorCaption": "" "EditorCaption": ""

View File

@@ -121,13 +121,17 @@
<Link> <Link>
<SubSystem>Console</SubSystem> <SubSystem>Console</SubSystem>
<GenerateDebugInformation>true</GenerateDebugInformation> <GenerateDebugInformation>true</GenerateDebugInformation>
<AdditionalLibraryDirectories>$(ProjectDir)external\FT4222\lib;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories> <AdditionalLibraryDirectories>$(ProjectDir)external\FT4222\lib\;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
<AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);LibFT4222-64.lib;ftd2xx.lib</AdditionalDependencies> <AdditionalDependencies>$(CoreLibraryDependencies);%(AdditionalDependencies);LibFT4222-64.lib;ftd2xx.lib</AdditionalDependencies>
<DelayLoadDLLs>LibFT4222-64.dll;%(DelayLoadDLLs)</DelayLoadDLLs> <DelayLoadDLLs>
</DelayLoadDLLs>
</Link> </Link>
<PostBuildEvent> <PostBuildEvent>
<Command>if not exist "$(OutDir)dll" mkdir "$(OutDir)dll" <Command>copy /y "$(ProjectDir)external\FT4222\dll\*.dll" "$(OutDir)"
xcopy /y "$(ProjectDir)external\FT4222\dll\*.dll" "$(OutDir)dll\"
</Command> </Command>
</PostBuildEvent> </PostBuildEvent>
</ItemDefinitionGroup> </ItemDefinitionGroup>

View File

@@ -35,75 +35,21 @@ int main()
unsigned int tempAddr = 0; unsigned int tempAddr = 0;
uint8_t I2C_SLAVE_ADDR = 0; uint8_t I2C_SLAVE_ADDR = 0;
unsigned long log_counter = 0; unsigned long log_counter = 0;
char timeStr[16]; // 시간을 저장할 버퍼 (HH:MM:SS면 9바이트면 충분)
char timeStr[16]; // 시간을 저장할 버퍼 (HH:MM:SS면 9바이트면 충분)
currentTime(timeStr, sizeof(timeStr)); currentTime(timeStr, sizeof(timeStr));
//printf("현재 시간: %s\n", timeStr); //printf("현재 시간: %s\n", timeStr);
// 1. DLL 탐색 경로에 하위 폴더 'dll' 추가 // 1. FT4222 장치 연결 및 초기화
// 이 설정은 이 함수 호출 이후에 로드되는 모든 DLL에 적용됩니다.
if (!SetDllDirectoryA("./dll")) {
printf("DLL 경로 설정 실패 (에러 코드: %lu)\n", GetLastError());
return -1;
}
// 2. FT4222 장치 연결 및 초기화
FT_HANDLE ftHandle = InitializeFT4222(); FT_HANDLE ftHandle = InitializeFT4222();
if (!ftHandle) { if (!ftHandle) return -1;
return -1; // 초기화 실패 시 프로그램 종료
}
printf("PMIC I2C Packet Logger with FT4222\n \n"); printf("PMIC I2C Packet Logger with FT4222\n \n");
#if 0 // 2. 초기화 상태 확인 with
printf("I2C Address\n Regulation Register is 0x54\n Protection Register is 0x55\n \nEnter 7-bit I2C Slave Address (hex): "); //printf("Read Regulation 0x54, Page 0x02, Address 0x23 : 0x66 이면 OTP26.66\n ");
if (scanf_s("%15s", addrInput, (unsigned)_countof(addrInput)) != 1) { //PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x02);
printf("입력 오류\n"); //PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x02);
return -1; //PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x23);
}
if (sscanf_s(addrInput, "%x", &tempAddr) != 1) {
printf("잘못된 주소 입력\n");
return -1;
}
I2C_SLAVE_ADDR = (uint8_t)tempAddr;
printf("슬레이브 주소 설정됨: 0x%02X\n", I2C_SLAVE_ADDR);
getchar(); // 버퍼 클리어
printf("사용법: I2C_WRITE <data...> 또는 w <data...>\n");
printf(" I2C_READ (항상 2바이트 읽음) 또는 r\n");
printf("exit 또틑 e 입력 시 종료\n");
#endif
printf("Read Regulation 0x54, Page 0x02, Address 0x23 : 0x66 이면 OK\n ");
#if 0
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
DWORD numDevs = 0;
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus != FT_OK || numDevs == 0) {
printf("FT4222 장치를 찾을 수 없습니다.\n");
return -1;
}
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;
}
#endif
/* Fault register data: Protection Register, Address 0x010 ~0x014, 0x019 ~0x021 /* Fault register data: Protection Register, Address 0x010 ~0x014, 0x019 ~0x021
0x010 - FUSA_STATUS_1 0x010 - FUSA_STATUS_1
@@ -141,7 +87,7 @@ int main()
/******************************************************************************************** /********************************************************************************************
I2C Write I2C Write
PMIC_I2C_Write(FT_HANDLE ftHandle, uint8_t slaveAddr, uint8_t regAddr, uint8_t value) PMIC_I2C_Write(FT_HANDLE ftHandle, uint8_t slaveAddr, uint8_t regAddr, uint8_t value)
PMIC_I2C_Write(ftHandle, PMIC_I2C_SLAVE_ADDR, 0xAA, 0xBB); PMIC_I2C_Write(ftHandle, PMIC_I2C_SLAVE_ADDR, PMIC_Register_Address, Value);
********************************************************************************************/ ********************************************************************************************/
//printf("=================================================================================\n"); //printf("=================================================================================\n");
/******************************************************************************************** /********************************************************************************************
@@ -290,6 +236,31 @@ int main()
//Protection Register //Protection Register
#endif #endif
#if 0
printf("I2C Address\n Regulation Register is 0x54\n Protection Register is 0x55\n \nEnter 7-bit I2C Slave Address (hex): ");
if (scanf_s("%15s", addrInput, (unsigned)_countof(addrInput)) != 1) {
printf("입력 오류\n");
return -1;
}
if (sscanf_s(addrInput, "%x", &tempAddr) != 1) {
printf("잘못된 주소 입력\n");
return -1;
}
I2C_SLAVE_ADDR = (uint8_t)tempAddr;
printf("슬레이브 주소 설정됨: 0x%02X\n", I2C_SLAVE_ADDR);
getchar(); // 버퍼 클리어
printf("사용법: I2C_WRITE <data...> 또는 w <data...>\n");
printf(" I2C_READ (항상 2바이트 읽음) 또는 r\n");
printf("exit 또틑 e 입력 시 종료\n");
#endif
char line[256]; char line[256];
while (1) { while (1) {
printf("> "); printf("> ");
@@ -430,6 +401,30 @@ FT_HANDLE InitializeFT4222() {
return NULL; return NULL;
} }
return handle; return handle;
#if 0
FT_HANDLE ftHandle = NULL;
FT_STATUS ftStatus;
DWORD numDevs = 0;
ftStatus = FT_CreateDeviceInfoList(&numDevs);
if (ftStatus != FT_OK || numDevs == 0) {
printf("FT4222 장치를 찾을 수 없습니다.\n");
return -1;
}
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;
}
#endif
} }
// 현재 시간을 "HH:MM:SS" 형식으로 buf에 저장 // 현재 시간을 "HH:MM:SS" 형식으로 buf에 저장