SLUAA17A August 2020 – October 2023 BQ79600-Q1
The basic structure for the ReadReg and SpiReadReg functions is as follows:
UART sample code:
#_of_Read_Bytes = ReadReg(Device_Address, Register_Address, Incoming_Data_Byte_Array, #_Data_Bytes, ms_Before_Time_Out, Packet_Type)
SPI sample code:
#_of_Read_Bytes = SpiReadReg(Device_Address, Register_Address, Incoming_Data_Byte_Array, #_Data_Bytes, ms_Before_Time_Out, Packet_Type)
Device_Address, #_Data_Bytes, ms_Before_Time_Out, and Packet_Type are integers. Register_Address is a hex value (with the prefix "0x"). Incoming_Data_Byte_Array is an array of 1-byte hex values in the UART sample code and an array of 2-byte hex values in the SPI sample code.
Device_Address is ignored for broadcast and stack read commands.
For example:
UART sample code:
nRead = ReadReg(nDev_ID, 0x0306, bFrame, 12, 0, FRMWRT_SGL_R);
SPI sample code:
nRead = SpiReadReg(nDev_ID, 0x0306, bFrame, 12, 0, FRMWRT_SGL_R);
This line reads 12 bytes of data from register 0x0306 of the device nDev_ID and stores it in a local byte array (on the microcontroller) called bFrame. The packet type is a single device read.