-
Notifications
You must be signed in to change notification settings - Fork 3k
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
STM32: make i2c_salve_read return the number of bytes read #14659
Conversation
@pennam, thank you for your changes. |
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.
Please add info from description to the commit message (what is being fixed and why)
Also keep the style consistent in i2c_api.c file (if (
- space)
This PR cannot be merged due to conflicts. Please rebase to resolve them. |
…ad API return an error if less bytes are readed
rebased to resolve conflict in |
CI started |
Jenkins CI Test : ❌ FAILEDBuild Number: 1 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Need to update objects.h file of all ST platforms to PASS ci. @jeromecoutant what's your opinion on this changes? If you are OK with them i will fix the other targets. Thanks |
Approved ! |
CI should be fixed now |
@0xc0170 looks like you added the label but didn't actually start the CI ? |
Correct, I had to wait until 5.15 job completed (the breakage in 5.15 to be cleared). Starting all master jobs now |
CI started |
Jenkins CI Test : ✔️ SUCCESSBuild Number: 2 | 🔒 Jenkins CI Job | 🌐 Logs & ArtifactsCLICK for Detailed Summary
|
Summary of changes
If no timeout happens during communication
i2c_slave_read(i2c_t *obj, char *data, int length)
returned value is always equal to length parameter even if the master sends a lower number of bytes. Subsequently mbed-os read API will return always success.The proposed solution is the same implemented here https://github.com/stm32duino/Arduino_Core_STM32/blob/655587065fbdd6324655fee0b13d268507e23a40/libraries/Wire/src/utility/twi.c#L1014
With this changes if the master writes 5 bytes and we read less than 5 bytes slave.read() will return success, same happens if we read exactly 5 bytes, but if we want to read 5 bytes and master writes only 4, slave.read() will return an error
Impact of changes
All ST targets
Migration actions required
Documentation
Pull request type
Test results
I've tested the changes on PORTENTA target using this code and works as described above.
Reviewers
@facchinm @jeromecoutant @0xc0170