Skip to content

potential issues in i2c_read_blocking_internal #336

@fivdi

Description

@fivdi

There may be two issues in i2c_read_blocking_internal.

Issue 1
The first potential issue is these two lines of code:

            abort_reason = i2c->hw->tx_abrt_source;
            abort = (bool) i2c->hw->clr_tx_abrt;

The first line of code copies the value of the IC_TX_ABRT_SOURCE register to abort_reason. The second line clears the same register, that is, the IC_TX_ABRT_SOURCE register. If the hardware decides to set a bit in the IC_TX_ABRT_SOURCE register after the first line has been executed, but before the second line is executed, the reason for the aborted transfer will be lost. I don't have an example program that can be used to demonstrate this, it's an assumption.

Issue 2
The second potential issue is these two lines of code:

        while (!i2c_get_write_available(i2c))
            tight_loop_contents();

I'm not 100% sure but I don't think this loop serves any purpose. Can it be removed?

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Relationships

None yet

Development

No branches or pull requests

Issue actions