This thread has been locked.

If you have a related question, please click the "Ask a related question" button in the top right corner. The newly created question will be automatically linked to this question.

BQ27541 : programming/writing DFI

Other Parts Discussed in Thread: BQ27541

Hello team,

I have got couple of queries related to BQ27541DFI writing:

1. If I2C port of BQ27541 is not directly accessible. And we have micro-controller on the board, is it possible to write DFI through controller over I2C?

or what alternate solution is possible?

2. Is it feasible/possible for gauge functions to run while writing to the device?

Regards,

Mahendra Patel, TI Pune 

  • Are you using any TI processor ?
    If yes, please give your processor details.

    We can access the fuel gauge through controller and processor.
  • It is an NXP controller (LPC series).
    I don't have exact part number. If required, I can get the details.
    Regards,
    Mahendra Patel
  • If it is a NFC controller and you are not using any TI prcessor then please you have to contact NFC forum support.
    In this forum, you would get linux support for TI processors.

    NFC might have a I2C library to communicate slave device and you may need to modify the code as per the fuel gauge IC spec (slave address , device info read & write etc.,)

    Thank you.
  • I think there is a confusion.

    I mentioned, it is an NXP controller (make is NXP) from LPC series. If it not NFC!

    Regards,

    Mahendra Patel

  • Hi Mahendra Patel,

    The answer is the same if you are using NXP controller.
    NXP controller could have I2C example code , you can modify it for your fuel gauge functionality.

    The below example code is used in linux (C application)

    Ex:
    Battery presence check.

    #define GAS_ADDR 0x55 //Mention the slave address of fuel gauge IC
    int gasfd;


    int i2c_gas_lltransfer(char dat,char *rbuf,int rlen)
    {

    struct i2c_rdwr_ioctl_data msgset;
    int rc;
    struct i2c_msg msgs[25];
    int addr = GAS_ADDR;
    char wbuf[4] = {0x00};

    wbuf[0] = dat;

    /* Write Message */
    msgset.msgs = msgs;
    msgset.msgs[0].addr = addr;
    msgset.msgs[0].flags = I2C_M_ZERO;
    msgset.msgs[0].buf = wbuf;
    msgset.msgs[0].len = 1;

    msgset.msgs[1].addr = addr;
    msgset.msgs[1].flags = I2C_M_RD;
    msgset.msgs[1].buf = rbuf;
    msgset.msgs[1].len = rlen;

    msgset.nmsgs = 2;

    rc = ioctl( gasfd , I2C_RDWR , &msgset );

    if(rc < 0)
    {
    printf("Error in Read\n");
    close(gasfd);
    }
    return rc;
    }

    int battery_presence_check()
    {
    char txbuf;
    char rdata[10]={0};
    int val;
    txbuf = 0x00;

    if ( write(gasfd,&txbuf,1) <0 ) {
    printf("Gasgauge write init error \n");
    return -1;
    }
    i2c_gas_lltransfer(0x0a,rdata,2); //0x0a is the command to check the battery availability.
    (rdata[0]&(1<<3))?(val = 1):(val = 0);

    if(val == 1)
    {
    printf("battery present \n");
    return 1;
    }
    else
    {
    printf("battery not present \n");
    return -1;
    }
    }