ZHCAD89A August 2020 – October 2023 BQ79600-Q1
WriteReg 和 SpiWriteReg 函數(shù)的基本結(jié)構(gòu)如下:
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 是整數(shù),而 Register_Address 和 Data 是十六進(jìn)制值(帶前綴“0x”)。Device_Address 在廣播和棧寫操作中會(huì)被忽略。
例如:
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);此行會(huì)將 1 字節(jié)數(shù)據(jù)寫入器件 nDev_ID 的寄存器 0x0306。發(fā)送的數(shù)據(jù)為 0x01。數(shù)據(jù)包的類型為單器件寫。