CVS: python/msp430 jtag.py,1.13,1.14

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-serv17021/python/msp430

Modified Files:
	jtag.py 
Log Message:
- add the ability to run funclets for a given time
- new function MSP430_FuncletWait, internal API changes for executeCode
- add a counter funclet (can be used to determine DCO frequency)
- update msp430-jtag with the new feature

Index: jtag.py
===================================================================
RCS file: /cvsroot/mspgcc/python/msp430/jtag.py,v
retrieving revision 1.13
retrieving revision 1.14
diff -u -w -d -r1.13 -r1.14
--- jtag.py	23 Dec 2005 02:23:54 -0000	1.13
+++ jtag.py	27 Dec 2005 01:12:11 -0000	1.14
@@ -117,15 +117,24 @@
         MSP430_WriteRegister            = MSP430mspgcc.MSP430_WriteRegister
         MSP430_WriteRegister.argtypes   = [ctypes.c_long, ctypes.c_long]
         MSP430_WriteRegister.restype    = ctypes.c_int
-        MSP430_Funclet                  = MSP430mspgcc.MSP430_Funclet
-        MSP430_Funclet.argtypes         = [ctypes.c_char_p, ctypes.c_long, ctypes.c_int, ctypes.c_int]
-        MSP430_Funclet.restype          = ctypes.c_int
+    except AttributeError:
+        #TI's USB-FET lib does not have this function
+        if DEBUG:
+            sys.stderr.write('MSP430_*Register not found in library. not supported.\n')
+    try:
+        #~ MSP430_Funclet                  = MSP430mspgcc.MSP430_Funclet
+        #~ MSP430_Funclet.argtypes         = [ctypes.c_char_p, ctypes.c_long, ctypes.c_int, ctypes.c_int]
+        #~ MSP430_Funclet.restype          = ctypes.c_int
+        MSP430_FuncletWait              = MSP430mspgcc.MSP430_FuncletWait
+        MSP430_FuncletWait.argtypes     = [ctypes.c_char_p, ctypes.c_long, ctypes.c_int, ctypes.c_ulong, ctypes.POINTER(ctypes.c_ulong)]
+        MSP430_FuncletWait.restype      = ctypes.c_int
         MSP430_isHalted                 = MSP430mspgcc.MSP430_isHalted
         MSP430_isHalted.argtypes        = []
         MSP430_isHalted.restype         = ctypes.c_int
     except AttributeError:
         #TI's USB-FET lib does not have this function
-        pass
+        if DEBUG:
+            sys.stderr.write('MSP430_Funclet and isHalted not found in library. not supported.\n')
     
     messagecallback = ctypes.CFUNCTYPE(ctypes.c_int, ctypes.c_short, ctypes.c_short) #void f(WORD count, WORD total)
 
@@ -224,19 +233,22 @@
             if status != STATUS_OK:
                 raise IOError("Could not erase the Flash")
 
-        def funclet(self, code):
+        def funclet(self, code, timeout=1):
             """Download a 'funclet' contained in the string 'code' to the target
             and execute it. This function waits until the code stops on a "jmp $"
             or a timeout.
             Please refer to the 'funclet' documentation for the contents of the
-            code string."""
+            code string.
+            return the runtime in seconds"""
+            runtime = ctypes.c_ulong()
             size = len(code)
             if size & 1:
                 raise ValueError("data must be of even size")
             
-            status = MSP430_Funclet(code, size, 1, 1)
+            status = MSP430_FuncletWait(code, size, 1, int(timeout*1000), ctypes.byref(runtime))
             if status != STATUS_OK:
                 raise IOError("Could not execute code")
+            return runtime.value/1000.0
 
         def configure(self, mode, value = 0):
             """Configure the MSP430 driver."""
@@ -414,17 +426,20 @@
         raise NotImplementedError
         #sys.stderr.write("Load PC with 0x%04x ...\n" % address)
 
-    def actionFunclet(self):
-        """Download and start funclet"""
+    def actionFunclet(self, timeout=1):
+        """Download and start funclet. timeout in seconds"""
         if self.data is not None:
             if self.verbose:
                 sys.stderr.write("Download and execute funclet...\n")
                 sys.stderr.flush()
             if len(self.data) != 1:
                 raise JTAGException("Funclets must have exactly one segment")
-            _parjtag.funclet(self.data[0].data)
+            runtime = _parjtag.funclet(self.data[0].data, timeout)
+            if runtime >= timeout:
+                sys.stderr.write("Funclet stopped on timeout\n")
+                sys.stderr.flush()
             if self.verbose:
-                sys.stderr.write("Funclet OK.\n")
+                sys.stderr.write("Funclet OK (%.2fs).\n" % (runtime,))
                 sys.stderr.flush()
         else:
             raise JTAGException("No funclet available, set data")



-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems?  Stop!  Download the new AJAX search engine that makes
searching your log files as easy as surfing the  web.  DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
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.