Skip to content

Documentation says that I2C is not thread safe but it is #1997

@xarrange

Description

@xarrange

Environment

  • Development Kit: none
  • Core (if using chip or module): ESP-WROOM32
  • IDF version 051d8d6
  • Development Env: other
  • Operating System: Windows
  • Power Supply: USB

Problem Description

Documentation for i2c_master_cmd_begin says:

The I2C APIs are not thread-safe, if you want to use one I2C port in different tasks, you need to take care of the multi-thread issue.

But code of i2c_master_cmd_begin has this:

portBASE_TYPE res = xSemaphoreTake(p_i2c->cmd_mux, ticks_to_wait);
...
xSemaphoreGive(p_i2c->cmd_mux);

which means that I2C driver protects command flow by mutex and we don't need to do the same on the upper levels. Am I right?

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions