2 #lut size of 93 (46 pins/header; 2 headers; padding for 1-indexed)
5 '''generate the lut from the csv'''
11 m = re.search("P(\d)_(\d+),(\d+)", line)
12 header = int(m.group(1))
14 gpionum = int(m.group(3))
21 lut[header*46+pin] = gpionum
22 reverselut[gpionum] = header*46+pin
26 for i in range(0, 93):
27 lutarr.append(lut.get(i, 0))
29 for i in range(0, 116): #Max safe GPIO is 115
30 reverselutarr.append(reverselut.get(i, 0))
32 return (lutarr, reverselutarr)
34 def printlut(lut, name="g_gpio_lut"):
35 '''print the lut for C'''
37 print("const unsigned char %s[%d] = {" % (name, len(lut)))
40 for i in range(0, len(lut), rowsize):
42 print(*("%3d" % g for g in lut[low:high]), sep=', ', end="")