-
Notifications
You must be signed in to change notification settings - Fork 1k
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
Conversation
cores/arduino/stm32/twi.c
Outdated
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){}; |
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.
Maybe add a timeout in case of error.
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.
Either check for a timeout indeed or maybe at least cehck for possible errors
cores/arduino/stm32/twi.c
Outdated
ret = I2C_OK; | ||
} | ||
// wait for transfer completion | ||
while(HAL_I2C_GetState(&(obj->handle)) != HAL_I2C_STATE_READY){}; |
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.
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.
Adding timeout following @fprwi6labs and @LMESTM remarks. |
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.
waiting @fprwi6labs and @cparata review
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.
Ok for me.
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.