ZHCAD89A August 2020 – October 2023 BQ79600-Q1
WriteReg 和 SpiWriteReg 函数的基本结构如下:
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 和 Packet_Type 是整数,而 Register_Address 和 Data 是十六进制值(带前缀“0x”)。Device_Address 在广播和栈写操作中会被忽略。
例如:
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);
此行会将 1 字节数据写入器件 nDev_ID 的寄存器 0x0306。发送的数据为 0x01。数据包的类型为单器件写。