This program is just a simple serial port program for communication with mbedWrapper

Dependencies:   AndroidAccessory mbed

Files at this revision

API Documentation at this revision

Comitter:
p07gbar
Date:
Tue Aug 02 10:56:10 2011 +0000
Commit message:
Initial

Changed in this revision

AndroidAccessory.lib Show annotated file Show diff for this revision Revisions of this file
demokit.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 4be11cf8cf0c AndroidAccessory.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/AndroidAccessory.lib	Tue Aug 02 10:56:10 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/p07gbar/code/AndroidAccessory/#98fbe1660f0a
diff -r 000000000000 -r 4be11cf8cf0c demokit.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/demokit.cpp	Tue Aug 02 10:56:10 2011 +0000
@@ -0,0 +1,118 @@
+/*
+ * ADKTerm
+ * 
+ * Written by p07gbar
+ * 
+ * This program is just a simple serial port program for comunication with mbedWrapper
+ */
+#include "mbed.h"
+#include "AndroidAccessory.h"
+
+
+#define OUTL 100
+#define INBL 100
+
+
+
+
+
+class AdkTerm :public AndroidAccessory {
+public:
+    AdkTerm():AndroidAccessory(INBL,OUTL,
+                                       "ARM",
+                                       "mbed",
+                                       "mbed Terminal",
+                                       "0.1",
+                                       "http://www.mbed.org",
+                                       "0000000012345678"),pc(USBTX,USBRX) {};
+    virtual int callbackRead(u8 *buff, int len);
+    virtual void setupDevice();
+    virtual void resetDevice();
+    virtual int callbackWrite();
+
+private:
+    void serialIRQ();
+    char buffer[OUTL];
+    int bcount;
+    Serial pc;
+};
+
+
+
+void AdkTerm::setupDevice() {
+    pc.printf("Welcome to adkTerm\n\n\n\n\n\n\r");
+    pc.attach(this, &AdkTerm::serialIRQ, Serial::RxIrq);
+    for (int i = 0; i<OUTL; i++) {
+        buffer[i] = 0;
+    }
+    bcount = 0;
+
+}
+
+
+void AdkTerm::resetDevice() {
+    pc.printf("adkTerm reset\n\r");
+    for (int i = 0; i<OUTL; i++) {
+        buffer[i] = 0;
+    }
+    bcount = 0;
+}
+
+int AdkTerm::callbackRead(u8 *buf, int len) {
+    pc.printf("%i  %s\n\r\n\n\n",len,buf);
+    for (int i = 0; i<INBL;i++) {
+        buf[i] = 0;
+    }
+    return 0;
+}
+
+int AdkTerm::callbackWrite() {
+    pc.printf("DoneWrite\n\r");
+    
+    return 0;
+}
+
+
+void AdkTerm::serialIRQ() {
+    buffer[bcount] = pc.getc();
+    pc.putc(buffer[bcount]);
+
+    if (buffer[bcount] == '\n' || buffer[bcount] == '\r') {
+        u8* wbuf = _writebuff;
+        for (int i = 0; i<OUTL; i++) {
+            wbuf[i] = buffer[i];
+            buffer[i] = 0;
+        }
+        pc.printf("Sending: %s\n\r",wbuf);
+        
+        this->write(wbuf,bcount);
+        bcount = 0;
+    } else {
+        if (buffer[bcount] != 0x08 && buffer[bcount] != 0x7F ) {
+            bcount++;
+            if (bcount == OUTL) {
+                bcount = 0;
+            }
+        } else {
+        bcount--;
+        
+        }
+    }
+}
+
+
+
+AdkTerm AdkTerm;
+
+
+
+int main() {
+    printf("Android Development Kit: start\r\n");
+
+    AdkTerm.setupDevice();
+    USBInit();
+    while (1) {
+        USBLoop();
+    }
+
+}
diff -r 000000000000 -r 4be11cf8cf0c mbed.bld
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Aug 02 10:56:10 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912