Dependencies:   mbed

Revision:
1:659c8f87b4bc
Parent:
0:5fbb38eaed90
Child:
2:b7a8bbb38e2f
--- a/main.cpp	Wed Mar 16 00:40:13 2011 +0000
+++ b/main.cpp	Wed Mar 16 01:36:35 2011 +0000
@@ -31,10 +31,10 @@
    it and experience odd problems, try raising it a bit higher.
    ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 #define CELL          int16_t
-#define IMAGE_SIZE      15000
+#define IMAGE_SIZE      14000              /* This can be raised to 15k */
 #define ADDRESSES         256
 #define STACK_DEPTH        50
-#define PORTS              12
+#define PORTS              13
 #define MAX_FILE_NAME      48
 #define MAX_ENV_QUERY       1
 #define MAX_OPEN_FILES      4
@@ -258,6 +258,12 @@
   DROP; DROP;
 }
 
+/* mbed devices ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+DigitalOut L1(LED1);
+DigitalOut L2(LED2);
+DigitalOut L3(LED3);
+DigitalOut L4(LED4);
+
 /* Device I/O Handler ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 void handle_devices(VM *vm) {
   if (vm->ports[0] != 1) {
@@ -337,6 +343,27 @@
         default:  vm->ports[5] = 0;
       }
     }
+
+    /* mbed io devices */
+    if (vm->ports[12] != 0) {
+      vm->ports[0] = 1;
+      switch (vm->ports[12]) {
+        case  1: L1 = TOS; DROP;
+                 vm->ports[12] = 0;
+                 break;
+        case  2: L2 = TOS; DROP;
+                 vm->ports[12] = 0;
+                 break;
+        case  3: L3 = TOS; DROP;
+                 vm->ports[12] = 0;
+                 break;
+        case  4: L4 = TOS; DROP;
+                 vm->ports[12] = 0;
+                 break;
+        default: vm->ports[12] = 0;
+      }
+    }
+
   }
 }
 
@@ -548,7 +575,7 @@
   vm->ports[3] = 1;
 }
 
-/* Main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
+/* Main ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ */
 int main(int argc, char **argv)
 {
   VM static vmm;