quicklogic_quickfeather: add button and GPIOIn

Signed-off-by: Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
This commit is contained in:
Gwenhael Goavec-Merou 2021-11-12 11:43:28 +01:00 committed by Florent Kermarrec
parent 5374c32873
commit 648d38da7e
2 changed files with 16 additions and 5 deletions

View File

@ -14,6 +14,9 @@ _io = [
("user_led", 0, Pins("38"), IOStandard("LVCMOS33")), # blue ("user_led", 0, Pins("38"), IOStandard("LVCMOS33")), # blue
("user_led", 1, Pins("39"), IOStandard("LVCMOS33")), # green ("user_led", 1, Pins("39"), IOStandard("LVCMOS33")), # green
("user_led", 2, Pins("34"), IOStandard("LVCMOS33")), # red ("user_led", 2, Pins("34"), IOStandard("LVCMOS33")), # red
# Button
("user_btn_n", 0, Pins("62"), IOStandard("LVCMOS33")),
] ]
# Platform ----------------------------------------------------------------------------------------- # Platform -----------------------------------------------------------------------------------------

View File

@ -18,6 +18,7 @@ from litex.soc.cores.clock import *
from litex.soc.integration.soc_core import * from litex.soc.integration.soc_core import *
from litex.soc.integration.builder import * from litex.soc.integration.builder import *
from litex.soc.cores.led import LedChaser from litex.soc.cores.led import LedChaser
from litex.soc.cores.gpio import *
# CRG ---------------------------------------------------------------------------------------------- # CRG ----------------------------------------------------------------------------------------------
@ -44,7 +45,7 @@ class _CRG(Module):
# BaseSoC ------------------------------------------------------------------------------------------ # BaseSoC ------------------------------------------------------------------------------------------
class BaseSoC(SoCCore): class BaseSoC(SoCCore):
def __init__(self, sys_clk_freq=int(10e6), with_led_chaser=True, **kwargs): def __init__(self, sys_clk_freq=int(10e6), with_led_chaser=True, with_gpioin=True, **kwargs):
platform = quicklogic_quickfeather.Platform() platform = quicklogic_quickfeather.Platform()
# SoCCore ---------------------------------------------------------------------------------- # SoCCore ----------------------------------------------------------------------------------
@ -62,11 +63,18 @@ class BaseSoC(SoCCore):
# CRG -------------------------------------------------------------------------------------- # CRG --------------------------------------------------------------------------------------
self.submodules.crg = _CRG(platform, is_eoss3_cpu) self.submodules.crg = _CRG(platform, is_eoss3_cpu)
# GPIOIn -> interrupt test
if with_gpioin:
self.submodules.gpio = GPIOIn(
pads = platform.request_all("user_btn_n"), with_irq=True)
self.add_csr("gpio")
self.irq.add("gpio", use_loc_if_exists=True)
# Leds ------------------------------------------------------------------------------------- # Leds -------------------------------------------------------------------------------------
if with_led_chaser: if with_led_chaser:
self.submodules.leds = LedChaser( self.submodules.leds = LedChaser(
pads = platform.request_all("user_led"), pads = platform.request_all("user_led"),
sys_clk_freq = sys_clk_freq) sys_clk_freq = sys_clk_freq)
if is_eoss3_cpu:
self.add_csr("leds") self.add_csr("leds")
# Build -------------------------------------------------------------------------------------------- # Build --------------------------------------------------------------------------------------------