-
Notifications
You must be signed in to change notification settings - Fork 6.8k
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
Fix i2c master on ESP32 #5851
Conversation
Codecov Report
@@ 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.
|
drivers/i2c/i2c_esp32.c
Outdated
@@ -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) |
There was a problem hiding this comment.
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done.
There was a problem hiding this comment.
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.
12261b8
to
c12eb3c
Compare
There was a problem hiding this 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!
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]>
c12eb3c
to
8e04f52
Compare
To fix I2C master this PR is required.