Hi,
I have setup TWI peripheral for async transfers via IRQ and callback. After firing the transfer operation, I feel uneasy about having no control until the interrupt happens. Sometimes while playing with TWI wires I've been able to lock the bus, i.e. a TWI operation is initiated but the IRQ handler is never called anymore, also blocking further operations. Due to the async nature, my idea is to start/stop an app timer (single mode, 200ms) on every I2C operation. I'm not sure is the best solution, since I continuously start/stop the timer on each TWI operation and I fear this can interfere with SoftDevice.
- If the operation completes, I stop the timer from the TWI handler.
- If the timer handler is called instead, it means I have a pending operation on the TWI driver. I need to gracefully cleanup the TWI hw/sw related stuff and pass an error to the application layer. What's the suggested way of doing this?
I am using SDK 14.2, SoftDevice and app timers with the scheduler (not sure this may be important).
Thanks!