Repository navigation
Commit b73b0fc
committed
taskI2C: reset I2C bus if cannot connect to MPU1 and MPU2 for too long
There are still certain corner cases which can cause the Arduino I2C bus
to become "stuck" -- it will not be able to make any successful I2C
communication after that regardless of whether the MPUs are connected
correctly or not.
Example of one such case: connect a wire to SDA (with the MPUs connected
as well). Rapidly attach and detach the other end of the wire to ground.
taskI2C will also rapidly report the MPUs as disconnected and connected,
and then finally stop at "the MPUs are disconnected", unable to
reconnect again.
Take the hard approach in fixing this: when we detect that both MPUs are
disconnected after 1 second, hard reset the Arduino's I2C bus, wait 1
second, and then re-enable it again. Some quick testing shows that this
works.1 parent 8f9e533 commit b73b0fc
1 file changed
Lines changed: 15 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
85 | 85 | | |
86 | 86 | | |
87 | 87 | | |
| 88 | + | |
88 | 89 | | |
89 | 90 | | |
90 | 91 | | |
| |||
111 | 112 | | |
112 | 113 | | |
113 | 114 | | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
114 | 129 | | |
115 | 130 | | |
116 | 131 | | |
| |||
0 commit comments