summaryrefslogtreecommitdiff
path: root/it2gpio
blob: f6b5e7b05e7f43b24b31932a78177305cf63d930 (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
#!/usr/bin/env python3
import sys, re

regs = []

def main():
    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 Error("regs is empty")

    for k, reg in enumerate(regs):
        for i in range(32):
            num = (32 * k) + i
            index = int(num / 32)
            bit = num % 32
            status = (reg >> bit) & 1
            print("GPIO%d = %d" % (num, status))

if __name__ == '__main__':
    main()