feat(stage2): extracting bank and pin information from PinSpec for later use in the...
authorAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 27 Sep 2022 16:44:32 +0000 (16:44 +0000)
committerAndrey Miroshnikov <andrey@technepisteme.xyz>
Tue, 27 Sep 2022 16:44:32 +0000 (16:44 +0000)
src/spec/stage2.py

index 3cd7fbafb424e223a8f883123801833d7bb684e5..221961695b450609054ff1172ac7ee9fbbdbb0f8 100644 (file)
@@ -434,9 +434,45 @@ if __name__ == '__main__':
                       'UART0': 'UART (TX/RX) 0',
                      }
     ps = PinSpec(pinbanks, fixedpins, function_names)
+    # Unit number, (Bank, pin #), mux, start, num # pins
     ps.gpio("", ('A', 0), 0, 0, 4)
     ps.uart("0", ('A', 0), 1)
     ps.i2c("0", ('A', 0), 2)
 
     print(dir(ps.gpio))
-    print(ps.gpio.pinouts, ps.gpio.bankspec, ps.gpio.pinfn, ps.gpio.fname)
+    #print(ps.gpio.pinouts, ps.gpio.bankspec, ps.gpio.pinfn, ps.gpio.fname)
+    """
+    desc_dict_keys = ['UART0', 'TWI0', 'GPIOA_A0', 'GPIOA_A1', 'GPIOA_A2', 'GPIOA_A3']
+    eint = []
+    pwm = []
+    desc = {'UART0': 'Basic serial TX/RX serial port',
+            'TWI0': 'I2C interface',
+            'GPIOA_A0': 'Test GPIO0',
+            'GPIOA_A1': 'Test GPIO1',
+            'GPIOA_A2': 'Test GPIO2',
+            'GPIOA_A3': 'Test GPIO3'}
+    ps.add_scenario("Test Manual Pinmux", desc_dict_keys, eint, pwm, desc)
+    """
+    print("---------------------------------")
+    #with open("test.mdwn", "w") as of:
+    #    pinout, bankspec, pin_spec, fixedpins = ps.write(of)
+    #print("---------------------------------")
+
+    bk = ps.pinbanks.keys()
+    for bank in bk:
+        muxwidth = ps.muxwidths[bank]
+        print(bank, muxwidth)
+        pinidx = sorted(ps.keys())
+        for pin in pinidx:
+            print("---------------------------------")
+            print(pin)
+            pdata = ps.get(pin)
+            for mux in range(muxwidth):
+                if mux not in pdata:
+                    print("Mux %d : NC" % mux)
+                else:
+                    name, assigned_bank = pdata[mux]
+                    print("Mux %d : %s" % (mux, name))
+
+
+