Read and write the logic analyzer waveform as shown in the figure above
The code is as follows
void QMC5883_Write (u8 addr, u8 data)
{
tls_i2c_write_byte (QMC5883_SlaveAddress, 1) ;
tls_i2c_wait_ack () ;
tls_i2c_write_byte (addr, 0) ;
tls_i2c_wait_ack () ;
tls_i2c_write_byte (data, 0) ;
tls_i2c_wait_ack () ;
tls_i2c_stop () ;
}
u8 QMC5883_Read_Byte (u8 addr)
{
uint8_t data;
tls_i2c_write_byte (QMC5883_SlaveAddress, 1) ;
tls_i2c_wait_ack () ;
tls_i2c_write_byte (addr, 0) ;
tls_i2c_wait_ack () ;
tls_i2c_write_byte (QMC5883_SlaveAddress+1, 0) ;
tls_i2c_wait_ack () ;
data = tls_i2c_read_byte (0, 1) ;
return data;
}
Writes can normally produce stop bits, But the read cannot be generated, Use is w800 The latest library functions.