update PMIC_Tool code
This commit is contained in:
@@ -127,12 +127,20 @@
|
||||
</DelayLoadDLLs>
|
||||
</Link>
|
||||
<PostBuildEvent>
|
||||
<Command>copy /y "$(ProjectDir)external\FT4222\dll\*.dll" "$(OutDir)"
|
||||
<Command>:: 1. DLL 파일 먼저 복사
|
||||
copy /y "$(ProjectDir)external\FT4222\dll\*.dll" "$(OutDir)"
|
||||
|
||||
@echo off
|
||||
:: 2. PowerShell을 이용해 시스템 언어와 무관하게 날짜_시간 추출 (YYYYMMDD_HHmm)
|
||||
for /f "tokens=*" %%i in ('powershell -NoProfile -Command "Get-Date -Format 'yyyyMMdd_HHmm'"') do set BUILD_NAME=%%i
|
||||
|
||||
:: 3. 경로 설정 (반드시 큰따옴표로 감싸야 함)
|
||||
set "TARGET_PATH=$(SolutionDir)PMIC_Cmd_Tool_Build_History\%BUILD_NAME%"
|
||||
|
||||
|
||||
</Command>
|
||||
:: 4. 폴더 생성 및 복사
|
||||
echo Creating backup at: "%TARGET_PATH%"
|
||||
if not exist "%TARGET_PATH%" mkdir "%TARGET_PATH%"
|
||||
xcopy /y /e "$(OutDir)*.*" "%TARGET_PATH%\"</Command>
|
||||
</PostBuildEvent>
|
||||
</ItemDefinitionGroup>
|
||||
<ItemGroup>
|
||||
|
||||
@@ -27,6 +27,7 @@ uint8_t calcCRC8(uint8_t addrWithRw, uint8_t* data, int len);
|
||||
int parseCommand(const char* dir);
|
||||
void PMIC_I2C_Write(FT_HANDLE ftHandle, uint8_t slaveAddr, uint8_t regAddr, uint8_t value);
|
||||
void PMIC_I2C_Read(FT_HANDLE ftHandle, uint8_t slaveAddr, uint8_t regAddr);
|
||||
void toBinaryString(uint8_t val, char* outBuf);
|
||||
|
||||
int main()
|
||||
{
|
||||
@@ -114,14 +115,16 @@ int main()
|
||||
(void)getchar();
|
||||
|
||||
//Regulation Register
|
||||
printf("Regulation Register\n");
|
||||
// Page00
|
||||
//PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x00);
|
||||
//PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x00);
|
||||
|
||||
// IO_CHIPVERSION_REGU & IO_DIEID3_REGU
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x00); //0x000 - IO_PAGE_REGU
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x01); //0x001 - IO_CHIPNAME_REGU
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x02); //0x002 - IO_CHIPVERSION_REGU
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x03); //0x003 - IO_DIEID3_REGU
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x02); //0x002 - IO_CHIPVERSION_REGU
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x03); //0x003 - IO_DIEID3_REGU
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x04); //0x004
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x05); //0x005
|
||||
|
||||
@@ -129,8 +132,25 @@ int main()
|
||||
//PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x02);
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x23);
|
||||
|
||||
// 30ms 딜레이
|
||||
//Sleep(30);
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x30); //0x030 - FLT_MASK_OTP(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x31); //0x031 - FLT_MASK_TEMP(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x32); //0x032 - FLT_MASK_BUCK1(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x33); //0x033 - FLT_MASK_BUCK2(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x34); //0x034 - FLT_MASK_BUCK3(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x35); //0x035 - FLT_MASK_BUCK4(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x36); //0x036 - FLT_MASK_BUCK5(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x37); //0x037 - FLT_MASK_LDO(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x38); //0x038 - FLT_MASK_IF(OTP)
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x40); //0x040 - FLT_RECORD_OTP
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x41); //0x041 - FLT_RECORD_TEMP
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x42); //0x042 - FLT_RECORD_BUCK1
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x43); //0x043 - FLT_RECORD_BUCK2
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x44); //0x044 - FLT_RECORD_BUCK3
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x45); //0x045 - FLT_RECORD_BUCK4
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x46); //0x046 - FLT_RECORD_BUCK5
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x47); //0x047 - FLT_RECORD_LDO
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x48); //0x048 - FLT_RECORD_IF
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x49); //0x049 - FLT_RECORD_LDO_DISC_DET
|
||||
|
||||
// Page02
|
||||
//PMIC_I2C_Write(ftHandle, PMIC_ADDR_REGU, 0x00, 0x02);
|
||||
@@ -142,10 +162,13 @@ int main()
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x24);
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x25);
|
||||
|
||||
// 30ms 딜레이
|
||||
//Sleep(30);
|
||||
// IO_CHIPVERSION_REGU & IO_DIEID3_REGU
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x02); //0x002 - IO_CHIPVERSION_REGU
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_REGU, 0x03); //0x003 - IO_DIEID3_REGU
|
||||
|
||||
/* Protection Register */
|
||||
printf("Protection Register\n");
|
||||
// Read IO_CHIPNAME & IO_DIEID3
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x02); //0x002 - IO_CHIPNAME
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x03); //0x003 - IO_DIEID3
|
||||
|
||||
@@ -154,16 +177,20 @@ int main()
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x11); //0x011 - FUSA_STATUS_2
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x12); //0x012 - FUSA_STATUS_2A
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x13); //0x013 - FUSA_STATUS_3
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x14); //0x014 - FUSA_STATUS_4
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x14); //0x014 - FUSA_STATUS_4
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x19); //0x019 - FLT_RECORD_A
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1A); //0x01A - FLT_RECORD_B
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1B); //0x01B - FLT_RECORD_GND_AVIN
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1C); //0x01C - FLT_RECORD_BG_Temp
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1D); //0x01D - FLT_RECORD_IntLDOs
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1E); //0x01E - FLT_RECORD_ExtLDOs
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1F); //0x01F - FLT_RECORD_BUCKS_B
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x20); //0x01E - FLT_RECORD_BUCKS_A
|
||||
//PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x21); //0x01F - FLT_RECORD_ExtINPs_7_0
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1B); //0x01B - FLT_RECORD_GND_AVIN
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1C); //0x01C - FLT_RECORD_BG_Temp
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1D); //0x01D - FLT_RECORD_IntLDOs
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1E); //0x01E - FLT_RECORD_ExtLDOs
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x1F); //0x01F - FLT_RECORD_BUCKS_B
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x20); //0x01E - FLT_RECORD_BUCKS_A
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x21); //0x01F - FLT_RECORD_ExtINPs_7_0
|
||||
|
||||
// Read IO_CHIPNAME & IO_DIEID3
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x02); //0x002 - IO_CHIPNAME
|
||||
PMIC_I2C_Read(ftHandle, PMIC_ADDR_PROT, 0x03); //0x003 - IO_DIEID3
|
||||
|
||||
|
||||
// PMIC Debug Mode
|
||||
@@ -612,7 +639,23 @@ void PMIC_I2C_Read(FT_HANDLE ftHandle, uint8_t slaveAddr, uint8_t regAddr)
|
||||
return;
|
||||
}
|
||||
else {
|
||||
printf("Read 결과: [Address = 0x%02X], [Value = 0x%02X], [CRC = 0x%02X]\n",
|
||||
regAddr, rx[0], rx[1]);
|
||||
// [개선] 2진수 변환 로직 적용
|
||||
char binStr[10]; // "0000_0000" + null
|
||||
toBinaryString(rx[0], binStr);
|
||||
|
||||
//printf("Read 결과: [Addr: 0x%02X] [Hex: 0x%02X] [Bin: %s] [CRC: 0x%02X]\n", regAddr, rx[0], binStr, rx[1]);
|
||||
printf(" [Addr: 0x%02X] [Value Hex: 0x%02X -> Bin: %s] [CRC: 0x%02X]\n", regAddr, rx[0], binStr, rx[1]);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
// 8비트 데이터를 "0000_0000" 형식의 문자열로 변환
|
||||
void toBinaryString(uint8_t val, char* outBuf)
|
||||
{
|
||||
for (int i = 0; i < 8; i++) {
|
||||
// 상위 비트부터 검사하여 '1' 또는 '0' 채우기
|
||||
outBuf[i + (i >= 4 ? 1 : 0)] = (val & (1 << (7 - i))) ? '1' : '0';
|
||||
}
|
||||
outBuf[4] = '_'; // 가독성을 위한 언더바 삽입
|
||||
outBuf[9] = '\0'; // 문자열 끝 지정
|
||||
}
|
||||
Reference in New Issue
Block a user