Other Parts Discussed in Thread: BQSTUDIO, , EV2400
I have uploaded golden image file to bq27z561 using code of slua801a application note without bqstudio and ev2400 .
i want to know if i write below code to upload configuration file to fuel gauge.
[Q - 1] Is my approach is right to verify golden image file written to my fuel gauge ic successfully ?
int main(void)
{
TI2C i2c;
void *pHandle = (void*) & i2c;
int nSourceFile;
struct stat st;
long n;
int nSeconds;
unsigned int nResult;
char *pFileBuffer;
unsigned char pData[DC_STATE_LENGTH];
printf("gauge test\n\r");
if((i2c.nI2C= open("/dev/i2c-2", O_RDWR))<0)
{
printf("cannotopenI2C bus\n\r");
exit(1);
}
printf("openend I2C bus\n\r");
gauge_address (pHandle, GAUGE_DEVICE_ADDRESS);
// nResult = gauge_control(pHandle, 0x0001);
// printf(" FW_VERSION= 0x%04X\n\r", nResult);
nResult = gauge_cmd_read (pHandle, 0x2c);
printf(" VOLTAGE = %04d [mV]\n\r", nResult);
nResult = gauge_control(pHandle, SUB_CMD_CONTROL_STATUS);
printf(" CONTROL_STATUS= 0x%04X\n\r", nResult);
stat(SOURCE_FILE,&st);
printf("source file '%s', size = %d\n\r", SOURCE_FILE, st.st_size);
if((nSourceFile= open(SOURCE_FILE,O_RDONLY))< 0)
{
printf("cannotopendataclassessourcefile\n\r");
exit(1);
}
pFileBuffer =(char *) malloc(st.st_size);
if(!pFileBuffer)
exit(1);
read(nSourceFile, pFileBuffer, st.st_size) ;
close(nSourceFile);
printf("%s",gauge_execute_fs(pHandle, pFileBuffer));
// above line print nothing so i think configuration file uploaded successfully
free(pFileBuffer);
close(i2c.nI2C);
printf("closedI2C bus\n\r");
}
-----------------------------
[ Q-2 ] is any other way is there to verify my golden image file uploaded successfully or not to bq27z561 ?
[ Q-3 ] Is it neccessary to chage parameter through code because i think flash stream file know design capacity, design energy, terminate voltage and taper current ?
[ Q-4 ] If any where i am wrong please let me know ?
Thanks,
Ti community.