I'm fairly new to embedded systems, and am trying to write a driver for a breakout board I made for a tlv493d magnetic encoder. Specifically, on power on, I need to send a single reset byte to the encoder (0xFF). I got this working using i2c_master_write_byte(), but am interested in generalizing my code a bit, and I see there's a wrapper function called i2c_master_write_to_device() in 5.1.2 that seems like it might help me tidy up my code. However, I can't seem to figure out how to write a single byte using that function. Is it designed to only write more than 1 bytes? So I need to stick with the i2c_master_write_byte() function for this?
Here's a code snippet:
Code: Select all
// 1) Send recovery frame to sensor
#define TLV493D_I2C_ADDR (0x5E << 1)
#define I2C_MASTER_NUM I2C_NUM_0
// For ease/clarity later, these are the pre-composed
// read/write addresses themselves.
#define TLV493D_I2C_WRITE_ADDR (TLV493D_I2C_ADDR | I2C_MASTER_WRITE)
#define TLV493D_I2C_READ_ADDR (TLV493D_I2C_ADDR | I2C_MASTER_READ)
uint8_t data 0xFF;
status = i2c_master_write_to_device( I2C_MASTER_NUM,
TLV493D_I2C_WRITE_ADDR,
&data,
1,
1000 / portTICK_PERIOD_MS);