Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix i2c master on ESP32 #5851

Merged
merged 7 commits into from
Feb 7, 2018
Merged

Conversation

iha
Copy link
Contributor

@iha iha commented Jan 26, 2018

To fix I2C master this PR is required.

@iha iha changed the title Fix i2c master Fix i2c master on ESP32 Jan 26, 2018
@codecov-io
Copy link

codecov-io commented Jan 26, 2018

Codecov Report

Merging #5851 into master will not change coverage.
The diff coverage is n/a.

Impacted file tree graph

@@           Coverage Diff           @@
##           master    #5851   +/-   ##
=======================================
  Coverage   52.51%   52.51%           
=======================================
  Files         406      406           
  Lines       39683    39683           
  Branches     7715     7715           
=======================================
  Hits        20839    20839           
  Misses      15663    15663           
  Partials     3181     3181

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 30824c9...8e04f52. Read the comment docs.

@@ -284,6 +284,19 @@ static int i2c_esp32_configure(struct device *dev, u32_t dev_config)
return ret;
}

static void i2c_esp32_reset_cmd(const struct i2c_esp32_config *config)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Could this be changed so that, right before a transfer is performed, only the unused commands are cleared out? This way, the number of unneeded register writes is reduced, and command queue cleanup happens in only one place.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually this cleanup is unnecessary because of the way commands are inserted in the queue, I'm going to remove this commit.

@iha iha force-pushed the fix_i2c_master branch 3 times, most recently from 12261b8 to c12eb3c Compare January 27, 2018 18:17
@nashif nashif added this to the v1.11.0 milestone Feb 7, 2018
Copy link
Collaborator

@lpereira lpereira left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM. Thanks for fixing this driver!

iha added 7 commits February 7, 2018 13:10
On i2c_esp32_read_msg() and i2c_esp32_write_msg() first command
it should be always RSTART.

Signed-off-by: Vitor Massaru Iha <[email protected]>
After a STOP opcode the transmission stops. The END opcode in this
case is unnecessary.

Signed-off-by: Vitor Massaru Iha <[email protected]>
The wait address command must be the last command address.

Unncessary variable was removed.

Signed-off-by: Vitor Massaru Iha <[email protected]>
When I2C Master writes to slave on CMD_Controller, opcode WRITE
was set twice instead of 1 WRITE at the beginning of the
transmission.

And when Master reads from slave, on CMD_Controller,
byte_num = 1 + data_lenght instead of byte_num = 1 at the
beginning of the transmission.

Note that is for 7 bits addresses, to 10 bit adressess is added
more 1 in byte_num as can be seen in the code above this fix.

Signed-off-by: Vitor Massaru Iha <[email protected]>
Increase I2C_ESP32_SPIN_THRESHOLD to avoid read or write timeout.
This is an empirical value.

Signed-off-by: Vitor Massaru Iha <[email protected]>
msg.len is incremented only when I2C master writes to slave.

Signed-off-by: Vitor Massaru Iha <[email protected]>
to_read is the minimum value between I2C_ESP32_BUFFER_SIZE
and (msg.len - 1) rather than the maximum value.

Signed-off-by: Vitor Massaru Iha <[email protected]>
@nashif nashif merged commit e9d1015 into zephyrproject-rtos:master Feb 7, 2018
@iha iha deleted the fix_i2c_master branch February 7, 2018 21:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants