- 充电芯片的熟悉,这个很重要,否则不知道如何操作让芯片能够正常工作。为了简便起见,所有的寄存器操作,全是单字节操作Single Read/Write:
充分利用STM32Cube HAL库里面I2C MEM Read/Write的两个函数,注意设备地址,需要移位还是不移位,寄存器的地址是一位还是两位,有些设备是两位的,有些是一位的,BQ的这颗芯片,就是1位的。
/**
* @brief Read an amount of data in blocking mode from a specific memory address
* @param hi2c Pointer to a I2C_HandleTypeDef structure that contains
* the configuration information for the specified I2C.
* @param DevAddress Target device address: The device 7 bits address value
* in datasheet must be shifted to the left before calling the interface
* @param MemAddress Internal memory address
* @param MemAddSize Size of internal memory address
* @param pData