SLUAA17A August 2020 – October 2023 BQ79600-Q1
The basic structure for the WriteReg and SpiWriteReg function is as follows:
UART sample code:
#_of_Sent_Bytes = WriteReg(Device_Address, Register_Address, Data, #_Data_Bytes, Packet_Type)
SPI sample code:
#_of_Sent_Bytes = SpiWriteReg(Device_Address, Register_Address, Data, #_Data_Bytes, Packet_Type)
Device_Address, #_Data_Bytes and Packet_Type are integers, while Register_Address and Data are hex values (with the prefix "0x"). Device_Address is ignored for broadcast and stack writes.
For example:
UART sample code:
nSent = WriteReg(nDev_ID, 0x0306, 0x01, 1, FRMWRT_SGL_NR);
SPI sample code:
nSent = SpiWriteReg(nDev_ID, 0x0306, 0x01, 1, FRMWRT_SGL_NR);
This line writes to register 0x0306 of the device nDev_ID with one byte of data. The data sent is 0x01. The type of packet is a single device write.