Page 1 of 1

2 different i2c timeout values: i2c_set_timeout vs i2c_master_cmd_begin

Posted: Mon Jan 10, 2022 2:22 am
by atx823
A timeout can be specified using i2c_set_timeout, or you can specify ticks_to_wait as an argument to i2c_master_cmd_begin.

How exactly does each of these values work?

Some devices have variable delays between receiving a command and issuing a reply. In such cases you want to wait the minimum amount of time and then start polling for a reply.

Looking at the source for i2c_master_cmd_begin, it seems as tick_to_wait is used as the timeout for xQueueReceive. If this times out, the bus is reset. From my experiments it seems that this resets the slave device, making polling impossible.