summaryrefslogtreecommitdiff
path: root/it2gpio
blob: 1723f484dec78caa14c40546b37216dcb709a595 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
#!/usr/bin/env python3
import sys


def main():
    regs = []

    for line in sys.stdin:
        line = line.strip()
        parts = line.split(' ')
        if line.endswith('(GP_LVL)') or line.endswith('(GP_LVL2)') or line.endswith('(GPIO_LVL3)'):
            val = parts[1]
            regs.append(int(val, 16))

    if not regs:
        raise Exception("regs is empty")

    for k, reg in enumerate(regs):
        for i in range(32):
            gpio_num = (32 * k) + i
            if gpio_num > 75:
                break
            bit = gpio_num % 32
            gpio_val = (reg >> bit) & 1
            print("GPIO%d = %d" % (gpio_num, gpio_val))


if __name__ == '__main__':
    main()