CVS: jtag/msp430 MSP430mspgcc.c,1.12,1.13 funclets.c,1.11,1.12 funclets.h,1.8,1.9

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

Modified Files:
	MSP430mspgcc.c funclets.c funclets.h 
Log Message:
- autodetect ramsize if it is not given

Index: MSP430mspgcc.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/MSP430mspgcc.c,v
retrieving revision 1.12
retrieving revision 1.13
diff -u -w -d -r1.12 -r1.13
--- MSP430mspgcc.c	27 Dec 2005 13:48:50 -0000	1.12
+++ MSP430mspgcc.c	27 Dec 2005 16:20:03 -0000	1.13
@@ -16,11 +16,12 @@
 
 // #defines. ------------------------------------------------------------------
 
-#define DLL_VERSION         04      // DLL version * 10.
+#define DLL_VERSION             4      // DLL version.
 
 // (File) Global variables. ---------------------------------------------------
 static BOOL jtagReleased = FALSE;
-static BOOL frequencySet = FALSE;      // remenber if the DCO setup was done
+static BOOL frequencySet = FALSE;      // remember if the DCO setup was done
+static BOOL ramsizeAutodetect = TRUE;  // remember if the ram size detection has to be run
 unsigned int debug_level = 0;
 
 static const char* errorStrings[] = {
@@ -144,11 +145,12 @@
             break;
         case RAMSIZE_OPTION:
             ramsize = value;
+            ramsizeAutodetect = FALSE;
             MSP430_Log(1, "MSP430mspgcc: Changing RAMSIZE to %d\n", ramsize);
             break;
         case DEBUG_OPTION:
             debug_level = value;
-            MSP430_Log(1, "MSP430mspgcc: Debug level set to %d\n", value);
+            MSP430_Log(1, "MSP430mspgcc: Debug level set to %d\n", debug_level);
             break;
         case FLASH_CALLBACK:
             flash_callback = (void *)value;
@@ -156,7 +158,6 @@
             break;
         default:
             RET_ERR(PARAMETER_ERR);
-            //~ break;
     }
     RET_OK;
 }
@@ -207,7 +208,24 @@
 STATUS_T WINAPI MSP430_Open(void) {
     MSP430_Log(1, "MSP430mspgcc: MSP430_Open...\n");
     if (HIL_Open() == STATUS_OK) {      // Enable the JTAG interface to the device.
-        return MSP430_Reset(RST_RESET|VCC_RESET, FALSE, FALSE); //needs a reset method with GetDevice
+        if (STATUS_OK == MSP430_Reset(RST_RESET|VCC_RESET, FALSE, FALSE)) { //needs a reset method with GetDevice
+            //ramsize has to detected
+            if (ramsizeAutodetect) {
+                if (STATUS_OK == detectRAMsize(&ramsize)) {
+                    if (128 <= ramsize && ramsize <= 2048) {
+                        MSP430_Log(0, "MSP430mspgcc: MSP430_Open: RAM size autodetected: %u Bytes\n", ramsize);
+                    } else {
+                        ramsize = 256;      // use a default
+                        MSP430_Log(0, "MSP430mspgcc: MSP430_Open: RAM size detect failed, using a default of %u Bytes\n", ramsize);
+                    }
+                } else {
+                    ramsize = 256;      // use a default
+                    MSP430_Log(0, "MSP430mspgcc: MSP430_Open: RAM size could not be detected, using a default of %u Bytes\n", ramsize);
+                }
+            }
+            return STATUS_OK;
+        }
+        return STATUS_ERROR;
     } else {
         RET_ERR(NO_DEVICE_ERR);
     }

Index: funclets.c
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/funclets.c,v
retrieving revision 1.11
retrieving revision 1.12
diff -u -w -d -r1.11 -r1.12
--- funclets.c	27 Dec 2005 13:48:50 -0000	1.11
+++ funclets.c	27 Dec 2005 16:20:03 -0000	1.12
@@ -174,6 +174,29 @@
 }
 
 // ----------------------------------------------------------------------------
+#include "ramsizeDetect.ci"                                     //include the counter program
+
+/**
+ * Probe RAM size.
+ *
+ * @param ramsize       [out] number of bytes in the RAM
+ * @return              STATUS_OK if the measurement succeeded
+ */
+STATUS_T detectRAMsize(WORD *ramsize) {
+    MSP430_Log(2, "funclets: detectRAMsize\n");
+    if (ramsize == NULL) return STATUS_ERROR;
+    if (STATUS_OK == executeCode(funclet_ramsizeDetect, sizeof(funclet_ramsizeDetect)/sizeof(WORD), 1, 100, NULL)) {
+        WORD detected_ramsize;
+        if (STATUS_OK == GetReg(15, &detected_ramsize)) {
+            *ramsize = detected_ramsize;
+            MSP430_Log(3, "funclets: detectRAMsize: %u Bytes\n", detected_ramsize);
+            return STATUS_OK;
+        }
+    }
+    return STATUS_ERROR;
+}
+
+// ----------------------------------------------------------------------------
 
 //The following functions were originaly developed by TI. I added debug
 //outputs and simpified some parts

Index: funclets.h
===================================================================
RCS file: /cvsroot/mspgcc/jtag/msp430/funclets.h,v
retrieving revision 1.8
retrieving revision 1.9
diff -u -w -d -r1.8 -r1.9
--- funclets.h	27 Dec 2005 13:48:50 -0000	1.8
+++ funclets.h	27 Dec 2005 16:20:03 -0000	1.9
@@ -9,6 +9,7 @@
 STATUS_T eraseFlash(WORD type, WORD address);
 STATUS_T getDCOFreq(CHAR DCOCTL, CHAR BCSCTL1, ULONG *frequency);
 STATUS_T getDCOPlusFreq(CHAR SCFI0, CHAR SCFI1, CHAR SCFQCTL, CHAR FLL_CTL0, CHAR FLL_CTL1, ULONG *frequency);
+STATUS_T detectRAMsize(WORD *ramsize);
 STATUS_T syncCPU(void);
 STATUS_T executeCode(const WORD* code, WORD sizeCode, BOOL verify, ULONG wait, ULONG *runtime);
 int isHalted(void);



-------------------------------------------------------
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.