-
Notifications
You must be signed in to change notification settings - Fork 7.7k
rx <-> tx typo's, NULLing free'd variable, consistent CRITICAL sects #1180
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
Conversation
A couple of typos referencing tx_ring_buf when rx_ring_buf, slv_tx_mux instead of slv_rx_mux. Also, I2C_ENTER_CRITICAL()/I2C_EXIT_CRITICAL() usage was not consistent. Only some of the _set_ functions had them. Most of the _get_ function had them? It is my understanding that they should be wrapped around writes, not reads? Also, the ticks_to_wait timeout handling in i2c_master_cmd_begin() would not handle integer rollover correctly.
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.
Thanks for fixing the overflow issue. There are some stylistic changes requested, but we'll be happy to merge this.
components/driver/i2c.c
Outdated
@@ -258,6 +258,7 @@ esp_err_t i2c_driver_install(i2c_port_t i2c_num, i2c_mode_t mode, size_t slv_rx_ | |||
} | |||
} | |||
free(p_i2c_obj[i2c_num]); | |||
p_i2c_obj[i2c_num] = NULL; |
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 you please space-ify the indentation here?
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.
I have converted tabs to spaces where ever I could find them.
Do I need to recreate a pull? or will your merge pull the current from my fork?
Chuck.
components/driver/i2c.c
Outdated
@@ -634,14 +635,14 @@ esp_err_t i2c_set_period(i2c_port_t i2c_num, int high_period, int low_period) | |||
esp_err_t i2c_get_period(i2c_port_t i2c_num, int* high_period, int* low_period) | |||
{ | |||
I2C_CHECK(i2c_num < I2C_NUM_MAX, I2C_NUM_ERROR_STR, ESP_ERR_INVALID_ARG); | |||
I2C_ENTER_CRITICAL(&i2c_spinlock[i2c_num]); | |||
// I2C_ENTER_CRITICAL(&i2c_spinlock[i2c_num]); |
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.
These critical sections can be removed instead of commented out.
(You're right that as there's no read-modify-write here the spinlock is unnecessary, thanks for pointing that out.)
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.
I removed the commented old code.
components/driver/i2c.c
Outdated
@@ -1103,7 +1110,9 @@ esp_err_t i2c_master_cmd_begin(i2c_port_t i2c_num, i2c_cmd_handle_t cmd_handle, | |||
|
|||
esp_err_t ret = ESP_FAIL; | |||
i2c_obj_t* p_i2c = p_i2c_obj[i2c_num]; | |||
portTickType ticks_end = xTaskGetTickCount() + ticks_to_wait; | |||
// portTickType ticks_end = xTaskGetTickCount() + ticks_to_wait; | |||
// change to handle integer rollover correctly |
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.
You can remove these lines instead of commenting out.
Comments on why a change was made are usually best put into the commit message (you can split this PR into a few commits if this is easier for you, but that's optional.)
components/driver/i2c.c
Outdated
// Wait event bits | ||
EventBits_t uxBits; | ||
while (1) { | ||
TickType_t wait_time = (ticks_to_wait < (I2C_CMD_ALIVE_INTERVAL_TICK) ? ticks_to_wait : (I2C_CMD_ALIVE_INTERVAL_TICK)); | ||
// TickType_t wait_time = (ticks_to_wait < (I2C_CMD_ALIVE_INTERVAL_TICK) ? ticks_to_wait : (I2C_CMD_ALIVE_INTERVAL_TICK)); | ||
TickType_t wait_time = xTaskGetTickCounter(); |
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.
I think this is a typo for xTaskGetTickCount() ?
space-ify, remove marker comments, correct awkward error wording.
I have no Idea what changes were requested, I'm just going to close this pull and assume it was ignored. |
Hi @stickbreaker , Sorry, I've been travelling a lot the last few weeks and a few things have slipped through the cracks, including this. I apologise for ignoring you. It looks like you addressed all the changes at the beginning of the month. I'll take another look today and get back to you, if that's OK. |
Changes look good. I've squashed the 3 commits into 1, with a couple of minor formatting changes, and pushed them into our internal merge queue. Sorry again for the long delay. The PR will be updated again when the changes land. |
Sounds good. Chuck. |
Hi @stickbreaker , Just a note to say we haven't forgotten this PR. Some notes popped up in review, so we've made some small tweaks (such as keeping the spinlocks on i2c_get_period, as it reads multiple registers to produce the result). Expecting this will be merged soon. We've also combined #1353 into the same branch, as they touched similar functionality. Angus |
…ects A couple of typos referencing tx_ring_buf when rx_ring_buf, slv_tx_mux instead of slv_rx_mux. Also, I2C_ENTER_CRITICAL()/I2C_EXIT_CRITICAL() usage was not consistent. Only some of the _set_ functions had them. Most of the _get_ function had them? It is my understanding that they should be wrapped around writes, not reads? (I think we still need the lock for reading pairs of consistent values) Also, the ticks_to_wait timeout handling in i2c_master_cmd_begin() would not handle integer rollover correctly. Merges #1180
Sorry for the extraordinary delay, cherry-picked as d913fff. |
…ects A couple of typos referencing tx_ring_buf when rx_ring_buf, slv_tx_mux instead of slv_rx_mux. Also, I2C_ENTER_CRITICAL()/I2C_EXIT_CRITICAL() usage was not consistent. Only some of the _set_ functions had them. Most of the _get_ function had them? It is my understanding that they should be wrapped around writes, not reads? (I think we still need the lock for reading pairs of consistent values) Also, the ticks_to_wait timeout handling in i2c_master_cmd_begin() would not handle integer rollover correctly. Merges #1180
A couple of typos referencing tx_ring_buf when rx_ring_buf, slv_tx_mux
instead of slv_rx_mux.
Also, I2C_ENTER_CRITICAL()/I2C_EXIT_CRITICAL() usage was not consistent.
Only some of the set functions had them. Most of the get function
had them? It is my understanding that they should be wrapped around
writes, not reads?
Also, the ticks_to_wait timeout handling in i2c_master_cmd_begin() would
not handle integer rollover correctly.