From 400bd4e79807aeb4effc427e3ac6e50241493fa4 Mon Sep 17 00:00:00 2001 From: Evgeny Zinoviev Date: Tue, 9 Feb 2021 15:47:46 +0300 Subject: initial --- it2gpio | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) create mode 100755 it2gpio (limited to 'it2gpio') diff --git a/it2gpio b/it2gpio new file mode 100755 index 0000000..f6b5e7b --- /dev/null +++ b/it2gpio @@ -0,0 +1,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() + -- cgit v1.2.3