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.

BQ40Z50-R2: Drivers written in C

Part Number: BQ40Z50-R2
Other Parts Discussed in Thread: BQ40Z50

Are there any drivers written in C to interface with this device?

  • What kind of driver are you talking about?  Linux driver? 

  • My customer is looking for the layer above the hardware control to see the logic of reading and writing the various data to the IC.

    They need to support getting the battery percentage.

    Thanks.

  • I don't think we have any C code.  Basically, it is easy to communicate with bq40z50 via SMBus.

    I would suggest your customer take a look at Section 14 SBS commands in the bq40z50 TRM.  They will see some examples there.

    Also,  below is some python code, which shows how to read voltage and temperature measurements from bq40z50. 

    import time
    import smbus
    
    DEVICE_BUS  = 1
    DEVICE_ADDR = 0x0b
    
    bus = smbus.SMBus(DEVICE_BUS)
            
    voltage = bus.read_word_data(DEVICE_ADDR, 0x09)
        
    time.sleep(0.05)
    
    temperature_K = bus.read_word_data(DEVICE_ADDR, 0x08)
    temperature_C = temperature_K * 1.0 / 10.0 - 273.15
    
    output = "%dmV,%0.3fC" % (voltage, temperature_C)
                
    print output