forked from M-Labs/artiq
artiq_ddb_template: add support for user LEDs
Add support for additional user LEDs.
This commit is contained in:
parent
e7af219505
commit
363afb5fc9
|
@ -24,6 +24,27 @@ def get_cpu_target(description):
|
||||||
else:
|
else:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
|
|
||||||
|
def get_num_leds(description):
|
||||||
|
drtio_role = description["drtio_role"]
|
||||||
|
target = description["target"]
|
||||||
|
hw_rev = description["hw_rev"]
|
||||||
|
kasli_board_leds = {
|
||||||
|
"v1.0": 4,
|
||||||
|
"v1.1": 6,
|
||||||
|
"v2.0": 3
|
||||||
|
}
|
||||||
|
if target == "kasli":
|
||||||
|
if hw_rev in ("v1.0", "v1.1") and drtio_role != "standalone":
|
||||||
|
# LEDs are used for DRTIO status on v1.0 and v1.1
|
||||||
|
return kasli_board_leds[hw_rev] - 3
|
||||||
|
return kasli_board_leds[hw_rev]
|
||||||
|
elif target == "kasli_soc":
|
||||||
|
return 2
|
||||||
|
else:
|
||||||
|
raise ValueError
|
||||||
|
|
||||||
|
|
||||||
def process_header(output, description):
|
def process_header(output, description):
|
||||||
print(textwrap.dedent("""
|
print(textwrap.dedent("""
|
||||||
# Autogenerated for the {variant} variant
|
# Autogenerated for the {variant} variant
|
||||||
|
@ -701,8 +722,8 @@ class PeripheralManager:
|
||||||
processor = getattr(self, "process_"+str(peripheral["type"]))
|
processor = getattr(self, "process_"+str(peripheral["type"]))
|
||||||
return processor(rtio_offset, peripheral)
|
return processor(rtio_offset, peripheral)
|
||||||
|
|
||||||
def add_board_leds(self, rtio_offset, board_name=None):
|
def add_board_leds(self, rtio_offset, board_name=None, num_leds=2):
|
||||||
for i in range(2):
|
for i in range(num_leds):
|
||||||
if board_name is None:
|
if board_name is None:
|
||||||
led_name = self.get_name("led")
|
led_name = self.get_name("led")
|
||||||
else:
|
else:
|
||||||
|
@ -716,7 +737,7 @@ class PeripheralManager:
|
||||||
}}""",
|
}}""",
|
||||||
name=led_name,
|
name=led_name,
|
||||||
channel=rtio_offset+i)
|
channel=rtio_offset+i)
|
||||||
return 2
|
return num_leds
|
||||||
|
|
||||||
|
|
||||||
def split_drtio_eem(peripherals):
|
def split_drtio_eem(peripherals):
|
||||||
|
@ -745,9 +766,10 @@ def process(output, primary_description, satellites):
|
||||||
for peripheral in local_peripherals:
|
for peripheral in local_peripherals:
|
||||||
n_channels = pm.process(rtio_offset, peripheral)
|
n_channels = pm.process(rtio_offset, peripheral)
|
||||||
rtio_offset += n_channels
|
rtio_offset += n_channels
|
||||||
if drtio_role == "standalone":
|
|
||||||
n_channels = pm.add_board_leds(rtio_offset)
|
num_leds = get_num_leds(primary_description)
|
||||||
rtio_offset += n_channels
|
pm.add_board_leds(rtio_offset, num_leds=num_leds)
|
||||||
|
rtio_offset += num_leds
|
||||||
|
|
||||||
for destination, description in satellites:
|
for destination, description in satellites:
|
||||||
if description["drtio_role"] != "satellite":
|
if description["drtio_role"] != "satellite":
|
||||||
|
@ -767,6 +789,10 @@ def process(output, primary_description, satellites):
|
||||||
n_channels = pm.process(rtio_offset, peripheral)
|
n_channels = pm.process(rtio_offset, peripheral)
|
||||||
rtio_offset += n_channels
|
rtio_offset += n_channels
|
||||||
|
|
||||||
|
num_leds = get_num_leds(description)
|
||||||
|
pm.add_board_leds(rtio_offset, num_leds=num_leds)
|
||||||
|
rtio_offset += num_leds
|
||||||
|
|
||||||
for i, peripheral in enumerate(drtio_peripherals):
|
for i, peripheral in enumerate(drtio_peripherals):
|
||||||
if not("drtio_destination" in peripheral):
|
if not("drtio_destination" in peripheral):
|
||||||
if primary_description["target"] == "kasli":
|
if primary_description["target"] == "kasli":
|
||||||
|
|
Loading…
Reference in New Issue