cores/gpio: Fix GPIOIRQ.
Compilation tested in Arty with: from litex.soc.cores.gpio import GPIOIn self.submodules.gpio_in = GPIOIn(platform.request("user_sw", 0), with_irq=True) self.add_csr("gpio_in") self.add_interrupt("gpio_in")
This commit is contained in:
parent
1bb4507d93
commit
d0c4199096
|
@ -18,8 +18,8 @@ def _to_signal(obj):
|
||||||
return obj.raw_bits() if isinstance(obj, Record) else obj
|
return obj.raw_bits() if isinstance(obj, Record) else obj
|
||||||
|
|
||||||
|
|
||||||
class _GPIOIRQ(Module, AutoCSR):
|
class _GPIOIRQ:
|
||||||
def __init__(self, in_pads):
|
def add_irq(self, in_pads):
|
||||||
self._polarity = CSRStorage(len(in_pads), description="GPIO IRQ Polarity: 0: Rising Edge, 1: Falling Edge.")
|
self._polarity = CSRStorage(len(in_pads), description="GPIO IRQ Polarity: 0: Rising Edge, 1: Falling Edge.")
|
||||||
|
|
||||||
# # #
|
# # #
|
||||||
|
@ -32,13 +32,13 @@ class _GPIOIRQ(Module, AutoCSR):
|
||||||
|
|
||||||
# GPIO Input ---------------------------------------------------------------------------------------
|
# GPIO Input ---------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class GPIOIn(Module, AutoCSR):
|
class GPIOIn(_GPIOIRQ, Module, AutoCSR):
|
||||||
def __init__(self, pads, with_irq=False):
|
def __init__(self, pads, with_irq=False):
|
||||||
pads = _to_signal(pads)
|
pads = _to_signal(pads)
|
||||||
self._in = CSRStatus(len(pads), description="GPIO Input(s) Status.")
|
self._in = CSRStatus(len(pads), description="GPIO Input(s) Status.")
|
||||||
self.specials += MultiReg(pads, self._in.status)
|
self.specials += MultiReg(pads, self._in.status)
|
||||||
if with_irq:
|
if with_irq:
|
||||||
self.submodules.irq = _GPIOIRQ(self._in.status)
|
self.add_irq(self._in.status)
|
||||||
|
|
||||||
# GPIO Output --------------------------------------------------------------------------------------
|
# GPIO Output --------------------------------------------------------------------------------------
|
||||||
|
|
||||||
|
@ -60,7 +60,7 @@ class GPIOInOut(Module):
|
||||||
|
|
||||||
# GPIO Tristate ------------------------------------------------------------------------------------
|
# GPIO Tristate ------------------------------------------------------------------------------------
|
||||||
|
|
||||||
class GPIOTristate(Module, AutoCSR):
|
class GPIOTristate(_GPIOIRQ, Module, AutoCSR):
|
||||||
def __init__(self, pads, with_irq=False):
|
def __init__(self, pads, with_irq=False):
|
||||||
assert isinstance(pads, Signal)
|
assert isinstance(pads, Signal)
|
||||||
nbits = len(pads)
|
nbits = len(pads)
|
||||||
|
@ -78,4 +78,4 @@ class GPIOTristate(Module, AutoCSR):
|
||||||
self.specials += MultiReg(t.i, self._in.status[i])
|
self.specials += MultiReg(t.i, self._in.status[i])
|
||||||
|
|
||||||
if with_irq:
|
if with_irq:
|
||||||
self.submodules.irq = _GPIOIRQ(self._in.status)
|
self.add_irq(self._in.status)
|
||||||
|
|
Loading…
Reference in New Issue