- def MSP430writeflash(self,adr,val):
- """Write a word of flash memory."""
- if(self.MSP430peek(adr)!=0xFFFF):
- print "FLASH ERROR: %04x not clear." % adr;
- data=[adr&0xFF,(adr&0xFF00)>>8,val&0xFF,(val&0xFF00)>>8];
- self.writecmd(self.MSP430APP,0xE1,4,data);
- rval=ord(self.data[0])+(ord(self.data[1])<<8);
- if(val!=rval):
- print "FLASH WRITE ERROR AT %04x. Found %04x, wrote %04x." % (adr,rval,val);
-
+ def MSP430infoerase(self):
+ """Erase MSP430 info flash."""
+ self.writecmd(self.MSP430APP,0xE8,0,None);
+
+ def MSP430setPC(self, pc):
+ """Set the program counter."""
+ self.writecmd(self.MSP430APP,0xC2,2,[pc&0xFF,(pc>>8)&0xFF]);
+ def MSP430setreg(self,reg,val):
+ """Set a register."""
+ self.writecmd(self.MSP430APP,0xD2,3,[reg,val&0xFF,(val>>8)&0xFF]);
+ def MSP430getreg(self,reg):
+ """Get a register."""
+ self.writecmd(self.MSP430APP,0xD3,1,[reg]);
+ return ord(self.data[0])+(ord(self.data[1])<<8);
+
+ def MSP430run(self):
+ """Reset the MSP430 to run on its own."""
+ self.writecmd(self.MSP430APP,0x21,0,None);