If all works fine – I mean I2C-Sensor is working properly on Bus – (imho) no one spend thoughts what happens if:
-a bit is missing/modified by EMI,
-the device is suddenly down maybe due brownout,
– other nice pain.
To utilize I2C-Bus in a secure manner (I mean preventing program from stuck endless in a while Loop) all rescue and error handler should be utilized not only why they are dedicated and available.
To do that, I have build up a working example, which could be implemented in the I2C-Communication Code to prevent from above mentioned pain.
Download Project for XMC1300 BootKit (or merge structure and Code to other Targets):
I2C_BusScanner for Infineon XMC