Skip to content

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

Closed
wants to merge 3 commits into from
Closed

Conversation

stickbreaker
Copy link
Contributor

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.

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.
@CLAassistant
Copy link

CLAassistant commented Oct 27, 2017

CLA assistant check
All committers have signed the CLA.

Copy link
Contributor

@projectgus projectgus left a 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.

@@ -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;
Copy link
Contributor

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?

Copy link
Contributor Author

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.

@@ -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]);
Copy link
Contributor

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.)

Copy link
Contributor Author

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.

@@ -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
Copy link
Contributor

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.)

// 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();
Copy link
Contributor

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.
fix type
@stickbreaker
Copy link
Contributor Author

I have no Idea what changes were requested, I'm just going to close this pull and assume it was ignored.
Chuck.

@projectgus projectgus reopened this Nov 16, 2017
@projectgus
Copy link
Contributor

projectgus commented Nov 16, 2017

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.

@projectgus
Copy link
Contributor

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.

@projectgus projectgus added the Status: Pending blocked by some other factor label Nov 16, 2017
@stickbreaker
Copy link
Contributor Author

Sounds good.

Chuck.

@projectgus
Copy link
Contributor

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

igrr pushed a commit that referenced this pull request Dec 18, 2017
…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
@projectgus
Copy link
Contributor

Sorry for the extraordinary delay, cherry-picked as d913fff.

@projectgus projectgus closed this Dec 18, 2017
igrr pushed a commit that referenced this pull request Dec 29, 2017
…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
@igrr igrr removed the Status: Pending blocked by some other factor label Aug 9, 2018
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