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

Committer:
earlz
Date:
Mon Apr 15 02:37:02 2013 +0000
Revision:
20:13556e5bac04
Parent:
18:83579e7dd1bc
Finally got SD card support working. WOW that was trickier than I expected

Who changed what in which revision?

UserRevisionLine numberNew contents of line
earlz 16:370b9e559f92 1 /*
earlz 16:370b9e559f92 2 <Copyright Header>
earlz 16:370b9e559f92 3 Copyright (c) 2012 Jordan "Earlz" Earls <http://lastyearswishes.com>
earlz 16:370b9e559f92 4 All rights reserved.
earlz 16:370b9e559f92 5
earlz 16:370b9e559f92 6 Redistribution and use in source and binary forms, with or without
earlz 16:370b9e559f92 7 modification, are permitted provided that the following conditions
earlz 16:370b9e559f92 8 are met:
earlz 16:370b9e559f92 9
earlz 16:370b9e559f92 10 1. Redistributions of source code must retain the above copyright
earlz 16:370b9e559f92 11 notice, this list of conditions and the following disclaimer.
earlz 16:370b9e559f92 12 2. Redistributions in binary form must reproduce the above copyright
earlz 16:370b9e559f92 13 notice, this list of conditions and the following disclaimer in the
earlz 16:370b9e559f92 14 documentation and/or other materials provided with the distribution.
earlz 16:370b9e559f92 15 3. The name of the author may not be used to endorse or promote products
earlz 16:370b9e559f92 16 derived from this software without specific prior written permission.
earlz 16:370b9e559f92 17
earlz 16:370b9e559f92 18 THIS SOFTWARE IS PROVIDED ``AS IS'' AND ANY EXPRESS OR IMPLIED WARRANTIES,
earlz 16:370b9e559f92 19 INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY
earlz 16:370b9e559f92 20 AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL
earlz 16:370b9e559f92 21 THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
earlz 16:370b9e559f92 22 EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
earlz 16:370b9e559f92 23 PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS;
earlz 16:370b9e559f92 24 OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY,
earlz 16:370b9e559f92 25 WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR
earlz 16:370b9e559f92 26 OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
earlz 16:370b9e559f92 27 ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
earlz 16:370b9e559f92 28
earlz 16:370b9e559f92 29 This file is part of the MbedConsole project
earlz 16:370b9e559f92 30 */
earlz 16:370b9e559f92 31
earlz 3:2bc2b0dce10e 32 #include "mbedconsole.h"
earlz 3:2bc2b0dce10e 33 #include "plEarlz.h"
earlz 9:4211d638b2e9 34 #include "PS2Keyboard.h"
earlz 20:13556e5bac04 35
earlz 20:13556e5bac04 36 #include "SDFileSystem.h"
earlz 20:13556e5bac04 37
earlz 10:bda85442b674 38 char kbd_GetKey();
earlz 3:2bc2b0dce10e 39
earlz 3:2bc2b0dce10e 40 LocalFileSystem local("local");
earlz 13:442bd2fb4ea0 41
earlz 18:83579e7dd1bc 42 /*
earlz 13:442bd2fb4ea0 43 void do_hackaday()
earlz 13:442bd2fb4ea0 44 {
earlz 13:442bd2fb4ea0 45 // int y=150;
earlz 13:442bd2fb4ea0 46 int tmp=0;
earlz 13:442bd2fb4ea0 47 for(int y=0;y<HACKADAY_HEIGHT;y++)
earlz 13:442bd2fb4ea0 48 {
earlz 13:442bd2fb4ea0 49 for(int x=0;x<HACKADAY_WIDTH;x++)
earlz 13:442bd2fb4ea0 50 {
earlz 13:442bd2fb4ea0 51 int byte=tmp/8;
earlz 13:442bd2fb4ea0 52 int bit=tmp%8;
earlz 13:442bd2fb4ea0 53 bit=bit-7; //bits are reversed! Those bastards!
earlz 13:442bd2fb4ea0 54 bit=-bit;
earlz 13:442bd2fb4ea0 55 vga_plot(x,y, (hackadaylogo[byte]&(1<<bit))==0);
earlz 13:442bd2fb4ea0 56 tmp++;
earlz 13:442bd2fb4ea0 57 }
earlz 13:442bd2fb4ea0 58 }
earlz 13:442bd2fb4ea0 59 }
earlz 18:83579e7dd1bc 60 */
earlz 3:2bc2b0dce10e 61 void shell_begin(){
earlz 18:83579e7dd1bc 62 //do_hackaday();
earlz 3:2bc2b0dce10e 63 vputs(">>Micro eMBEDded Shell v0.1<<\n");
earlz 3:2bc2b0dce10e 64 char *cmd=(char*)malloc(128);
earlz 3:2bc2b0dce10e 65 bool valid=false;
earlz 3:2bc2b0dce10e 66 while(1){
earlz 3:2bc2b0dce10e 67 vputs("> ");
earlz 3:2bc2b0dce10e 68 vgetsl(cmd, 128);
earlz 3:2bc2b0dce10e 69 vputc('\n');
earlz 3:2bc2b0dce10e 70 valid=false;
earlz 3:2bc2b0dce10e 71 if(strlcmp(cmd, "help", 5)==0){
earlz 3:2bc2b0dce10e 72 valid=true;
earlz 3:2bc2b0dce10e 73 vputs("Command list:\n");
earlz 12:3ee3062cc11c 74 vputs("help -- this text \n");
earlz 12:3ee3062cc11c 75 vputs("cls -- clear the screen\n");
earlz 12:3ee3062cc11c 76 vputs("testX -- test (where X is number) performs tests\n");
earlz 12:3ee3062cc11c 77 vputs("reboot -- resets the processor\n");
earlz 12:3ee3062cc11c 78 vputs("about -- prints text about how we got to here\n");
earlz 12:3ee3062cc11c 79 vputs("plearlz -- enter the PLEarlz Forth shell\n");
earlz 3:2bc2b0dce10e 80 }else if(strlcmp(cmd,"cls",4)==0){
earlz 3:2bc2b0dce10e 81 valid=true;
earlz 3:2bc2b0dce10e 82 vga_cls();
earlz 3:2bc2b0dce10e 83 vsetcursor(0,0);
earlz 3:2bc2b0dce10e 84 }else if(strlcmp(cmd,"test", 5)==0){
earlz 3:2bc2b0dce10e 85 valid=true;
earlz 3:2bc2b0dce10e 86 vputs("Opening File...Screen may flicker!\n"); // Drive should be marked as removed
earlz 3:2bc2b0dce10e 87 wait(5);
earlz 3:2bc2b0dce10e 88 FILE *fp = fopen("/local/test.txt", "w");
earlz 3:2bc2b0dce10e 89 if(!fp) {
earlz 3:2bc2b0dce10e 90 vputs("File /local/test.txt could not be opened!\n");
earlz 3:2bc2b0dce10e 91 exit(1);
earlz 3:2bc2b0dce10e 92 }
earlz 3:2bc2b0dce10e 93
earlz 3:2bc2b0dce10e 94 wait(5.0);
earlz 3:2bc2b0dce10e 95
earlz 3:2bc2b0dce10e 96 vputs("Writing Data...\n");
earlz 3:2bc2b0dce10e 97 fprintf(fp, "Hello World!");
earlz 3:2bc2b0dce10e 98
earlz 3:2bc2b0dce10e 99 wait(5.0);
earlz 3:2bc2b0dce10e 100
earlz 3:2bc2b0dce10e 101 vputs("Closing File...\n");
earlz 3:2bc2b0dce10e 102 fclose(fp);
earlz 3:2bc2b0dce10e 103
earlz 3:2bc2b0dce10e 104 // Drive should be restored. this is the same as just returning from main
earlz 3:2bc2b0dce10e 105 wait(5);
earlz 9:4211d638b2e9 106 }else if(strlcmp(cmd, "test2", 6)==0){
earlz 10:bda85442b674 107 while(1){
earlz 10:bda85442b674 108 vputc(kbd_GetKey());
earlz 9:4211d638b2e9 109 }
earlz 20:13556e5bac04 110 }else if(strlcmp(cmd, "test3", 6) == 0)
earlz 20:13556e5bac04 111 {
earlz 20:13556e5bac04 112 //SDFileSystem sdcard(p11, p12, p13, p20, "sd");
earlz 20:13556e5bac04 113 FILE *fp = fopen("/sd/sdtest.txt", "w");
earlz 20:13556e5bac04 114 if(fp == NULL) {
earlz 20:13556e5bac04 115 vputs("Could not open file for write\n");
earlz 20:13556e5bac04 116 }
earlz 20:13556e5bac04 117 fprintf(fp, "Hello fun SD Card World!");
earlz 20:13556e5bac04 118 fclose(fp);
earlz 20:13556e5bac04 119 }else if(strlcmp(cmd, "format", 7) == 0)
earlz 20:13556e5bac04 120 {
earlz 20:13556e5bac04 121 if(sdcard->format()!=0)
earlz 20:13556e5bac04 122 {
earlz 20:13556e5bac04 123 vputs("Error formatting :(");
earlz 20:13556e5bac04 124 }
earlz 3:2bc2b0dce10e 125 }else if(strlcmp(cmd, "plearlz", 8)==0){
earlz 3:2bc2b0dce10e 126 valid=1;
earlz 3:2bc2b0dce10e 127 pl_shell();
earlz 12:3ee3062cc11c 128 }else if(strlcmp(cmd,"reboot", 7)==0){
earlz 12:3ee3062cc11c 129 valid=1;
earlz 12:3ee3062cc11c 130 NVIC_SystemReset();
earlz 12:3ee3062cc11c 131 }else if(strlcmp(cmd, "about", 6)==0){
earlz 12:3ee3062cc11c 132 valid=1;
earlz 12:3ee3062cc11c 133 vputs("I am Jack's broken monolog\n");
earlz 13:442bd2fb4ea0 134 }else if(strlcmp(cmd, "scheme", 7)==0){
earlz 13:442bd2fb4ea0 135 valid=1;
earlz 13:442bd2fb4ea0 136 //scheme_main();
earlz 3:2bc2b0dce10e 137 }
earlz 3:2bc2b0dce10e 138 if(!valid){
earlz 12:3ee3062cc11c 139 vputs("Invalid Command! Try `help` if you need it\n");
earlz 3:2bc2b0dce10e 140 }
earlz 3:2bc2b0dce10e 141 }
earlz 3:2bc2b0dce10e 142 }
earlz 3:2bc2b0dce10e 143
earlz 3:2bc2b0dce10e 144
earlz 3:2bc2b0dce10e 145