WIP
authorDan White <dan@whiteaudio.com>
Sun, 13 May 2012 01:53:07 +0000 (20:53 -0500)
committerDan White <dan@whiteaudio.com>
Sun, 13 May 2012 01:53:07 +0000 (20:53 -0500)
python-lib/mpsse-test.py
python-lib/usbio.py

index 79c7f0b3c982f9245ac8520a5415c7f482e4ad02..a71b5573880d0ff28a0719c7f981897cf217ce56 100755 (executable)
@@ -111,6 +111,7 @@ for i in range(5, 8):
 ##############################################################################
 # ADC
 # (TODO)
+# see 'ADC testing stuff' section below
 #
 adc = usbio.ADS8201(spi0)
 
@@ -166,7 +167,7 @@ for h in arb.h:
         ota.fast = 1
         ota.gain = 8
         ota.offset = 0
-#arb.write()
+arb.write()
 
 amux.selA = 48
 amux.selB = 48
@@ -175,7 +176,7 @@ for ota in amux.ota:
     ota.fast = 1
     ota.gain = 8
     ota.offset = 0
-#amux.write()
+amux.write()
 
 
 
@@ -227,44 +228,53 @@ if 0:
         r.append(v)
         print x, v
 
-    figure()
-    plot(n, r)
-    xlabel('DAC code')
-    ylabel('ADC count')
-    title('DAC_ch0 --> ADC_ch4 direct connection')
-    savefig('dac-adc-loopback.pdf')
-    show()
+    if 0:
+        figure()
+        plot(n, r)
+        xlabel('DAC code')
+        ylabel('ADC count')
+        title('DAC_ch0 --> ADC_ch4 direct connection')
+        savefig('dac-adc-loopback.pdf')
+        show()
 
 
 
 ##############################################################################
 # Flash testing
 #
-flash = usbio.M25PExx(spi0)
-flash.power(True)
-print flash.status()
-print 'id:', str2hex(flash.id())
-print flash.status()
-print 'data:', str2hex(flash.read(0x4000, 16))
-
-flash.writeEnable(True)
-
-from intelhex import IntelHex
-#h = IntelHex('../msp4th/hello-world.hex')
-h = IntelHex('../msp4th/x.hex')
-a = [a for a in h.addresses() if (a >= 0x4000 and a < 0xf000)]
-alen = max(a) - min(a)
-#code = ''.join([chr(h[i]) for i in range(0x4000, 0x10000-2)])
-code = h.gets(0x4000, alen)
-#code = 0*'\x00' + code + '\x00\x40'
-flash.write(min(a), code)
-
-vectors = ''.join([chr(h[i]) for i in range(0xff00, 0x10000-2)])
-vectors += '\x00\x40'
-flash.write(0xff00, vectors)
-
-while not flash.isReady():
-    print 'waiting...'
+if 0:
+    flash = usbio.M25PExx(spi0)
+    flash.power(True)
+    print flash.status()
+    print 'id:', str2hex(flash.id())
+    print flash.status()
+    print 'data:', str2hex(flash.read(0x4000, 16))
+
+    flash.writeEnable(True)
+
+    from intelhex import IntelHex
+    #h = IntelHex('../msp4th/hello-world.hex')
+    h = IntelHex('../msp4th/x.hex')
+
+    #code space in RAM, only get/send used block of bytes
+    a = [a for a in h.addresses() if (a >= 0x4000 and a < 0xff00)]
+    alen = max(a) - min(a)
+    code = h.gets(0x4000, alen)
+    flash.write(min(a), code)
+
+    # 0xffd0 -- 0xffff are interrupt vectors
+    # gcc et.al. for some reason do not give a value for 0xfffe word
+    #   the flash loader in ROM jumps to addr pointed here
+    #   force to start of RAM
+    #
+    # the flash uses 256-byte pages, include code from 0xff00 - 0xffcf
+    # as it was excluded above
+    vectors = ''.join([chr(h[i]) for i in range(0xff00, 0x10000-2)])
+    vectors += '\x00\x40'
+    flash.write(0xff00, vectors)
+
+    while not flash.isReady():
+        print 'waiting...'
 
 if 0:
     nread = 0
index 9878dc4c896a041359934854b55fe0434eee53dc..a3d4fb83f4ef13c1407b4e6efb6524cf75612e7c 100644 (file)
@@ -250,11 +250,11 @@ class I2C(object):
 
     def pinState(self, bitfield):
         """Set GPIO pins to given bitfield state, ignoring scl/sda pins."""
-        b = intbv(bitfield, max=2**8)
-        b[self.scl] = self.io[self.scl]
-        b[self.sda] = self.io[self.sda]
+        bits = intbv(bitfield, max=2**8)
+        bits[self.scl] = self.io[self.scl]
+        bits[self.sda] = self.io[self.sda]
         print 'port:', b(self.port, 8), '-->',
-        self.port[:] = d
+        self.port[:] = bits
         print b(self.port, 8)
         ftdi.write_data(self.context, chr(self.port), 1)