@@ -24,6 +24,24 @@ def get_cpu_target(description):
2424 else :
2525 raise NotImplementedError
2626
27+
28+ def get_num_leds (description ):
29+ drtio_role = description ["drtio_role" ]
30+ target = description ["target" ]
31+ hw_rev = description ["hw_rev" ]
32+ kasli_board_leds = {
33+ "v1.0" : 4 ,
34+ "v1.1" : 6 ,
35+ "v2.0" : 3
36+ }
37+ if target == "kasli" :
38+ if hw_rev in ("v1.0" , "v1.1" ) and drtio_role != "standalone" :
39+ # LEDs are used for DRTIO status on v1.0 and v1.1
40+ return kasli_board_leds [hw_rev ] - 3
41+ return kasli_board_leds [hw_rev ]
42+ return 2
43+
44+
2745def process_header (output , description ):
2846 print (textwrap .dedent ("""
2947 # Autogenerated for the {variant} variant
@@ -701,8 +719,8 @@ def process(self, rtio_offset, peripheral):
701719 processor = getattr (self , "process_" + str (peripheral ["type" ]))
702720 return processor (rtio_offset , peripheral )
703721
704- def add_board_leds (self , rtio_offset , board_name = None ):
705- for i in range (2 ):
722+ def add_board_leds (self , rtio_offset , board_name = None , num_leds = 2 ):
723+ for i in range (num_leds ):
706724 if board_name is None :
707725 led_name = self .get_name ("led" )
708726 else :
@@ -716,7 +734,7 @@ def add_board_leds(self, rtio_offset, board_name=None):
716734 }}""" ,
717735 name = led_name ,
718736 channel = rtio_offset + i )
719- return 2
737+ return num_leds
720738
721739
722740def split_drtio_eem (peripherals ):
@@ -745,9 +763,10 @@ def process(output, primary_description, satellites):
745763 for peripheral in local_peripherals :
746764 n_channels = pm .process (rtio_offset , peripheral )
747765 rtio_offset += n_channels
748- if drtio_role == "standalone" :
749- n_channels = pm .add_board_leds (rtio_offset )
750- rtio_offset += n_channels
766+
767+ num_leds = get_num_leds (primary_description )
768+ pm .add_board_leds (rtio_offset , num_leds = num_leds )
769+ rtio_offset += num_leds
751770
752771 for destination , description in satellites :
753772 if description ["drtio_role" ] != "satellite" :
@@ -766,7 +785,11 @@ def process(output, primary_description, satellites):
766785 for peripheral in peripherals :
767786 n_channels = pm .process (rtio_offset , peripheral )
768787 rtio_offset += n_channels
769-
788+
789+ num_leds = get_num_leds (description )
790+ pm .add_board_leds (rtio_offset , num_leds = num_leds )
791+ rtio_offset += num_leds
792+
770793 for i , peripheral in enumerate (drtio_peripherals ):
771794 if not ("drtio_destination" in peripheral ):
772795 if primary_description ["target" ] == "kasli" :
0 commit comments