A project to implement a console using the Mbed using VGA for video output and a PS/2 keyboard for the input. The eventual goal is to also include tools for managing SD cards, and a semi-self-hosting programming environment.

Dependencies:   PS2_MbedConsole fastlib SDFileSystem vga640x480g_mbedconsole lightvm mbed

MbedConsole is a cool little project to have a self-contained computer all on an Mbed. So far it has VGA and PS/2 support and can stand alone without a computer powering it. Next planned features are SD card support and a lightweight programmable VM complete with a file editor and self-hosted assembler.

You can view additional details about it at http://earlz.net/tags/mbedconsole

Files at this revision

API Documentation at this revision

Comitter:
earlz
Date:
Mon Apr 15 02:37:02 2013 +0000
Parent:
19:8a94de51c61a
Commit message:
Finally got SD card support working. WOW that was trickier than I expected

Changed in this revision

SDFileSystem.lib Show annotated file Show diff for this revision Revisions of this file
main.cpp Show annotated file Show diff for this revision Revisions of this file
mbed.bld Show diff for this revision Revisions of this file
mbed.lib Show annotated file Show diff for this revision Revisions of this file
mbedconsole.h Show annotated file Show diff for this revision Revisions of this file
shell.cpp Show annotated file Show diff for this revision Revisions of this file
diff -r 8a94de51c61a -r 13556e5bac04 SDFileSystem.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/SDFileSystem.lib	Mon Apr 15 02:37:02 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/SDFileSystem/#c8f66dc765d4
diff -r 8a94de51c61a -r 13556e5bac04 main.cpp
--- a/main.cpp	Fri Apr 12 04:15:26 2013 +0000
+++ b/main.cpp	Mon Apr 15 02:37:02 2013 +0000
@@ -33,20 +33,23 @@
 #include "clock.h"
 #include "i2s.h"
 #include "nvic.h"
- 
+#include "SDFileSystem.h" 
+
+#define DEVICE_STDIO_MESSAGES
+#include "mbed_debug.h"
  
 PS2Keyboard *ps2kb;
 DigitalOut myled(LED1);
-
-
 Serial serial(USBTX, USBRX);
 ConsoleStream console("console");
+SDFileSystem *sdcard;
+
 
 void keyboard_init();
 
 int main() {
     serial.baud(9600);
-    serial.puts("Resetting interrupt priorities...");
+    serial.puts("Resetting interrupt priorities..\n");
     //Set all priorities to 100 so we are able to make VGA a priority
     //By default, all priorities are at their highest 0
     NVIC_SetPriority( NonMaskableInt_IRQn, 100 ); 
@@ -72,7 +75,7 @@
     NVIC_SetPriority(I2C0_IRQn, 100);
     NVIC_SetPriority(I2C1_IRQn, 100);
     NVIC_SetPriority(I2C2_IRQn, 100);
-    NVIC_SetPriority(SPI_IRQn, 100);
+    NVIC_SetPriority(SPI_IRQn, 1);
     NVIC_SetPriority(SSP0_IRQn, 100);
     NVIC_SetPriority(SSP1_IRQn, 100);
     NVIC_SetPriority(PLL0_IRQn, 100);
@@ -99,16 +102,25 @@
     keyboard_init();
     fl_select_clock_i2s(FL_CLOCK_DIV1); // assume 100MHz
     fl_i2s_set_tx_rate(1,4);            // set 25 MHz pixel clock 
-    
+
     
     NVIC_SetPriority( EINT3_IRQn, 90 ); 
     
+    //initialize way down here AFTER overclocking has already taken place
+    //Otherwise we end up with sdcard assume a different clockrate or something
+    wait(0.5); //MAGIC do not remove this wait statement. SD card won't work otherwise.
+    sdcard=new SDFileSystem(p11, p12, p13, p20, "sd");
+    
     freopen("/console", "w", stdout);
     setvbuf(stdout, NULL, _IONBF, 0);
     freopen("/console", "r", stdin);
-    //setvbuf(stdout, NULL, _IONBF, 0);
-    freopen("/console", "w", stderr);
+    setvbuf(stdout, NULL, _IONBF, 0);
+    //freopen("/console", "w", stderr);
     setvbuf(stderr, NULL, _IONBF, 0);
+    //serial.baud(9216);//9600);
+    
+    serial.puts("Entering main shell\n");
+    debug("testing... ");
     while(1)
     {
         vputs("mbedConsole by Jordan Earls\n");
diff -r 8a94de51c61a -r 13556e5bac04 mbed.bld
--- a/mbed.bld	Fri Apr 12 04:15:26 2013 +0000
+++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
@@ -1,1 +0,0 @@
-http://mbed.org/users/mbed_official/code/mbed/builds/cd19af002ccc
\ No newline at end of file
diff -r 8a94de51c61a -r 13556e5bac04 mbed.lib
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.lib	Mon Apr 15 02:37:02 2013 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/#5e5da4a5990b
diff -r 8a94de51c61a -r 13556e5bac04 mbedconsole.h
--- a/mbedconsole.h	Fri Apr 12 04:15:26 2013 +0000
+++ b/mbedconsole.h	Mon Apr 15 02:37:02 2013 +0000
@@ -35,6 +35,7 @@
 #include "mbed.h"
 #include "vga640x480g.h"
 #include "PS2Keyboard.h"
+#include "SDFileSystem.h"
 
 void vputc(char c);
 void vputs(char *s);
@@ -48,7 +49,7 @@
 
 extern PS2Keyboard *ps2kb;
 
-
+extern SDFileSystem *sdcard;
 
 extern Serial serial;
 
diff -r 8a94de51c61a -r 13556e5bac04 shell.cpp
--- a/shell.cpp	Fri Apr 12 04:15:26 2013 +0000
+++ b/shell.cpp	Mon Apr 15 02:37:02 2013 +0000
@@ -32,6 +32,9 @@
 #include "mbedconsole.h"
 #include "plEarlz.h"
 #include "PS2Keyboard.h"
+
+#include "SDFileSystem.h"
+
 char kbd_GetKey();
 
 LocalFileSystem local("local");
@@ -104,6 +107,21 @@
             while(1){
                 vputc(kbd_GetKey());
             }
+        }else if(strlcmp(cmd, "test3", 6) == 0)
+        {
+            //SDFileSystem sdcard(p11, p12, p13, p20, "sd");
+            FILE *fp = fopen("/sd/sdtest.txt", "w");
+            if(fp == NULL) {
+                vputs("Could not open file for write\n");
+            }
+            fprintf(fp, "Hello fun SD Card World!");
+            fclose(fp); 
+        }else if(strlcmp(cmd, "format", 7) == 0)
+        {
+            if(sdcard->format()!=0)
+            {
+                vputs("Error formatting :(");
+            }
         }else if(strlcmp(cmd, "plearlz", 8)==0){
             valid=1;
             pl_shell();