Commit 8083dc9
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 ba5971e commit 8083dc9
File tree
6 files changed
+659
-2
lines changed- drivers/i2c
- dts/bindings/i2c
- tests/drivers/build_all/i2c
- boards
6 files changed
+659
-2
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
51 | 51 | | |
52 | 52 | | |
53 | 53 | | |
| 54 | + | |
54 | 55 | | |
55 | 56 | | |
56 | 57 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
254 | 254 | | |
255 | 255 | | |
256 | 256 | | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
| 260 | + | |
| 261 | + | |
| 262 | + | |
| 263 | + | |
| 264 | + | |
257 | 265 | | |
258 | 266 | | |
259 | 267 | | |
| |||
0 commit comments