i2c: let them pull the bus down by toggling SCL OE off instead of O on.

Note that we still don't actually *let* them stretch the clock.
This commit is contained in:
Charlotte 2023-08-22 16:53:14 +10:00
parent 7b05e685eb
commit bb7388b9f1
2 changed files with 13 additions and 9 deletions

View File

@ -76,6 +76,7 @@ I2CHardwareBus = Signature(
{
"scl_o": Out(1, reset=1),
"scl_oe": Out(1, reset=1),
"scl_i": In(1, reset=1),
"sda_o": Out(1, reset=1),
"sda_oe": Out(1, reset=1),
"sda_i": In(1, reset=1),
@ -202,16 +203,15 @@ class I2C(Component):
plat_i2c.scl.oe.eq(self.hw_bus.scl_oe),
plat_i2c.sda.o.eq(self.hw_bus.sda_o),
plat_i2c.sda.oe.eq(self.hw_bus.sda_oe),
self.hw_bus.scl_i.eq(plat_i2c.scl.i),
self.hw_bus.sda_i.eq(plat_i2c.sda.i),
]
m.d.comb += self.hw_bus.scl_oe.eq(1)
# NOTE(Mia): we might need to keep scl_o=0 and toggle scl_oe instead for
# clock stretching?
m.d.comb += self.hw_bus.scl_o.eq(0)
m.submodules._c = c = self._c
with m.If(c.full):
m.d.sync += self.hw_bus.scl_o.eq(~self.hw_bus.scl_o)
m.d.sync += self.hw_bus.scl_oe.eq(~self.hw_bus.scl_oe)
m.d.sync += self._in_fifo.r_en.eq(0)
@ -224,7 +224,7 @@ class I2C(Component):
m.d.sync += [
self.hw_bus.sda_oe.eq(1),
self.hw_bus.sda_o.eq(1),
self.hw_bus.scl_o.eq(1),
self.hw_bus.scl_oe.eq(0),
]
with m.If(self.bus.stb & self._in_fifo.r_rdy):
@ -430,7 +430,7 @@ class I2C(Component):
m.d.sync += [
c.en.eq(0),
self.bus.busy.eq(0),
self.hw_bus.scl_o.eq(1),
self.hw_bus.scl_oe.eq(0),
]
m.next = "IDLE"

View File

@ -248,9 +248,13 @@ class OLED(Component):
self.result.eq(OLED.Result.BUSY),
]
m.next = "START: STROBED FIFO_IN R_EN"
with m.Elif(self._cursor_en &
((self._cursor_last_drawn_col != self._col) |
(self._cursor_last_drawn_row != self._row))):
with m.Elif(
self._cursor_en
& (
(self._cursor_last_drawn_col != self._col)
| (self._cursor_last_drawn_row != self._row)
)
):
m.d.sync += self._cursor_en.eq(0)
m.next = "CURSOR_ON: RESET"