Skip to content

Use interrupt mode for I2C transfers #115

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

Merged
merged 1 commit into from
Sep 28, 2017
Merged

Conversation

VVESTM
Copy link
Contributor

@VVESTM VVESTM commented Sep 27, 2017

I faced an issue while coding a demo for L475 IoT board that use several sensors on i2c2 and BTLE on SPI3. With the actual polling mode for I2C, the transfers can be disturbed by SPI.

Commit message :
Switch from polling mode to IT mode for I2C transfers.
For example, this is needed if we want to use SPI and
I2C in the same time.

@VVESTM VVESTM requested review from fpistm, cparata, LMESTM and a user September 27, 2017 15:25
status = HAL_I2C_Master_Transmit_IT(&(obj->handle), dev_address, data, size);

// wait for transfer completion
while(HAL_I2C_GetState(&(obj->handle)) != HAL_I2C_STATE_READY){};
Copy link

Choose a reason for hiding this comment

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

Maybe add a timeout in case of error.

Copy link
Member

Choose a reason for hiding this comment

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

Either check for a timeout indeed or maybe at least cehck for possible errors

ret = I2C_OK;
}
// wait for transfer completion
while(HAL_I2C_GetState(&(obj->handle)) != HAL_I2C_STATE_READY){};
Copy link

Choose a reason for hiding this comment

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

ditto

Switch from polling mode to IT mode for I2C transfers.
For example, this is needed if we want to use SPI and
I2C in the same time.
@VVESTM
Copy link
Contributor Author

VVESTM commented Sep 28, 2017

Adding timeout following @fprwi6labs and @LMESTM remarks.

Copy link
Member

@fpistm fpistm left a comment

Choose a reason for hiding this comment

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

waiting @fprwi6labs and @cparata review

@ghost ghost self-requested a review September 28, 2017 11:57
@fpistm fpistm added the bug 🐛 Something isn't working label Sep 28, 2017
@fpistm fpistm added this to the Next release milestone Sep 28, 2017
@fpistm fpistm merged commit 1048019 into stm32duino:master Sep 28, 2017
@cparata cparata requested review from cparata and removed request for cparata September 28, 2017 15:07
Copy link
Contributor

@cparata cparata left a comment

Choose a reason for hiding this comment

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

Ok for me.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug 🐛 Something isn't working
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants