CVS: python/msp430 bsl.py,1.6,1.7

Chris Liechti <[email protected]>
Newsgroups gmane.comp.hardware.texas-instruments.msp430.gcc.cvs
Message-ID <[email protected]>
Update of /cvsroot/mspgcc/python/msp430
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv9252/python/msp430

Modified Files:
	bsl.py 
Log Message:
- added --swap-reset-test option
- added --test-on-tx option
- added option to ignore answers from the BSL and just wait a little
- fix for slowmode

Index: bsl.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430/bsl.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -u -w -d -r1.6 -r1.7
--- bsl.py	12 Nov 2004 22:27:39 -0000	1.6
+++ bsl.py	14 Jun 2005 09:42:38 -0000	1.7
@@ -265,10 +265,13 @@
         #used for some hardware
         self.invertRST = 0
         self.invertTEST = 0
+        self.swapResetTest = 0
+        self.testOnTX = 0
+        self.ignoreAnswer = 0
         
         self.protocolMode = self.MODE_BSL
         self.BSLMemAccessWarning = 0            #Default: no warning.
-        self.slowmode = 0                       #give a little time when changing the control lines
+        self.slowmode = 0                       #give a little more time when changing the control lines
 
     def comInit(self, port):
         """Tries to open the serial port given and
@@ -405,6 +408,9 @@
             if DEBUG > 1: sys.stderr.write( "  comTxRx() transmit OK\n")
 
         #Receiving part -------------------------------------------
+        if self.ignoreAnswer:
+            time.sleep(0.1)
+        else:
         rxHeader, rxNum = self.comRxHeader()        #receive header
         if DEBUG > 1: sys.stderr.write("  comTxRx() rxHeader=0x%02x, rxNum=%d, seqNo=%d, reqNo=%s\n" % (rxHeader, rxNum, self.seqNo, self.reqNo))
         if rxHeader == self.DATA_ACK:               #acknowledge/OK
@@ -431,10 +437,15 @@
 
     def SetRSTpin(self, level=1):
         """Controls RST/NMI pin (0: GND; 1: VCC; unless inverted flag is set)"""
+        #invert signal if configured
         if self.invertRST:
-            self.serialport.setDTR(not level)
+            level = not level
+        #set pin level
+        if self.swapResetTest:
+            self.serialport.setRTS(level)
         else:
             self.serialport.setDTR(level)
+        #add some delay
         if self.slowmode:
             time.sleep(0.200)
         else:
@@ -442,10 +453,22 @@
 
     def SetTESTpin(self, level=1):
         """Controls TEST pin (inverted on board: 0: VCC; 1: GND; unless inverted flag is set)"""
+        #invert signal if configured
         if self.invertTEST:
-            self.serialport.setRTS(not level)
+            level = not level
+        #set pin level
+        if self.swapResetTest:
+            self.serialport.setDTR(level)
         else:
             self.serialport.setRTS(level)
+        #make TEST signal on TX pin, unsing break condition.
+        #currently only working on win32!
+        if self.testOnTX:
+            if level:
+                serial.win32file.ClearCommBreak(self.serialport.hComPort)
+            else:
+                serial.win32file.SetCommBreak(self.serialport.hComPort)
+        #add some delay
         if self.slowmode:
             time.sleep(0.200)
         else:
@@ -475,6 +498,9 @@
             self.SetTESTpin(1)  #TEST pin: GND
             self.SetTESTpin(0)  #TEST pin: Vcc
             self.SetRSTpin (1)  #RST  pin: Vcc
+            if self.testOnTX:
+                serial.win32file.ClearCommBreak(self.serialport.hComPort)
+            else:
             self.SetTESTpin(1)  #TEST pin: GND
         else:
             self.SetRSTpin(1)   #RST  pin: Vcc
@@ -490,6 +516,9 @@
         loopcnt = 3                                 #Max. tries to get synchronization
 
         if DEBUG > 1: sys.stderr.write("* bslSync(wait=%d)\n" % wait)
+        if self.ignoreAnswer:
+            self.serialport.write(chr(self.BSL_SYNC))   #Send synchronization byte
+        else:
         while wait or loopcnt:
             loopcnt = loopcnt - 1                   #count down tries
             self.serialport.flushInput()            #clear input, in case a prog is running
@@ -583,6 +612,7 @@
         self.maxData        = self.MAXDATA
         self.cpu            = None
         self.showprogess    = 0
+        self.retrasnmitPasswd = 1
 
 
     def preparePatch(self):
@@ -669,7 +699,7 @@
             pstart = 0
             count = 0
             while pstart<len(seg.data):
-                length = self.MAXDATA
+                length = self.maxData
                 if pstart+length > len(seg.data):
                     length = len(seg.data) - pstart
                 self.programBlk(currentAddr, seg.data[pstart:pstart+length], action)
@@ -879,6 +909,7 @@
         self.patchLoaded   = 0
 
         #Re-send password to re-gain access to protected functions.
+        if self.retrasnmitPasswd:
         self.txPasswd(self.passwd)
 
         #update version info



-------------------------------------------------------
This SF.Net email is sponsored by: NEC IT Guy Games.  How far can you shotput
a projector? How fast can you ride your desk chair down the office luge track?
If you want to score the big prize, get to know the little guy.  
Play to win an NEC 61" plasma display: http://www.necitguy.com/?r=20
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.