Browse Source

Implement C and G commands

Pretty straightforward.  copy_ram_to_flash is a simple binding for the C
command, and go is a binding for G that defaults to address 0 and mode
b"T".
Clara Hobbs 7 years ago
parent
commit
88be5395d6
1 changed files with 19 additions and 1 deletions
  1. 19
    1
      alpaca_isp/__init__.py

+ 19
- 1
alpaca_isp/__init__.py View File

@@ -168,7 +168,7 @@ class LPC:
168 168
 
169 169
     def write_ram(self, start, data, count=None):
170 170
         """Write count bytes from data to RAM at the given start address
171
-        
171
+
172 172
         Start and count must be multiples of four.  If count is not specified,
173 173
         len(data) is used.
174 174
         """
@@ -199,6 +199,24 @@ class LPC:
199 199
             end = start
200 200
         self._send_command("P {} {}\r\n".format(start, end).encode("utf-8"))
201 201
 
202
+    def copy_ram_to_flash(self, flash, ram, count):
203
+        """Copy count bytes from RAM to flash
204
+
205
+        The flash address should be a 64 byte boundary.  Count should be a
206
+        power of two in [64, 1024].
207
+        """
208
+        self._send_command("C {} {} {}\r\n".format(flash, ram, count).encode(
209
+            "utf-8"))
210
+
211
+    def go(self, address=0, mode=b"T"):
212
+        """Jump to the given address, in the given mode of execution
213
+
214
+        Of course, this function generally causes the ISP command handler to
215
+        stop running, so it is typically appropriate to follow this with a call
216
+        to LPC.close.
217
+        """
218
+        self._writeline("G {} {}\r\n".format(address, mode).encode("utf-8"))
219
+
202 220
 
203 221
 class ReturnCode(Enum):
204 222
     """LPC ISP return codes

Loading…
Cancel
Save