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:
Fri Apr 05 00:54:22 2013 +0000
Revision:
17:8646a54da9ca
Parent:
16:370b9e559f92
Moved keyboard to pins 21 and 22 so that we can use the spare SPI for SD card

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 12:3ee3062cc11c 32 #ifndef KEYBOARD_H
earlz 12:3ee3062cc11c 33 #define KEYBOARD_H
earlz 12:3ee3062cc11c 34
earlz 12:3ee3062cc11c 35 #include "stdint.h"
earlz 12:3ee3062cc11c 36 /**This is basically a straight rip off of my x86 OS project AlloyOS. I just ported the keyboard driver from it cause it always treated me well**/
earlz 12:3ee3062cc11c 37
earlz 12:3ee3062cc11c 38
earlz 17:8646a54da9ca 39 #define KEYBOARD_DATAPIN p21
earlz 17:8646a54da9ca 40 #define KEYBOARD_CLOCKPIN p22
earlz 12:3ee3062cc11c 41
earlz 12:3ee3062cc11c 42 //how many keys the buffer can hold
earlz 12:3ee3062cc11c 43 #define KBD_BUFFER_SIZE 128
earlz 12:3ee3062cc11c 44
earlz 12:3ee3062cc11c 45 //key defines
earlz 12:3ee3062cc11c 46 #define LSHIFT_KEY 0x12
earlz 12:3ee3062cc11c 47 #define RSHIFT_KEY 0x59
earlz 12:3ee3062cc11c 48
earlz 12:3ee3062cc11c 49 #define CTRL_KEY 0xF3
earlz 12:3ee3062cc11c 50 #define ALT_KEY 0xF4
earlz 12:3ee3062cc11c 51 #define CAPS_KEY 0x58
earlz 12:3ee3062cc11c 52 #define NUM_KEY 0x77
earlz 12:3ee3062cc11c 53 #define SCROLL_KEY 0xF7
earlz 12:3ee3062cc11c 54 //#define F_BASE_KEY 0xFF //59 is F1, 60 is F2, and so on until F10
earlz 12:3ee3062cc11c 55 #define HOME_KEY 0xFF
earlz 12:3ee3062cc11c 56 #define UP_KEY 0xFF
earlz 12:3ee3062cc11c 57 #define PAGE_UP_KEY 0xFF
earlz 12:3ee3062cc11c 58 #define LEFT_KEY 0xFF
earlz 12:3ee3062cc11c 59 #define RIGHT_KEY 0xFF
earlz 12:3ee3062cc11c 60 #define END_KEY 0xFF
earlz 12:3ee3062cc11c 61 #define DOWN_KEY 0xFF
earlz 12:3ee3062cc11c 62 #define PAGE_DOWN_KEY 0xFF
earlz 12:3ee3062cc11c 63 #define INSERT_KEY 0xFF
earlz 12:3ee3062cc11c 64 #define DEL_KEY 0xFF
earlz 12:3ee3062cc11c 65 #define F11_KEY 0xFF
earlz 12:3ee3062cc11c 66 #define F12_KEY 0xFF
earlz 12:3ee3062cc11c 67
earlz 12:3ee3062cc11c 68 #define SCROLL_LED 1
earlz 12:3ee3062cc11c 69 #define NUM_LED 2
earlz 12:3ee3062cc11c 70 #define CAPS_LED 4
earlz 12:3ee3062cc11c 71
earlz 12:3ee3062cc11c 72
earlz 12:3ee3062cc11c 73 extern const char kbdus[0x84];
earlz 12:3ee3062cc11c 74 extern const char kbdus_caps[0x84];
earlz 12:3ee3062cc11c 75
earlz 12:3ee3062cc11c 76 typedef struct {
earlz 12:3ee3062cc11c 77 unsigned char caps;
earlz 12:3ee3062cc11c 78 unsigned char shift;
earlz 12:3ee3062cc11c 79 unsigned char scroll;
earlz 12:3ee3062cc11c 80 unsigned char num;
earlz 12:3ee3062cc11c 81 unsigned char ctrl;
earlz 12:3ee3062cc11c 82 unsigned char alt;
earlz 12:3ee3062cc11c 83 }
earlz 12:3ee3062cc11c 84 shift_locks; /*for simplicity and speed*/
earlz 12:3ee3062cc11c 85
earlz 12:3ee3062cc11c 86 extern volatile shift_locks kbd_shifts;
earlz 12:3ee3062cc11c 87
earlz 12:3ee3062cc11c 88 typedef struct {
earlz 12:3ee3062cc11c 89 uint16_t scancode;
earlz 12:3ee3062cc11c 90 uint8_t asci;
earlz 12:3ee3062cc11c 91 }kbd_key;
earlz 12:3ee3062cc11c 92
earlz 12:3ee3062cc11c 93 void keyboard_callback(PS2KB kb, uint8_t val);
earlz 12:3ee3062cc11c 94 void keyboard_init();
earlz 12:3ee3062cc11c 95
earlz 12:3ee3062cc11c 96 int kbd_PutBuffer(uint16_t scan,uint8_t asci);
earlz 12:3ee3062cc11c 97
earlz 12:3ee3062cc11c 98 kbd_key kbd_PopBuffer();
earlz 12:3ee3062cc11c 99 uint8_t kbd_GetKey();
earlz 12:3ee3062cc11c 100 void kbd_update_leds(uint8_t status);
earlz 12:3ee3062cc11c 101 int kbd_DoShifts(uint8_t scan);
earlz 12:3ee3062cc11c 102 int kbd_DoUnshifts(uint8_t scan);
earlz 12:3ee3062cc11c 103 void keyboard_callback(PS2KB kb, uint8_t val);
earlz 12:3ee3062cc11c 104
earlz 12:3ee3062cc11c 105
earlz 12:3ee3062cc11c 106
earlz 12:3ee3062cc11c 107 #endif