SLUAA17A August   2020  – October 2023 BQ79600-Q1

 

  1.   1
  2.   BQ79600-Q1 Software Design Reference
  3.   Trademarks
  4. 1Command Frames
    1. 1.1 Structure
      1. 1.1.1 Initialization Byte
      2. 1.1.2 Device ID Address
      3. 1.1.3 Register Address
      4. 1.1.4 Data
      5. 1.1.5 CRC
    2. 1.2 Command Frame Template Tables
    3. 1.3 Read Register and Write Register Functions
      1. 1.3.1 ReadReg/SpiReadReg
      2. 1.3.2 WriteReg/SPIWriteReg
      3. 1.3.3 Packet Types Available in Sample Code
  5. 2Quick Start Guide
    1. 2.1 Wake Sequence
    2. 2.2 Auto-Addressing
      1. 2.2.1 Steps
      2. 2.2.2 Example Commands for a Stack of 3 Devices
    3. 2.3 Read Cell Voltages
      1. 2.3.1 Steps
      2. 2.3.2 Example Commands for a Stack of 3 Devices
      3. 2.3.3 Convert to Voltages
    4. 2.4 Reverse Addressing
      1. 2.4.1 Steps
      2. 2.4.2 Example Commands for a Stack of Three Devices
  6. 3Revision History

ReadReg/SpiReadReg

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.