Program for loading code into LPC1768 on a costum PCB

Dependencies:   mbed

Files at this revision

API Documentation at this revision

Comitter:
DaniusKalv
Date:
Tue Mar 10 15:24:36 2015 +0000
Commit message:
In system programming code

Changed in this revision

main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r ba450e9d7f56 main.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Mar 10 15:24:36 2015 +0000
@@ -0,0 +1,62 @@
+#include "mbed.h"
+
+DigitalOut led1(LED1);
+DigitalOut led2(LED2);
+
+Serial pc (USBTX,USBRX);
+Serial target (p28,p27);
+
+// We'll drive this low, and then set the as inputs
+// this mimics an open collector style ouput
+DigitalInOut reset (p29);
+DigitalInOut isp   (p30);
+
+int main() {
+
+    pc.baud(115200);
+    target.baud(115200);
+   
+    // ISP Input with pullup
+    pc.printf("Ready!\r\n");
+    isp.input();
+    isp.mode(PullUp);
+
+    // pulse reset low
+    reset.output();
+    reset = 0;
+    wait (0.01);
+    
+    // reset input, with pullup
+    reset.input();
+    reset.mode(PullUp);
+    
+    while (!pc.readable()) {}   
+   
+    // pull ISP and nReset low
+    reset.output();
+    isp.output();
+    reset = 0;
+    isp = 0;
+    
+    wait (0.1);
+    
+    // Bring target out of reset
+    reset.input();
+    reset.mode(PullUp);
+    
+    wait (0.1);
+
+    while (1) {
+    
+        if (pc.readable()) {
+            target.putc(pc.getc());
+            led1 = !led1;
+        }
+    
+        if (target.readable()) {
+            pc.putc(target.getc());
+            led2 = !led2;
+        }
+    
+    }
+}
\ No newline at end of file
diff -r 000000000000 -r ba450e9d7f56 mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Mar 10 15:24:36 2015 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/031413cf7a89
\ No newline at end of file