-
Notifications
You must be signed in to change notification settings - Fork 19
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
I2C is easy to misuse #13
Comments
I can Imagine we will take address of current I2C controller in class constructor and place it into an static array for already reserved peripherals. There we can also check if the peripheral address is already present or not in the array. But the other hand, is it really necessary? This seems to be too much complicated with very low benefit. Unnecessary code with another wasted memory. Potentially issue with backwards compatibility. Or exists another way? BR, Jan |
I think I have come across this today, it was particularly aggravated by multiple threads both trying to use I2C, it was using STM32 V2 HAL The symptoms were looping in the I2C ISR and no user coded executing afterwards. I think it should really be possible to have multiple instances of I2C per bus like SPI |
That could be really cool. Basically, what it would take would be adding the logic into I2C that SPI already has to share instances of the peripheral between multiple objects. Unfortunately it ends up being rather complex... |
The Mbed I2C implementation has two restrictions that are easy to violate:
Unfortunately, these are not made clear in the docs, and even some of the built-in drivers (I2CEEBlockDevice) violate them e.g. by having a constructor that takes pins instead of an I2C object. To make matters worse, violating the restrictions will appear to work fine in some scenarios, only to cause undefined behavior later on.
To fix this, we should:
The text was updated successfully, but these errors were encountered: