Commit 10e93ae
committed
drivers: i2c: add i2c controller implementation using rp2040 pio
I2C controller that uses PIO on RP2040. Using this we can drive up to 8 I2C
busses in addition to the two supported by the built-in i2c peripheral.
This driver is adapted from the pico sdk pio i2c example with some changes
to fix identified issues.
1. Resetting the input shift register before reading a byte. Sometimes the
shift register might get out of sync.
2. Resetting the SM after handling a NAK, related to shift registers
counters getting out of sync.
3. Waiting for possible clock stretching when writing the I2C STOP.
This is a blocking driver as I found versions interacting with the PIO via
interrupts to perform much worse than simply waiting via `k_yield`.
The driver attempts to load the PIO code only once in order to allow
multiple driver instances to run the same code.
It also uses the `reg` property as the SM, instead of relying on pico sdk
to arbitrarily assign one, which seems to be the norm for other PIO-based
drivers in the codebase. I'll put up a separate PR to do this on the main
pio dts nodes and fix-up drivers if people think this is a good idea.
Signed-off-by: Yiding Jia <[email protected]>1 parent c966eac commit 10e93ae
File tree
6 files changed
+624
-2
lines changed- drivers/i2c
- dts/bindings/i2c
- tests/drivers/build_all/i2c
- boards
6 files changed
+624
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
104 | 104 | | |
105 | 105 | | |
106 | 106 | | |
| 107 | + | |
107 | 108 | | |
108 | 109 | | |
109 | 110 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
248 | 248 | | |
249 | 249 | | |
250 | 250 | | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
251 | 259 | | |
252 | 260 | | |
253 | 261 | | |
| |||
0 commit comments