Chipcon peek and poke for iram, include SFRs.
authortravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Fri, 6 Nov 2009 04:51:41 +0000 (04:51 +0000)
committertravisutk <travisutk@12e2690d-a6be-4b82-a7b7-67c4a43b65c8>
Fri, 6 Nov 2009 04:51:41 +0000 (04:51 +0000)
git-svn-id: https://svn.code.sf.net/p/goodfet/code/trunk@224 12e2690d-a6be-4b82-a7b7-67c4a43b65c8

client/GoodFETCC.py
client/goodfet.cc
firmware/apps/chipcon/chipcon.c
firmware/include/chipcon.h

index d5208bd..e2f28e6 100644 (file)
@@ -106,6 +106,17 @@ class GoodFETCC(GoodFET):
         self.data=[adr&0xff, (adr&0xff00)>>8];
         self.writecmd(0x30,0x91, 2, self.data);
         return ord(self.data[0]);
         self.data=[adr&0xff, (adr&0xff00)>>8];
         self.writecmd(0x30,0x91, 2, self.data);
         return ord(self.data[0]);
+    def CCpeekirambyte(self,adr):
+        """Read the contents of IRAM at an address."""
+        self.data=[adr&0xff];
+        self.writecmd(0x30,0x02, 1, self.data);
+        return ord(self.data[0]);
+    def CCpokeirambyte(self,adr,val):
+        """Write the contents of IRAM at an address."""
+        self.data=[adr&0xff, val&0xff];
+        self.writecmd(0x30,0x02, 2, self.data);
+        return ord(self.data[0]);
+    
     def CCpokedatabyte(self,adr,val):
         """Write a byte to data memory."""
         self.data=[adr&0xff, (adr&0xff00)>>8, val];
     def CCpokedatabyte(self,adr,val):
         """Write a byte to data memory."""
         self.data=[adr&0xff, (adr&0xff00)>>8, val];
index 6d8eed1..d79d166 100755 (executable)
@@ -97,7 +97,13 @@ if(sys.argv[1]=="peekinfo"):
     while start<=stop:
         print "%04x: %02x" % (start,client.CCpeekcodebyte(start));
         start=start+1;
     while start<=stop:
         print "%04x: %02x" % (start,client.CCpeekcodebyte(start));
         start=start+1;
-
+if(sys.argv[1]=="peek"):
+    print "%02x" % client.CCpeekirambyte(int(sys.argv[2],16));
+if(sys.argv[1]=="poke"):
+    client.CCpokeirambyte(int(sys.argv[2],16),
+                          int(sys.argv[3],16));
+if(sys.argv[1]=="randtest"):
+    print "coming soon"
 if(sys.argv[1]=="config"):
     print "Config is %02x" % client.CCrd_config();
 
 if(sys.argv[1]=="config"):
     print "Config is %02x" % client.CCrd_config();
 
index 0b883db..00182f0 100644 (file)
@@ -132,6 +132,14 @@ void cchandle(unsigned char app,
   
   switch(verb){
     //CC_PEEK and CC_POKE will come later.
   
   switch(verb){
     //CC_PEEK and CC_POKE will come later.
+  case PEEK:
+    cmddata[0]=cc_peekirambyte(cmddata[0]);
+    txdata(app,verb,1);
+    break;
+  case POKE:
+    cmddata[0]=cc_pokeirambyte(cmddata[0],cmddata[1]);
+    txdata(app,verb,0);
+    break;
   case READ:  //Write a command and return 1-byte reply.
     cccmd(len);
     ccread(1);
   case READ:  //Write a command and return 1-byte reply.
     cccmd(len);
     ccread(1);
@@ -556,3 +564,16 @@ unsigned char cc_peekdatabyte(unsigned int adr){
 }
 
 
 }
 
 
+//! Fetch a byte of IRAM.
+u8 cc_peekirambyte(u8 adr){
+  //MOV A, #iram
+  return cc_debug(3, 0xE5, adr, 0);
+}
+
+//! Write a byte of IRAM.
+u8 cc_pokeirambyte(u8 adr, u8 val){
+  //MOV #iram, #val
+  return cc_debug(3, 0x75, adr, val);
+}
+
+
index 3bf3da1..bf471e6 100644 (file)
@@ -39,6 +39,10 @@ void cc_debug_instr(unsigned char);
 unsigned char cc_peekcodebyte(unsigned long adr);
 //!Read a byte of data memory.
 unsigned char cc_peekdatabyte(unsigned int adr);
 unsigned char cc_peekcodebyte(unsigned long adr);
 //!Read a byte of data memory.
 unsigned char cc_peekdatabyte(unsigned int adr);
+//! Fetch a byte of IRAM.
+u8 cc_peekirambyte(u8 adr);
+//! Write a byte of IRAM.
+u8 cc_pokeirambyte(u8 adr, u8 val);
 //! Set a byte of data memory.
 unsigned char cc_pokedatabyte(unsigned int adr,
                              unsigned char val);
 //! Set a byte of data memory.
 unsigned char cc_pokedatabyte(unsigned int adr,
                              unsigned char val);