Skip to content
This repository has been archived by the owner on Dec 6, 2018. It is now read-only.

Add error handling to i2c bus implementaion #19

Closed
vadimol opened this issue Apr 25, 2016 · 6 comments
Closed

Add error handling to i2c bus implementaion #19

vadimol opened this issue Apr 25, 2016 · 6 comments

Comments

@vadimol
Copy link
Collaborator

vadimol commented Apr 25, 2016

For now i2c bus implementation does not support error handling. Actually device can hang in case of en error or glitch on a bus.
For polling we can use timeouts for operations.
For irq - there is a separate handler for errors.

@rasendubi
Copy link
Collaborator

rasendubi commented May 10, 2017

We should also switch to using I2C_GetLastEvent instead of I2C_GetFlagStatus because the former allows checking for errors.

@forGGe
Copy link
Collaborator

forGGe commented May 10, 2017

@rasendubi Makes sense.

@forGGe
Copy link
Collaborator

forGGe commented Jul 10, 2017

@Dubland : check #19 (comment)

@forGGe
Copy link
Collaborator

forGGe commented Jul 10, 2017

Function usage is described in stm32 i2c source.

Checks like these https://github.com/forGGe/theCore/blob/develop/platform/stm32/export/aux/i2c_bus.hpp#L586 must be re-implemented using I2C_GetFlagStatus.

Error can be reported using bus event:
https://github.com/forGGe/theCore/blob/develop/platform/common/export/common/bus.hpp#L26

After that, soft_reset can try to repeat xfer if necessary:
https://github.com/forGGe/theCore/blob/develop/dev/sensor/htu21d/export/dev/sensor/htu21d.hpp#L177

Talk to @vadimol for more details of how i2c driver works if something unclear.

@rasendubi
Copy link
Collaborator

A small correction: checks must be re-implemented using I2C_GetLastEvent.

I2C_GetFlagStatus resets some status flags so is not appropriate to call multiple times in a row.

@forGGe
Copy link
Collaborator

forGGe commented Oct 11, 2017

Implemented as a part of #279 Thanks to @Dubland !

@forGGe forGGe closed this as completed Oct 11, 2017
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

3 participants