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.

Linux/BQ27545-G1: Unable to enter into unsealed mode using HDQ

Part Number: BQ27545-G1
Other Parts Discussed in Thread: BQ27000, BQ27541-G1

Tool/software: Linux

Hi,

We are using HDQ to communicate with BQ27545-G1. For a requirement, I have to enter from sealed to unsealed mode through the driver code.

I tried the following code to do the same:

w1_bq27000_write(dev, 0x00, BQ27545_CONTROL_HI);

/* Read the status to check if the battery is sealed */
read = bq27x00_read(di, BQ27545_CONTROL_HI, false);
printk("%s: BQ27545_CONTROL_HI 0x%x\n", __func__, read);

/* Unseal access to battery */
if (read & BQ27545_CONTROL_STATUS_SS) {
      printk("1. Unseal the battery\n");
      w1_bq27000_write(dev, 0x04, BQ27545_CONTROL_LO);
      w1_bq27000_write(dev, 0x14, BQ27545_CONTROL_HI);
      w1_bq27000_write(dev, 0x36, BQ27545_CONTROL_LO);
      w1_bq27000_write(dev, 0x72, BQ27545_CONTROL_HI);
 }


 /* Write which register you want to access */
 w1_bq27000_write(dev, 0x00, BQ27545_CONTROL_HI);
 /* Read the status to check other flags */
 read = bq27x00_read(di, BQ27545_CONTROL_HI, false);

But this code still prints the status as sealed. I have tried different combinations of sending the code to battery guage. But it always shows the state as sealed.

Please help me to know the right way of unsealing the Battery Guage.

Thanks,

  • Hi Abdul, welcome to the forums!

    Assuming that the bq27541-G1 you're working on still uses the default unseal key, it looks like your high and low bytes are swapped - hence why the gauge is not accepting the key (you're essentially sending 0x72361404). The code should look more like the following (note the order that the bytes will be sent in):

    /* Unseal access to battery */
    if (read & BQ27545_CONTROL_STATUS_SS) {
          printk("1. Unseal the battery\n");
          w1_bq27000_write(dev, 0x14, BQ27545_CONTROL_LO);
          w1_bq27000_write(dev, 0x04, BQ27545_CONTROL_HI);
          w1_bq27000_write(dev, 0x72, BQ27545_CONTROL_LO);
          w1_bq27000_write(dev, 0x36, BQ27545_CONTROL_HI);
     }

    Also, it looks like you're only sending one byte out of the two required for a Control() subcommand. For the CONTROL_STATUS command, send 0x00 to both the low and high bytes of Control():

    w1_bq27000_write(dev, 0x00, BQ27545_CONTROL_LO);
    w1_bq27000_write(dev, 0x00, BQ27545_CONTROL_HI);

    Try making these changes to your code. It should be enough to allow your driver to unseal a gauge in-system (of course, if the key is changed, the hardcoded default key won't work anymore). I don't have any experience coding for Linux, but I have had success communicating with gauges over HDQ through a modified PC serial port.

    Hope this helps!

    Regards,
    Jason