CVS: libraries/mspgcc flash_lock.c,NONE,1.1 flash_erase_segment.c,1.1,1.2

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

Modified Files:
	flash_erase_segment.c 
Added Files:
	flash_lock.c 
Log Message:
add support function for F2xx devices SegmentA lock

--- NEW FILE: flash_lock.c ---

#include <signal.h>
#include <msp430/flash.h>

// this function is used to lock or unlock SegmentA on F2xx devices
// note that the LOCKA bit is toggled by writing a one, so this code ensures
// the desired state by toggling it if needed.
critical void flash_lock_segmentA(int lock) {
    if (lock) {
        // Lock SegmentA (ensure that LOCKA is set)
        if ((FCTL3 & LOCKA) == 0) {     // Test LOCKA, is it already locked?
            FCTL3 = FWKEY|LOCKA;        // No, lock SegmentA
        }
    } else {
        // Unlock SegmentA (ensure that LOCKA is cleared)
        if (FCTL3 & LOCKA) {            // Test LOCKA, is it already un locked?
            FCTL3 = FWKEY|LOCKA;        // No, unlock SegmentA
        }
    }
}

Index: flash_erase_segment.c
===================================================================
RCS file: /cvsroot/mspgcc/libraries/mspgcc/flash_erase_segment.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -w -d -r1.1 -r1.2
--- flash_erase_segment.c	22 Aug 2005 11:23:20 -0000	1.1
+++ flash_erase_segment.c	27 Dec 2005 22:00:08 -0000	1.2
@@ -3,6 +3,9 @@
 #include <msp430/flash.h>
 
 // FCTL2 must be initialized by the user
+// this function cannot directly be used to erase SegmentA on F2xx devices
+// the LOCKA bit has to be cleared before calling thing function.
+// see also flash_lock.c
 critical void flash_erase_segment(void *address) {
     FCTL3 = FWKEY;                      // unlock
     FCTL1 = FWKEY|ERASE;                // select segment erase



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