The original snake game for the mbedgc

Dependencies:   mbed EthernetNetIf HTTPClient

Fork of SimpleLib_03272011 by J.P. Armstrong

Files at this revision

API Documentation at this revision

Comitter:
jp
Date:
Sat Apr 02 23:23:07 2011 +0000
Child:
1:3606fe561f47
Commit message:

Changed in this revision

mbed.bld Show annotated file Show diff for this revision Revisions of this file
mbedGC/EthernetNetIf.lib Show annotated file Show diff for this revision Revisions of this file
mbedGC/HTTPClient.lib Show annotated file Show diff for this revision Revisions of this file
mbedGC/I2CConfig.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/Snake.cpp Show annotated file Show diff for this revision Revisions of this file
mbedGC/Snake.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/SnakeNode.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/WiiClassicControllerDefs.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/WiiClassicControllerReader.cpp Show annotated file Show diff for this revision Revisions of this file
mbedGC/WiiClassicControllerReader.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/colors.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/ethernet.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/interrupts.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/ip.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/leds.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/mbed_globals.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/mbedgc.cpp Show annotated file Show diff for this revision Revisions of this file
mbedGC/mbedgc.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/serial.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/sprites.h Show annotated file Show diff for this revision Revisions of this file
mbedGC/timers.h Show annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/EthernetNetIf.lib	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mamezu/code/EthernetNetIf/#0f6c82fcde82
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/HTTPClient.lib	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mamezu/code/HTTPClient/#62fac7f06c8d
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/I2CConfig.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,51 @@
+/*
+* WiiClassicControllerReader. A program allowing the output of one or two
+* Wii Classic Controllers to be read via I2C and decoded for use, using the mbed 
+* microcontroller and its associated libraries.
+*
+* Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source 
+* game console <http://www.mbedgc.com>. Based on the original code for
+* the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>.
+*
+* This file is part of WiiClassicControllerReader.
+*
+* WiiClassicControllerReader is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+* 
+* WiiClassicControllerReader is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ALFREDOG83_I2CCONFIG_H
+#define ALFREDOG83_I2CCONFIG_H
+
+#include <mbed.h>
+
+class I2CPort_A
+{
+public:
+    static const PinName SDA;
+    static const PinName SCL;
+};
+
+    
+class I2CPort_B
+{
+public:
+    static const PinName SDA;
+    static const PinName SCL;
+};
+
+const PinName I2CPort_A::SDA = p9;
+const PinName I2CPort_A::SCL = p10;
+
+const PinName I2CPort_B::SDA = p28;
+const PinName I2CPort_B::SCL = p27;
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/Snake.cpp	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,49 @@
+#include "mbed.h"
+#include "Snake.h"
+
+Snake::Snake( )
+{
+    head = tail = NULL;
+    size = 0;
+}
+void Snake::addHead( int xC, int yC  )
+{
+    Node * p = ( Node * ) malloc ( sizeof ( Node ) );
+    if ( head == NULL )
+    {
+        head = tail = p;
+        p->next = NULL;
+    }
+    else
+    {
+        p->x = xC;
+        p->y = yC;
+        head->next = p;
+        head = p;
+    }
+    
+    size++;
+
+}
+
+void Snake::removeTail( )
+{
+    Node * temp = tail;
+    tail = tail->next;
+    delete( temp );
+    size--;
+}
+
+int Snake::getTailXCor( )
+{
+    return tail->x;
+}
+int Snake::getTailYCor( )
+{
+    return tail->y;
+}
+
+int Snake::getSize()
+{
+    return size;
+}
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/Snake.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,23 @@
+#define Node struct NodeStruct
+
+Node
+{
+    int x, y;
+    Node * next;
+};
+
+class Snake
+{
+    public:
+        Snake( );
+        void addHead( int xC, int yC );
+        void removeTail( );
+        int getTailXCor();
+        int getTailYCor();
+        int getSize();
+        
+    private:
+        Node * head;
+        Node * tail;
+        int size;
+};
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/SnakeNode.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,8 @@
+struct SnakeNode
+{
+    public:
+        SnakeNode(int xC, int yC): x(xC),y(yC){}
+        SnakeNode * next;
+    private:
+        int x, y;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/WiiClassicControllerDefs.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,61 @@
+/*
+* WiiClassicControllerReader. A program allowing the output of one or two
+* Wii Classic Controllers to be read via I2C and decoded for use, using the mbed 
+* microcontroller and its associated libraries.
+*
+* Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source 
+* game console <http://www.mbedgc.com>. Based on the original code for
+* the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>.
+*
+* This file is part of WiiClassicControllerReader.
+*
+* WiiClassicControllerReader is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+* 
+* WiiClassicControllerReader is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ALFREDOG83_WIICLASSICCONTROLLERDEFS_H
+#define ALFREDOG83_WIICLASSICCONTROLLERDEFS_H
+
+// I2C
+#define CONTROLLER_ADDR     0xA4  // I2C library doesn't right shift the address, so provided shifted
+#define CONTROLLER_REGADDR  0x40  // relevant register address
+#define CONTROLLER_READLEN  0x06  // always read this many bytes back
+
+// bitmasks for individual buttons
+// LX, LY: left analog stick X, Y (0-63)
+// RX, RY: right analog stick X, Y (0-31) [RX separated among bytes 0-2]
+// RT, LT: right, left trigger (0-31) [LT separated among bytes 2-3]
+// B{ZR,ZL,A,B,X,Y,START,HOME,SELECT}: discrete buttons
+// BD{L,R,U,D}: D-pad direction buttons
+// LC,RC: digital button click of LT, RT when pressed down all the way
+#define MASK_LX         0x3F    // LX<5:0>
+#define MASK_RX34       0xC0    // RX<4:3>
+#define MASK_LY         0x3F    // LY<5:0>
+#define MASK_RY         0x1F    // RY<4:0>
+#define MASK_LT34       0x60    // LT<4:3>
+#define MASK_RT         0x1F    // RT<4:0>
+#define MASK_BDU        0x01    // DU
+#define MASK_RC_DL      0x02    // DL, RC
+#define MASK_BSTART_ZR  0x04    // ZR, START
+#define MASK_BHOME_X    0x08    // X, HOME
+#define MASK_BSELECT_A  0x10    // A, SELECT
+#define MASK_LC_Y       0x20    // LC, Y, LT<0>
+#define MASK_BDD_B      0x40    // B, DD, LT<1>, RX<1>
+#define MASK_BDR_ZL     0x80    // ZL, DR, LT<2>, RX<0>, RX<2>
+
+// timing
+#define I2C_READ_DELAY  0.01
+
+// I2C status
+#define I2C_OK        0    // zero on success (ACK), non-zero on fail (NACK) for read or write
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/WiiClassicControllerReader.cpp	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,122 @@
+/*
+* WiiClassicControllerReader. A program allowing the output of one or two
+* Wii Classic Controllers to be read via I2C and decoded for use, using the mbed 
+* microcontroller and its associated libraries.
+*
+* Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source 
+* game console <http://www.mbedgc.com>. Based on the original code for
+* the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>.
+*
+* This file is part of WiiClassicControllerReader.
+*
+* WiiClassicControllerReader is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+* 
+* WiiClassicControllerReader is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>.
+*/
+
+#include "WiiClassicControllerReader.h"
+
+// constructor
+WiiClassicControllerReader::WiiClassicControllerReader(PinName sda, PinName scl) : 
+    controllerPort(sda, scl),
+    ljoyX(0), ljoyY(0), rjoyX(0), rjoyY(0), buttonX(0), buttonY(0), buttonA(0),
+    buttonB(0), buttonZL(0), buttonZR(0), buttonLT(0), buttonRT(0), buttonLC(0), 
+    buttonRC(0), buttonHOME(0), buttonSELECT(0), buttonSTART(0), buttonDU(0), 
+    buttonDD(0), buttonDL(0), buttonDR(0), controllerInit(false)
+{
+}
+
+void WiiClassicControllerReader::RequestRead()
+{
+    // don't expect client to remember to send an init to the nunchuck
+    // so do it for them here
+    if (!controllerInit)
+    {
+        controllerInit = ControllerInit();
+    }
+    
+    if (controllerInit)    // don't start reading if init failed
+    {
+        if (ControllerRead())
+        {
+            // only decode successful reads
+            ControllerDecode();
+        }
+    }
+}
+
+bool WiiClassicControllerReader::ControllerInit()
+{
+    bool success = false;
+    
+    const BYTE cmd[] = {CONTROLLER_REGADDR, 0x00};    
+    if (I2C_OK == controllerPort.write(CONTROLLER_ADDR, (const char*)cmd, sizeof(cmd))) success = true;
+    
+    return success;
+}
+
+bool WiiClassicControllerReader::ControllerRead()
+{
+    bool success = false;
+    
+    // write the address we want to read from
+    const BYTE cmd[] = {0x00};
+    if (I2C_OK ==  controllerPort.write(CONTROLLER_ADDR, (const char*)cmd, sizeof(cmd)))
+    {
+        // the Wii Classic Controller is non-standard I2C
+        // and can't manage setting the read address and immediately supplying the data
+        // so wait a bit
+        wait(I2C_READ_DELAY);
+        
+        if (I2C_OK == controllerPort.read(CONTROLLER_ADDR, readBuf, sizeof(readBuf))) success = true;
+    }
+    
+    return success;
+}
+
+void WiiClassicControllerReader::ControllerDecode()
+{
+    ljoyX = (int)readBuf[0] & MASK_LX;
+    ljoyY = (int)readBuf[1] & MASK_LY;
+    rjoyY = (int)readBuf[2] & MASK_RY;
+    buttonRT = (int)readBuf[3] & MASK_RT;
+    buttonRC = (int)readBuf[4] & MASK_RC_DL;
+    buttonSTART = (int)readBuf[4] & MASK_BSTART_ZR;
+    buttonHOME = (int)readBuf[4] & MASK_BHOME_X;
+    buttonSELECT = (int)readBuf[4] & MASK_BSELECT_A;
+    buttonLC = (int)readBuf[4] & MASK_LC_Y;
+    buttonDD = (int)readBuf[4] & MASK_BDD_B;
+    buttonDR = (int)readBuf[4] & MASK_BDR_ZL;
+    buttonDU = (int)readBuf[5] & MASK_BDU;
+    buttonDL = (int)readBuf[5] & MASK_RC_DL;
+    buttonZR = (int)readBuf[5] & MASK_BSTART_ZR;
+    buttonX = (int)readBuf[5] & MASK_BHOME_X;
+    buttonA = (int)readBuf[5] & MASK_BSELECT_A;
+    buttonY = (int)readBuf[5] & MASK_LC_Y;
+    buttonB = (int)readBuf[5] & MASK_BDD_B;
+    buttonZL = (int)readBuf[5] & MASK_BDR_ZL;
+    
+    // the RjoyX axis and LT values are really 5 bit values
+    // so shift the 2 bit values read from the controller
+    // 3 bits to the right
+    rjoyX = ( (int)readBuf[0] & MASK_RX34 ) << 3;
+    buttonLT = ( (int)readBuf[2] & MASK_LT34 ) << 3;
+    
+    // and for each value add bit 2, bit 1, and bit 0
+    // as required    
+    if (readBuf[2] & MASK_BDR_ZL) rjoyX += 1;
+    if (readBuf[1] & MASK_BDD_B) rjoyX += 2;
+    if (readBuf[1] & MASK_BDR_ZL) rjoyX += 4;
+    if (readBuf[3] & MASK_LC_Y) buttonLT += 1;
+    if (readBuf[3] & MASK_BDD_B) buttonLT += 2;
+    if (readBuf[3] & MASK_BDR_ZL) buttonLT += 4;
+
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/WiiClassicControllerReader.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,106 @@
+/*
+* WiiClassicControllerReader. A program allowing the output of one or two
+* Wii Classic Controllers to be read via I2C and decoded for use, using the mbed 
+* microcontroller and its associated libraries.
+*
+* Written by Alfredo Guerrero <alfredog83@gmail.com> for the mbedGC open-source 
+* game console <http://www.mbedgc.com>. Based on the original code for
+* the WiiNunchuckReader written by Petras Saduikis <petras@petras.co.uk>.
+*
+* This file is part of WiiClassicControllerReader.
+*
+* WiiClassicControllerReader is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License as published by
+* the Free Software Foundation, either version 3 of the License, or
+* (at your option) any later version.
+* 
+* WiiClassicControllerReader is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+* GNU General Public License for more details.
+*
+* You can find a copy of the GNU General Public License at <http://www.gnu.org/licenses/>.
+*/
+
+#ifndef ALFREDOG83_WIICLASSICCONTROLLERREADER_H
+#define ALFREDOG83_WIICLASSICCONTROLLERREADER_H
+
+#include <mbed.h>
+#include "WiiClassicControllerDefs.h"
+
+typedef unsigned char BYTE;
+
+class WiiClassicControllerReader
+{
+public:
+    // constructors
+    WiiClassicControllerReader(PinName sda, PinName scl);
+    
+    // functions
+    void RequestRead();
+    
+    // accessors
+    int getLJoyX() const { return ljoyX; }
+    int getLJoyY() const { return ljoyY; }
+    int getRJoyX() const { return rjoyX; }
+    int getRJoyY() const { return rjoyY; }
+    int getButtonX() const { return buttonX; }
+    int getButtonY() const { return buttonY; }
+    int getButtonA() const { return buttonA; }
+    int getButtonB() const { return buttonB; }
+    int getButtonLT() const { return buttonLT; }
+    int getButtonRT() const { return buttonRT; }
+    int getButtonLC() const { return buttonLC; }
+    int getButtonRC() const { return buttonRC; }
+    int getButtonZL() const { return buttonZL; }
+    int getButtonZR() const { return buttonZR; }
+    int getButtonSELECT() const { return buttonSELECT; }
+    int getButtonHOME() const { return buttonHOME; }
+    int getButtonSTART() const { return buttonSTART; }
+    int getButtonDU() const { return buttonDU; }
+    int getButtonDD() const { return buttonDD; }
+    int getButtonDL() const { return buttonDL; }
+    int getButtonDR() const { return buttonDR; }
+    int getBufferSize() const { return sizeof(readBuf); }
+    char* getReadBuf() { return readBuf; }
+    
+private:
+    // classic controls states
+    int ljoyX;
+    int ljoyY;
+    int rjoyX;
+    int rjoyY;
+    int buttonY;
+    int buttonX;
+    int buttonB;
+    int buttonA;
+    int buttonLT;
+    int buttonRT;
+    int buttonLC;
+    int buttonRC;
+    int buttonZL;
+    int buttonZR;
+    int buttonSELECT;
+    int buttonHOME;
+    int buttonSTART;
+    int buttonDU;
+    int buttonDD;
+    int buttonDL;
+    int buttonDR;
+    
+    // classic init state
+    bool controllerInit;
+    
+    // classic I2C port
+    I2C controllerPort;
+    
+    // read data
+    char readBuf[CONTROLLER_READLEN];
+    
+    // functions    
+    bool ControllerInit();
+    bool ControllerRead();
+    void ControllerDecode();
+};
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/colors.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,324 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+*    MODIFIED BY J.P. ARMSTRONG FROM WWW.MBEDGC.COM
+*
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_LEDS_H__
+#define __SIMPLELIB_LEDS_H__
+
+#include "mbed_globals.h"
+
+/** Bits **/
+#define COLOR_OFF 0
+#define RED1 (1 << 16)
+#define RED2 (1 << 23)
+#define RED3 (1 << 24)
+#define GRN1 (1 << 25)
+#define GRN2 (1 << 9)
+#define GRN3 (1 << 8)
+
+#define BLU1 (1 << 7)
+#define BLU2 (1 << 6)
+
+#define COLOR_MASK ( RED1 | RED2 | RED3 | GRN1 | GRN2 | GRN3 | BLU1 | BLU2 )
+
+const uint32_t COLOR_VAR_MASK[] = {
+    RED1, 
+    RED2, 
+    RED1|RED2, 
+    RED3, 
+    RED1|RED3, 
+    RED2|RED3, 
+    RED1|RED2|RED3, 
+    GRN1, 
+    RED1|GRN1, 
+    RED2|GRN1, 
+    RED1|RED2|GRN1, 
+    RED3|GRN1, 
+    RED1|RED3|GRN1, 
+    RED2|RED3|GRN1, 
+    RED1|RED2|RED3|GRN1, 
+    GRN2, 
+    RED1|GRN2, 
+    RED2|GRN2, 
+    RED1|RED2|GRN2, 
+    RED3|GRN2, 
+    RED1|RED3|GRN2, 
+    RED2|RED3|GRN2, 
+    RED1|RED2|RED3|GRN2, 
+    GRN1|GRN2, 
+    RED1|GRN1|GRN2, 
+    RED2|GRN1|GRN2, 
+    RED1|RED2|GRN1|GRN2, 
+    RED3|GRN1|GRN2, 
+    RED1|RED3|GRN1|GRN2, 
+    RED2|RED3|GRN1|GRN2, 
+    RED1|RED2|RED3|GRN1|GRN2, 
+    GRN3, 
+    RED1|GRN3, 
+    RED2|GRN3, 
+    RED1|RED2|GRN3, 
+    RED3|GRN3, 
+    RED1|RED3|GRN3, 
+    RED2|RED3|GRN3, 
+    RED1|RED2|RED3|GRN3, 
+    GRN1|GRN3, 
+    RED1|GRN1|GRN3, 
+    RED2|GRN1|GRN3, 
+    RED1|RED2|GRN1|GRN3, 
+    RED3|GRN1|GRN3, 
+    RED1|RED3|GRN1|GRN3, 
+    RED2|RED3|GRN1|GRN3, 
+    RED1|RED2|RED3|GRN1|GRN3, 
+    GRN2|GRN3, 
+    RED1|GRN2|GRN3, 
+    RED2|GRN2|GRN3, 
+    RED1|RED2|GRN2|GRN3, 
+    RED3|GRN2|GRN3, 
+    RED1|RED3|GRN2|GRN3, 
+    RED2|RED3|GRN2|GRN3, 
+    RED1|RED2|RED3|GRN2|GRN3, 
+    GRN1|GRN2|GRN3, 
+    RED1|GRN1|GRN2|GRN3, 
+    RED2|GRN1|GRN2|GRN3, 
+    RED1|RED2|GRN1|GRN2|GRN3, 
+    RED3|GRN1|GRN2|GRN3, 
+    RED1|RED3|GRN1|GRN2|GRN3, 
+    RED2|RED3|GRN1|GRN2|GRN3, 
+    RED1|RED2|RED3|GRN1|GRN2|GRN3, 
+    BLU1, 
+    RED1|BLU1, 
+    RED2|BLU1, 
+    RED1|RED2|BLU1, 
+    RED3|BLU1, 
+    RED1|RED3|BLU1, 
+    RED2|RED3|BLU1, 
+    RED1|RED2|RED3|BLU1, 
+    GRN1|BLU1, 
+    RED1|GRN1|BLU1, 
+    RED2|GRN1|BLU1, 
+    RED1|RED2|GRN1|BLU1, 
+    RED3|GRN1|BLU1, 
+    RED1|RED3|GRN1|BLU1, 
+    RED2|RED3|GRN1|BLU1, 
+    RED1|RED2|RED3|GRN1|BLU1, 
+    GRN2|BLU1, 
+    RED1|GRN2|BLU1, 
+    RED2|GRN2|BLU1, 
+    RED1|RED2|GRN2|BLU1, 
+    RED3|GRN2|BLU1, 
+    RED1|RED3|GRN2|BLU1, 
+    RED2|RED3|GRN2|BLU1, 
+    RED1|RED2|RED3|GRN2|BLU1, 
+    GRN1|GRN2|BLU1, 
+    RED1|GRN1|GRN2|BLU1, 
+    RED2|GRN1|GRN2|BLU1, 
+    RED1|RED2|GRN1|GRN2|BLU1, 
+    RED3|GRN1|GRN2|BLU1, 
+    RED1|RED3|GRN1|GRN2|BLU1, 
+    RED2|RED3|GRN1|GRN2|BLU1, 
+    RED1|RED2|RED3|GRN1|GRN2|BLU1, 
+    GRN3|BLU1, 
+    RED1|GRN3|BLU1, 
+    RED2|GRN3|BLU1, 
+    RED1|RED2|GRN3|BLU1, 
+    RED3|GRN3|BLU1, 
+    RED1|RED3|GRN3|BLU1, 
+    RED2|RED3|GRN3|BLU1, 
+    RED1|RED2|RED3|GRN3|BLU1, 
+    GRN1|GRN3|BLU1, 
+    RED1|GRN1|GRN3|BLU1, 
+    RED2|GRN1|GRN3|BLU1, 
+    RED1|RED2|GRN1|GRN3|BLU1, 
+    RED3|GRN1|GRN3|BLU1, 
+    RED1|RED3|GRN1|GRN3|BLU1, 
+    RED2|RED3|GRN1|GRN3|BLU1, 
+    RED1|RED2|RED3|GRN1|GRN3|BLU1, 
+    GRN2|GRN3|BLU1, 
+    RED1|GRN2|GRN3|BLU1, 
+    RED2|GRN2|GRN3|BLU1, 
+    RED1|RED2|GRN2|GRN3|BLU1, 
+    RED3|GRN2|GRN3|BLU1, 
+    RED1|RED3|GRN2|GRN3|BLU1, 
+    RED2|RED3|GRN2|GRN3|BLU1, 
+    RED1|RED2|RED3|GRN2|GRN3|BLU1, 
+    GRN1|GRN2|GRN3|BLU1, 
+    RED1|GRN1|GRN2|GRN3|BLU1, 
+    RED2|GRN1|GRN2|GRN3|BLU1, 
+    RED1|RED2|GRN1|GRN2|GRN3|BLU1, 
+    RED3|GRN1|GRN2|GRN3|BLU1, 
+    RED1|RED3|GRN1|GRN2|GRN3|BLU1, 
+    RED2|RED3|GRN1|GRN2|GRN3|BLU1, 
+    RED1|RED2|RED3|GRN1|GRN2|GRN3|BLU1, 
+    BLU2, 
+    RED1|BLU2, 
+    RED2|BLU2, 
+    RED1|RED2|BLU2, 
+    RED3|BLU2, 
+    RED1|RED3|BLU2, 
+    RED2|RED3|BLU2, 
+    RED1|RED2|RED3|BLU2, 
+    GRN1|BLU2, 
+    RED1|GRN1|BLU2, 
+    RED2|GRN1|BLU2, 
+    RED1|RED2|GRN1|BLU2, 
+    RED3|GRN1|BLU2, 
+    RED1|RED3|GRN1|BLU2, 
+    RED2|RED3|GRN1|BLU2, 
+    RED1|RED2|RED3|GRN1|BLU2, 
+    GRN2|BLU2, 
+    RED1|GRN2|BLU2, 
+    RED2|GRN2|BLU2, 
+    RED1|RED2|GRN2|BLU2, 
+    RED3|GRN2|BLU2, 
+    RED1|RED3|GRN2|BLU2, 
+    RED2|RED3|GRN2|BLU2, 
+    RED1|RED2|RED3|GRN2|BLU2, 
+    GRN1|GRN2|BLU2, 
+    RED1|GRN1|GRN2|BLU2, 
+    RED2|GRN1|GRN2|BLU2, 
+    RED1|RED2|GRN1|GRN2|BLU2, 
+    RED3|GRN1|GRN2|BLU2, 
+    RED1|RED3|GRN1|GRN2|BLU2, 
+    RED2|RED3|GRN1|GRN2|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN2|BLU2, 
+    GRN3|BLU2, 
+    RED1|GRN3|BLU2, 
+    RED2|GRN3|BLU2, 
+    RED1|RED2|GRN3|BLU2, 
+    RED3|GRN3|BLU2, 
+    RED1|RED3|GRN3|BLU2, 
+    RED2|RED3|GRN3|BLU2, 
+    RED1|RED2|RED3|GRN3|BLU2, 
+    GRN1|GRN3|BLU2, 
+    RED1|GRN1|GRN3|BLU2, 
+    RED2|GRN1|GRN3|BLU2, 
+    RED1|RED2|GRN1|GRN3|BLU2, 
+    RED3|GRN1|GRN3|BLU2, 
+    RED1|RED3|GRN1|GRN3|BLU2, 
+    RED2|RED3|GRN1|GRN3|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN3|BLU2, 
+    GRN2|GRN3|BLU2, 
+    RED1|GRN2|GRN3|BLU2, 
+    RED2|GRN2|GRN3|BLU2, 
+    RED1|RED2|GRN2|GRN3|BLU2, 
+    RED3|GRN2|GRN3|BLU2, 
+    RED1|RED3|GRN2|GRN3|BLU2, 
+    RED2|RED3|GRN2|GRN3|BLU2, 
+    RED1|RED2|RED3|GRN2|GRN3|BLU2, 
+    GRN1|GRN2|GRN3|BLU2, 
+    RED1|GRN1|GRN2|GRN3|BLU2, 
+    RED2|GRN1|GRN2|GRN3|BLU2, 
+    RED1|RED2|GRN1|GRN2|GRN3|BLU2, 
+    RED3|GRN1|GRN2|GRN3|BLU2, 
+    RED1|RED3|GRN1|GRN2|GRN3|BLU2, 
+    RED2|RED3|GRN1|GRN2|GRN3|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN2|GRN3|BLU2, 
+    BLU1|BLU2, 
+    RED1|BLU1|BLU2, 
+    RED2|BLU1|BLU2, 
+    RED1|RED2|BLU1|BLU2, 
+    RED3|BLU1|BLU2, 
+    RED1|RED3|BLU1|BLU2, 
+    RED2|RED3|BLU1|BLU2, 
+    RED1|RED2|RED3|BLU1|BLU2, 
+    GRN1|BLU1|BLU2, 
+    RED1|GRN1|BLU1|BLU2, 
+    RED2|GRN1|BLU1|BLU2, 
+    RED1|RED2|GRN1|BLU1|BLU2, 
+    RED3|GRN1|BLU1|BLU2, 
+    RED1|RED3|GRN1|BLU1|BLU2, 
+    RED2|RED3|GRN1|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN1|BLU1|BLU2, 
+    GRN2|BLU1|BLU2, 
+    RED1|GRN2|BLU1|BLU2, 
+    RED2|GRN2|BLU1|BLU2, 
+    RED1|RED2|GRN2|BLU1|BLU2, 
+    RED3|GRN2|BLU1|BLU2, 
+    RED1|RED3|GRN2|BLU1|BLU2, 
+    RED2|RED3|GRN2|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN2|BLU1|BLU2, 
+    GRN1|GRN2|BLU1|BLU2, 
+    RED1|GRN1|GRN2|BLU1|BLU2, 
+    RED2|GRN1|GRN2|BLU1|BLU2, 
+    RED1|RED2|GRN1|GRN2|BLU1|BLU2, 
+    RED3|GRN1|GRN2|BLU1|BLU2, 
+    RED1|RED3|GRN1|GRN2|BLU1|BLU2, 
+    RED2|RED3|GRN1|GRN2|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN2|BLU1|BLU2, 
+    GRN3|BLU1|BLU2, 
+    RED1|GRN3|BLU1|BLU2, 
+    RED2|GRN3|BLU1|BLU2, 
+    RED1|RED2|GRN3|BLU1|BLU2, 
+    RED3|GRN3|BLU1|BLU2, 
+    RED1|RED3|GRN3|BLU1|BLU2, 
+    RED2|RED3|GRN3|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN3|BLU1|BLU2, 
+    GRN1|GRN3|BLU1|BLU2, 
+    RED1|GRN1|GRN3|BLU1|BLU2, 
+    RED2|GRN1|GRN3|BLU1|BLU2, 
+    RED1|RED2|GRN1|GRN3|BLU1|BLU2, 
+    RED3|GRN1|GRN3|BLU1|BLU2, 
+    RED1|RED3|GRN1|GRN3|BLU1|BLU2, 
+    RED2|RED3|GRN1|GRN3|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN3|BLU1|BLU2, 
+    GRN2|GRN3|BLU1|BLU2, 
+    RED1|GRN2|GRN3|BLU1|BLU2, 
+    RED2|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED2|GRN2|GRN3|BLU1|BLU2, 
+    RED3|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED3|GRN2|GRN3|BLU1|BLU2, 
+    RED2|RED3|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN2|GRN3|BLU1|BLU2, 
+    GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED1|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED2|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED2|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED3|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED3|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED2|RED3|GRN1|GRN2|GRN3|BLU1|BLU2, 
+    RED1|RED2|RED3|GRN1|GRN2|GRN3|BLU1|BLU2
+};
+
+/** Macros **/
+#define COLOR_INIT()     LPC_GPIO0->FIODIR |= COLOR_MASK;
+
+#define COLOR_SET(value) do\
+{\
+    LPC_GPIO0->FIOCLR = COLOR_MASK;\
+    LPC_GPIO0->FIOSET = COLOR_VAR_MASK[value];\
+} while(0);
+/* LPC_GPIO0->FIOMASK = ~COLOR_MASK; \
+    LPC_GPIO0->FIOPIN = COLOR_VAR_MASK[value];\
+    */
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/ethernet.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,66 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_ETHERNET_H__
+#define __SIMPLELIB_ETHERNET_H__
+
+typedef __packed struct {
+    char destination[6];
+    char source[6];
+    uint16_t type;
+} ethernet_packet;
+#define asETH(x) ((ethernet_packet*)(x))
+
+#define IPV4_TYPE 0x0800
+#define ARP_TYPE  0x0806
+
+typedef __packed struct {
+    ethernet_packet eth;
+    __packed struct {
+        char hardware_type[2];
+        char protocol_type[2];
+        char hardware_size;
+        char protocol_size;
+        uint16_t opcode_request;
+        char sender_mac[6];
+        char sender_ip[4];
+        char target_mac[6];
+        char target_ip[4];
+    } arp;
+} arp_packet;
+#define asARP(x) ((arp_packet*)(x))
+
+#define ARP_REQUEST 0x0001
+#define ARP_REPLY   0x0002
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/interrupts.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,121 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_INTERRUPTS_H__
+#define __SIMPLELIB_INTERRUPTS_H__
+
+#include "mbed_globals.h"
+
+/** Interrupt Managment **/
+#define ENABLE_INTERRUPT(intr)  NVIC_EnableIRQ(intr)
+#define DISABLE_INTERRUPT(intr) NVIC_DisableIRQ(intr)
+
+#if defined ( __CC_ARM )
+    #define __IRQ     __irq
+#elif defined   ( __GNUC__ )
+    #define __IRQ     __attribute__((interrupt("IRQ")))
+#endif
+
+/* Interrupts names
+ * WDT_IRQn         Watchdog Timer Interrupt
+ * TIMER0_IRQn      Timer0 Interrupt
+ * TIMER1_IRQn      Timer1 Interrupt
+ * TIMER2_IRQn      Timer2 Interrupt
+ * TIMER3_IRQn      Timer3 Interrupt
+ * UART0_IRQn       UART0 Interrupt
+ * UART1_IRQn        UART1 Interrupt
+ * UART2_IRQn        UART2 Interrupt
+ * UART3_IRQn        UART3 Interrupt
+ * PWM1_IRQn        PWM1 Interrupt
+ * I2C0_IRQn        I2C0 Interrupt
+ * I2C1_IRQn        I2C1 Interrupt
+ * I2C2_IRQn        I2C2 Interrupt
+ * SPI_IRQn         SPI Interrupt
+ * SSP0_IRQn        SSP0 Interrupt
+ * SSP1_IRQn        SSP1 Interrupt
+ * PLL0_IRQn        PLL0 Lock (Main PLL) Interrupt
+ * RTC_IRQn         Real Time Clock Interrupt
+ * EINT0_IRQn        External Interrupt 0 Interrupt
+ * EINT1_IRQn        External Interrupt 1 Interrupt
+ * EINT2_IRQn        External Interrupt 2 Interrupt
+ * EINT3_IRQn        External Interrupt 3 Interrupt
+ * ADC_IRQn         A/D Converter Interrupt
+ * BOD_IRQn            Brown-Out Detect Interrupt
+ * USB_IRQn            USB Interrupt
+ * CAN_IRQn            CAN Interrupt
+ * DMA_IRQn            General Purpose DMA Interrupt
+ * I2S_IRQn            I2S Interrupt
+ * ENET_IRQn        Ethernet Interrupt
+ * RIT_IRQn            Repetitive Interrupt Timer Interrupt
+ * MCPWM_IRQn        Motor Control PWM Interrupt
+ * QEI_IRQn            Quadrature Encoder Interface Interrupt
+ * PLL1_IRQn        PLL1 Lock (USB PLL) Interrupt
+ */
+
+/* Default interrupt handlers
+ * WDT_IRQHandler
+ * TIMER0_IRQHandler
+ * TIMER1_IRQHandler
+ * TIMER2_IRQHandler
+ * TIMER3_IRQHandler
+ * UART0_IRQHandler
+ * UART1_IRQHandler
+ * UART2_IRQHandler
+ * UART3_IRQHandler
+ * PWM1_IRQHandler
+ * I2C0_IRQHandler
+ * I2C1_IRQHandler
+ * I2C2_IRQHandler
+ * SPI_IRQHandler
+ * SSP0_IRQHandler
+ * SSP1_IRQHandler
+ * PLL0_IRQHandler
+ * RTC_IRQHandler
+ * EINT0_IRQHandler
+ * EINT1_IRQHandler
+ * EINT2_IRQHandler
+ * EINT3_IRQHandler
+ * ADC_IRQHandler
+ * BOD_IRQHandler
+ * USB_IRQHandler
+ * CAN_IRQHandler
+ * DMA_IRQHandler
+ * I2S_IRQHandler
+ * ENET_IRQHandler
+ * RIT_IRQHandler
+ * MCPWM_IRQHandler
+ * QEI_IRQHandler
+ * PLL1_IRQHandler
+*/ 
+ 
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/ip.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,79 @@
+/*
+* Copyright or © or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_IP_H__
+#define __SIMPLELIB_IP_H__
+
+#include "ip.h"
+
+typedef __packed struct {
+    unsigned char version:4;
+    unsigned char length:4;
+    unsigned char services;
+    uint16_t total_length;
+    uint16_t identification;
+    unsigned int flags:3;
+    unsigned fragment_offset:13;
+    unsigned char ttl;
+    unsigned char protocol;
+    uint16_t header_checksum;
+    unsigned char source[4];
+    unsigned char destination[4];
+} s_ip;
+
+typedef __packed struct {
+    ethernet_packet eth;
+    s_ip ip;
+} ipv4_packet;
+#define asIPV4(x) ((ipv4_packet*)(x))
+
+#define PROTO_ICMP  0x01
+
+typedef __packed struct {
+    ethernet_packet eth;
+    s_ip ip;
+    __packed struct {
+        unsigned char type;
+        unsigned char code;
+        uint16_t checksum;
+        uint16_t identifier;
+        uint16_t sequence_number;
+        unsigned char data[];
+    } icmp;
+} icmp_packet;
+#define asICMP(x) ((icmp_packet*)(x))
+
+#define ICMP_REQUEST 0x08
+#define ICMP_REPLY   0x00
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/leds.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,55 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_LEDS_H__
+#define __SIMPLELIB_LEDS_H__
+
+#include "mbed_globals.h"
+
+/** Bits **/
+#define LEDS_OFF 0
+#define LED1 (1 << 18)
+#define LED2 (1 << 20)
+#define LED3 (1 << 21)
+#define LED4 (1 << 23)
+#define LEDS_MASK (LED1 | LED2 | LED3 | LED4)
+
+/** Macros **/
+#define LEDS_INIT()     LPC_GPIO1->FIODIR |= LEDS_MASK;
+
+#define LEDS_SET(value) do {                                 \
+                            LPC_GPIO1->FIOMASK = ~LEDS_MASK; \
+                            LPC_GPIO1->FIOPIN = (value);     \
+                        } while(0)
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/mbed_globals.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,79 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_MBED_GLOBALS_H__
+#define __SIMPLELIB_MBED_GLOBALS_H__
+
+#include <LPC17xx.h>
+
+/* GLOBALS MACRO */
+#define GET_REGISTER8(reg)  *(volatile uint8_t *)(reg)
+#define GET_REGISTER16(reg) *(volatile uint16_t *)(reg)
+#define GET_REGISTER32(reg) *(volatile uint32_t *)(reg)
+
+#define SET_REGISTER8(reg, val)  *(uint8_t *)(reg)=(val)
+#define SET_REGISTER16(reg, val) *(uint16_t *)(reg)=(val)
+#define SET_REGISTER32(reg, val) *(uint32_t *)(reg)=(val)
+
+// See 34.3.2.5 p740
+#define BIT_BANDING_ADDRESS(reg, bit) (((reg) & 0xF0000000) | (0x02000000) | (((reg) & 0x000FFFFF) << 5) | ((bit) << 2))
+#define GET_BIT_ADDRESS(reg, bit) BIT_BANDING_ADDRESS(((uint32_t)&(reg)), (bit))
+#define GET_BIT_VALUE(reg, bit) GET_REGISTER32(GET_BIT_ADDRESS((reg), (bit)))
+#define SET_BIT_VALUE(reg, bit, value) SET_REGISTER32(GET_BIT_ADDRESS((reg), (bit)), (value))
+
+// Macro tools
+#define TOKENPASTE(x, y) x ## y
+#define TOKENPASTE2(x, y) TOKENPASTE(x, y)
+
+// Extern C
+#ifdef __cplusplus
+    #define EXTERN_C extern "C"
+#else
+    #define EXTERN_C
+#endif
+
+// Byte swap macros
+#define HTONS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8))
+#define NTOHS(x) (((((unsigned short)(x))>>8) & 0xff) | ((((unsigned short)(x)) & 0xff)<<8))
+#define HTONL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
+#define NTOHL(x) ((((x)>>24) & 0xffL) | (((x)>>8) & 0xff00L) | (((x)<<8) & 0xff0000L) | (((x)<<24) & 0xff000000L))
+
+
+/** Constants **/
+// Peripheral Clock Selection register bit values (Table 42, p57)
+#define CCLK4   0U
+#define CCLK    1U
+#define CCLK2   2U
+#define CCLK8   3U
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/mbedgc.cpp	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,537 @@
+#include "mbed.h"
+#include "mbedGC/mbedgc.h"
+#include "Snake.h"
+#include "sprites.h"
+#include <string>
+#include "EthernetNetIf.h"
+#include "HTTPClient.h"
+
+EthernetNetIf eth; 
+
+void apples(int);
+void startGame();
+void endGame();
+int networking();
+
+void drawNumbers(int, int, unsigned char, int);
+void drawStrings(int, int, unsigned char, string);
+Snake snake;
+int snake_x = 60;
+int snake_y = 10;
+int snake_direction = 0;
+int snake_length = 10;
+int snake_apples_eaten = 0;
+float logic_percent = 0;
+int score = 0;
+unsigned char snake_color = 192;
+
+bool game_paused = false;
+bool faster = false;
+
+const int num_apples = 10;
+
+
+int main() {
+
+//    networking();
+ 
+    blankFB(); 
+    soundNoteHalf = 0;
+   
+    NVIC_SetPriority(TIMER0_IRQn, 0);
+
+    COLOR_INIT();
+    TIMER0_INIT();
+    TIMER0_SETPCLK(CCLK4);
+    TIMER0_SETPRESCALE(3000); // 3000 : 134
+    TIMER0_SETMATCH(0, 132);
+    TIMER0_SETMATCHCONTROL(0, MATCH_RESET | MATCH_INTERRUPT); // Reset and Interrupt each 100ms
+    TIMER0_ENABLE_INTERRUPT();
+    TIMER0_START();
+
+    setup();
+    
+    while (1){
+        loop();
+        
+        if (hsync_count > 0xFFFFF)
+            hsync_count = 0x80000;
+     
+         logic_count++;
+        
+       if (logic_count > 0xFFFFFF)
+            logic_count = 0;
+    }
+    
+}
+
+void drawRectangle(int x, int y, int width, int height, unsigned char color) 
+{
+        
+        if (x < 0 || y < 0)
+            return; 
+            
+        for (int i = 0; i < height; i++) 
+        {
+
+               for (int j = 0; j < width; j++) 
+               {
+                                                                
+                    framebuffer[ (y + i) % fbH ][ (x + j) % fbW ] = color;
+                    
+               }
+        }
+}
+
+void drawCharacter(int x, int y, unsigned char color, char ch) {
+   
+    if (ch <= 'z' && ch >= 'a')
+        ch = ch - 'a' + 10;
+    else if (ch <= 'Z' && ch >= 'A')
+        ch = ch - 'A' + 10;   
+    else if (ch <= '9' && ch >= '0')
+            ch = ch - '0';
+    else if (ch == ' ')
+        ch = 36;
+    else if (ch == '.')
+        ch = 37;
+        
+    for (int i = 0; i < 5; i++) {
+
+        unsigned char buf = alphabet[ch][i];
+        
+  //      buf = numbers[ch][i] << 3;
+        
+        for (int j = 4; j >= 0; j--) {
+            
+            framebuffer[(y + i) % fbH ][ (x + j) % fbW ] = (buf % 2) * color;
+            buf = ( buf >> 1 );
+        }
+            
+        y %= fbH;
+        
+    }
+}
+
+
+void fill(unsigned char val) 
+{
+
+    for (int i = 0; i < fbH; i++) 
+    {
+ 
+        for (int j = 0; j < fbW; j++) 
+        {
+            framebuffer[i][j] = val;
+        }
+    }
+
+}
+
+void blankFB() 
+{
+
+    for (int i = 0; i < fbH; i++) 
+    {
+        for (int j = 0; j < fbW; j++) 
+        {
+            framebuffer[i][j] = 0;
+        }
+    }
+
+}
+
+TIMER0_INTERRUPT_HANDLER(void)
+{
+    TIMER0_CLEAR_INTERRUPT(MR0_INT);
+    
+    vSync = 1;
+    for( int i = 0; i < fbH * 2; i++ )
+    {
+        COLOR_SET(0);
+        hSync = 0;
+        
+        for (int tmp = 0; tmp < 90; tmp++) { // 206
+            __nop();
+        }
+      
+        hSync = 1;
+        
+        for (int tmp = 0; tmp < 110; tmp++) { // 206
+            __nop();
+        } 
+        
+        for( int j = 0; j < fbW; j++ )
+        {
+            unsigned char bp = framebuffer[ i / 2 ][ j ];
+            COLOR_SET(bp);
+            
+            soundPin = (hsync_count % soundNote < soundNoteHalf) ? 1 : 0;
+            
+            hsync_count++;
+            
+            __nop();
+            __nop();
+            __nop();    
+            __nop();
+            __nop();    
+            __nop();
+            __nop();
+        } 
+    }
+    COLOR_SET(0);  
+    
+    __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();  __nop();  //__nop();
+//    __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop(); __nop();
+    
+    vSync = 0;
+
+}
+
+int getButton(WiiClassicControllerReader* const ctrlr)
+{
+    //int bufSize = 0;
+    //char* bufPtr = NULL;
+    ctrlr->RequestRead();
+        
+    bool up = !ctrlr->getButtonDU();
+    if (up)   return 2;
+    
+    bool down = !ctrlr->getButtonDD();
+    if (down) return 0;
+    
+    bool left = !ctrlr->getButtonDL();
+    if (left) return 3;
+    
+    bool right = !ctrlr->getButtonDR(); 
+    if (right) return 1;
+    
+    if (!ctrlr->getButtonSTART()) {
+        game_paused = !game_paused;
+        wait(0.5);
+    }
+    
+    return -1;
+}
+
+// MBEDGC SNAKE BY J.P. ARMSTRONG WWW.JPARMSTRONG.COM
+// LICENSED UNDER GNU PUBLIC LICENSE.
+
+void setup() 
+{  
+        
+    drawStrings(28, 50, 28, "MBEDGC.COM");
+    
+    drawStrings(10, 70, 192, "JP. YIGAL. DANNY.");
+    drawStrings(12, 78, 192, "SHAIN. ALFREDO.");
+
+    wait(3);
+    blankFB();
+    
+    drawStrings(30, 50, 192, "FIU SENIOR");
+    drawStrings(28, 58, 192, "DESIGN 2011");
+
+    wait(3);
+    blankFB();
+    startGame();
+}
+
+void loop() 
+{
+    // KEEP THE SNAKE IN THE FRAMEBUFFER.
+    // IF IT'S CORD ARE BEYOND THE FRAMEBUFFER. ADJUST IT. 
+    if (snake_y <= 0)
+        snake_y = fbH - 1;
+    
+    if (snake_x <= 0)
+        snake_x = fbW - 1;
+        
+    snake_y %= fbH;
+    snake_x %= fbW;
+    
+    // GET VALUE FROM CONTROLLER
+    int tmp_sd;
+    do {
+       tmp_sd = getButton(&ctrlrA);
+    }
+    while (game_paused);
+    
+    // MAKE SURE BUTTON WAS PRESSED OTHERWISE IGNORE IT.
+    if (tmp_sd != -1) {
+            
+        // YOU CAN'T GO LEFT IF YOU'RE ALREADY GOING RIGHT AND VICE VERSA
+        // YOU CAN'T GO   UP IF YOU'RE ALREADY GOING DOWN AND VICE VERSA
+        if (!((snake_direction == 0 && tmp_sd == 2) || (snake_direction == 2 && tmp_sd == 0) ||
+              (snake_direction == 3 && tmp_sd == 1) || (snake_direction == 1 && tmp_sd == 3)  )) {
+            snake_direction = tmp_sd;
+        }
+    }
+    
+    // PRODUCE NO SOUND
+    soundNoteHalf = 0;
+    
+    // INCREMENT OR DECREMENT SNAKE'S COORD DEPENDING ON DIRECTION
+    switch (snake_direction) 
+    {
+        case 0:
+            snake_y += 2;
+            break;
+        case 2:
+            snake_y -= 2;
+            break;
+        case 1:
+            snake_x += 2;
+            break;
+        case 3:
+            snake_x -= 2;
+            break;
+    }
+    
+    // IF LOCATION SNAKE IS GOING IS AN APPLE. EAT IT.
+    if (framebuffer[snake_y][snake_x] == 3) {
+    
+        snake_apples_eaten++;
+        snake_length += 2;
+        
+        // DECREASE COUNTDOWN TIMER
+        logic_count -= 50;
+        
+        if (logic_count < 0)
+            logic_count = 0;
+        
+        score += 5;
+        
+        // BEEP
+        soundNote = 3100;
+        soundNoteHalf = 1550;
+        
+        // IF NO MORE APPLES ADD N MORE. "NEW LEVEL"
+        if (snake_apples_eaten % num_apples == 0) {
+            
+            score += (snake_apples_eaten / 10) * (100 - 100 * ((float) logic_count / 1000));
+            
+            soundNote = 2000;
+            soundNoteHalf = 1000;
+        
+            apples(num_apples);
+           
+        }
+        
+        drawNumbers(36, 105, 16, score);
+        
+    }
+    // IF NOT AN APPLE, AND NOT EMPTY SPACE, THE SNAKE EITHER
+    // HIT THE WALL OR IT ITSELF AND THE GAME IS LOST.
+    else if (framebuffer[snake_y][snake_x] != 0) {
+       
+        
+        endGame();
+        startGame();
+         
+       
+    }
+    else {
+        soundNote = 4000;
+        soundNoteHalf = 0;
+    }
+    
+    // ADVANCE THE SNAKE TO NEW POSITION
+    snake.addHead(snake_x, snake_y);
+    drawRectangle(snake_x, snake_y, 2, 2, snake_color);
+      
+    // REMOVE THE TAIL UNLESS IT ATE AN APPLE.
+    while (snake_length <= snake.getSize()) { 
+        drawRectangle(snake.getTailXCor(), snake.getTailYCor(), 2, 2, 0);
+        snake.removeTail();
+    }
+    
+    
+    // COUNT DOWN
+    logic_percent = (float) logic_count / 1000 ;
+    drawRectangle(60, 106, 48, 4 , 0); 
+     
+    if ((logic_percent * 100) < 75.0) {
+        drawRectangle(60, 106, 48 - 48 * logic_percent, 4 , 192); 
+    }
+    else {
+    
+        if ((logic_percent * 100) > 100) {
+            endGame();
+            startGame();
+         }
+        else {
+          drawRectangle(60, 106, 48 - 48 * logic_percent, 4 , 3);
+        }
+        
+        if (logic_count % 20 == 0) {
+            soundNote = 4000;
+            soundNoteHalf = 2000;
+        }
+        else {
+            soundNoteHalf = 0;
+        }
+   }
+
+   // ADD DELAY TO THE LOGIC
+   wait(0.05);
+}
+
+// SETUP A NEW GAME
+void startGame() {
+
+        // blank framebuffer
+        blankFB();
+        
+        // initialization variables
+        snake_x = 60;
+        snake_y = 12;
+        snake_direction = 0;    
+        snake_apples_eaten = 0;
+        snake_length = 10;
+        score = 0;
+
+        
+        // add apples
+        apples(num_apples);
+        
+        // add head to beginning of snake linked list
+        snake.addHead(snake_x, snake_y);
+
+        
+        // BLUE BORDERS
+        drawRectangle(4, 10, 2, 90, 16);
+        drawRectangle(4, 10, 104, 2, 16);
+        
+        drawRectangle(108, 10, 2, 90, 16);
+        drawRectangle(4, 100, 106, 2, 16);
+        
+        // COUNTDOWN
+        drawRectangle(59, 105, 50, 6 , 16); 
+        drawRectangle(60, 106, 48, 4 , 0); 
+        
+        logic_count = 0;
+        
+           
+       drawNumbers(36, 105, 16, score);
+     
+}
+
+void endGame() {
+    // blankFB();
+     
+     soundNote = 4000;
+     soundNoteHalf = soundNote / 2;
+        
+     wait(0.1); 
+        
+     soundNoteHalf = 0;
+ 
+     
+     drawStrings(30, 40, 192, "GAME OVER");
+     drawStrings(28, 50, 192, "MBEDGC.COM");
+     drawNumbers(73, 60, 192, score);
+  
+  wait(3);
+  blankFB();
+  wait(0.1);
+      
+  LocalFileSystem local("local");               // Create the local filesystem under the name "local"
+
+  FILE *fp = fopen("/local/hs.txt", "a");  // Open "out.txt" on the local file system for writing
+  
+  char buf[16];
+  sprintf(buf, "AMS\t%05d\r\n", score);
+  fprintf(fp, buf);
+  
+  fclose(fp);
+
+}
+
+void drawStrings(int x, int y, unsigned char color, string str) {
+    
+        for (int i = 0; i < str.size(); i++) {
+            drawCharacter( x + (6 * i), y, color, str[i]);
+        }
+    
+}
+
+void drawNumbers(int x, int y, unsigned char color, int num) {
+       
+        for (int i = 1; i <= 5; i++) {
+            drawCharacter( x - (6 * i), y, color, num % 10);
+            num /= 10;
+        }
+}
+
+// ADD N APPLES TO THE SCREEN
+void apples(int number) {
+    
+    int i = 0;
+    int x = 0, y = 0;
+    
+    do  {
+       x = 2 * (rand() % (90 / 2)) + 6;
+       y = 2 * (rand() % (86 / 2)) + 12;
+       
+       // MAKE SURE YOU DON'T ADD AN APPLE ON THE SNAKE OR WALL
+       if (framebuffer[y][x] == 0) {
+          drawRectangle(x, y, 2 , 2, 3);
+          i++;
+       }
+       
+    }
+    while (i < number);
+}
+
+
+DigitalOut mled0(LED1);
+DigitalOut mled1(LED2);
+DigitalOut mled2(LED3);
+DigitalOut mled3(LED4);
+
+
+int networking() {
+        
+  mled0 = 1;
+  
+  printf("Init\n");
+
+  printf("\r\nSetting up...\r\n");
+  EthernetErr ethErr = eth.setup();
+  
+  mled1 = 1;
+  
+  if(ethErr)
+  {
+    printf("Error %d in setup.\n", ethErr);
+  }
+  mled2 = 1;
+  printf("\r\nSetup OK\r\n");
+
+  HTTPClient twitter;
+  mled1 = 0;
+  
+  HTTPMap msg;
+  mled0 = 0;
+  msg["status"] = "I am tweeting from my mbedgc!"; //A good example of Key/Value pair use with Web APIs
+
+  twitter.basicAuth("mbedgc", "mbgc321"); //We use basic authentication, replace with you account's parameters
+  mled0 = 1;
+ 
+  //No need to retieve data sent back by the server
+  HTTPResult r = twitter.post("http://api.supertweet.net/1/statuses/update.xml", msg, NULL);
+   
+  if( r == HTTP_OK )
+  {
+    printf("Tweet sent with success!\n");
+    
+    mled3 = 1;
+  }
+  else
+  {
+    printf("Problem during tweeting, return code %d\n", r);
+    mled2 = 0;
+  }
+  
+  return 0;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/mbedgc.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,34 @@
+
+#include "mbed.h"
+#include "colors.h"
+#include "timers.h"
+#include "I2CConfig.h"
+#include "WiiClassicControllerReader.h"
+
+#define fbW 121//121 is max//129
+#define fbH 121//121
+
+DigitalOut vSync(p29);
+DigitalOut hSync(p30);
+DigitalOut soundPin(p18);
+
+int soundNote = 4000;
+int soundNoteHalf = 2000;
+unsigned int hsync_count = 0x80000;
+int hsync_count_adder = 1;
+int logic_count = 0;
+
+//Serial pc(USBTX, USBRX);
+DigitalOut led1(LED1);
+
+WiiClassicControllerReader ctrlrA(I2CPort_A::SDA, I2CPort_A::SCL);
+
+void fill(unsigned char);
+void setup();
+void loop();
+void blankFB();
+int getButton(WiiClassicControllerReader* const ctrlr);
+void drawRectangle(int x, int y, int width, int height, unsigned char color);
+
+unsigned int frame = 0;
+unsigned char framebuffer[fbH][fbW];
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/serial.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,189 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_SERIAL_H__
+#define __SIMPLELIB_SERIAL_H__
+
+#include "mbed_globals.h"
+#include "interrupts.h"
+
+/**********************************
+ *    Simple Serial Managment     *
+ **********************************
+ * The interrupt handler is :     *
+ * SERIAL_INTERRUPT_HANDLER(void) *
+ * UART0 : Serial over USB        *
+ * UART1 : TX p13, RX p14         *
+ * UART2 : TX p28, RX p27         *
+ * UART3 : TX p9,  RX p10         *
+ **********************************/
+ 
+/** Registers **/
+// Serial port (Choose UARTn (0,1,2,3))
+#define UART_NUMBER UART0
+#define UART_BASE TOKENPASTE2(LPC_,UART_NUMBER)
+
+// Peripheral Clock Selection registers (See 4.7.3 p56)
+#define UART0_PCLK_REG (LPC_SC->PCLKSEL0)
+#define UART1_PCLK_REG (LPC_SC->PCLKSEL0)
+#define UART2_PCLK_REG (LPC_SC->PCLKSEL1)
+#define UART3_PCLK_REG (LPC_SC->PCLKSEL1)
+#define UART_PCLK_REG  TOKENPASTE2(UART_NUMBER,_PCLK_REG)
+
+#define UART0_PCLK_OFFSET   6
+#define UART1_PCLK_OFFSET   8
+#define UART2_PCLK_OFFSET  16
+#define UART3_PCLK_OFFSET  18
+#define UART_PCLK_OFFSET   TOKENPASTE2(UART_NUMBER,_PCLK_OFFSET)
+
+#define UART0_PCLK ((LPC_SC->PCLKSEL0 >>  6) & 0x03)
+#define UART1_PCLK ((LPC_SC->PCLKSEL0 >>  8) & 0x03)
+#define UART2_PCLK ((LPC_SC->PCLKSEL1 >> 16) & 0x03)
+#define UART3_PCLK ((LPC_SC->PCLKSEL1 >> 18) & 0x03)
+#define UART_PCLK TOKENPASTE2(UART_NUMBER,_PCLK)
+
+// Pin Function Select register (See 8.5.1-8 p108)
+#define UART0RX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UART1RX_PINSEL_REG (LPC_PINCON->PINSEL1)
+#define UART2RX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UART3RX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UARTRX_PINSEL_REG  TOKENPASTE2(UART_NUMBER,RX_PINSEL_REG)
+
+#define UART0TX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UART1TX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UART2TX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UART3TX_PINSEL_REG (LPC_PINCON->PINSEL0)
+#define UARTTX_PINSEL_REG  TOKENPASTE2(UART_NUMBER,TX_PINSEL_REG)
+
+#define UART0RX_PINSEL_OFFSET   6
+#define UART1RX_PINSEL_OFFSET   0
+#define UART2RX_PINSEL_OFFSET  22
+#define UART3RX_PINSEL_OFFSET   2
+#define UARTRX_PINSEL_OFFSET    TOKENPASTE2(UART_NUMBER,RX_PINSEL_OFFSET)
+
+#define UART0TX_PINSEL_OFFSET   4
+#define UART1TX_PINSEL_OFFSET  30
+#define UART2TX_PINSEL_OFFSET  20
+#define UART3TX_PINSEL_OFFSET   0
+#define UARTTX_PINSEL_OFFSET    TOKENPASTE2(UART_NUMBER,TX_PINSEL_OFFSET)
+
+#define UART0_PINSEL_VALUE    1U
+#define UART1_PINSEL_VALUE    1U
+#define UART2_PINSEL_VALUE    1U
+#define UART3_PINSEL_VALUE    2U
+#define UART_PINSEL_VALUE     TOKENPASTE2(UART_NUMBER,_PINSEL_VALUE)
+
+/** Interrupt handlers **/
+#define SERIAL_INTERRUPT_HANDLER EXTERN_C void __IRQ TOKENPASTE2(UART_NUMBER,_IRQHandler)
+
+/** Bits **/
+// RBR Interrupt Enable (UnIER, 14.4.4 p302)
+#define RBR_INT_BIT 0
+// Receiver Data Ready (UnLSR, 14.4.8 p306)
+#define RDR_BIT 0
+// Transmitter Holding Register Empty (UnLSR, 14.4.8 p306)
+#define THRE_BIT 5
+// RBR Interrupt Enable (UnIER, 14.4.4 p302)
+#define SERIAL_INT_RX 1
+// THRE Interrupt Enable (UnIER, 14.4.4 p302)
+#define SERIAL_INT_TX 2
+// Divisor Latch Access Bit (UnLCR, 14.4.7 p306)
+#define DLA_BIT 7
+// Power Control for Peripherals (PCONP, 4.8.7.1 p63)
+#define UART0_PCONP_BIT  3
+#define UART1_PCONP_BIT  4
+#define UART2_PCONP_BIT 24
+#define UART3_PCONP_BIT 25
+
+/** Macros **/
+#define SERIAL_PUTCHAR(c)               do {                                                        \
+                                            while (GET_BIT_VALUE(UART_BASE->LSR, THRE_BIT) == 0);   \
+                                            UART_BASE->THR = c;                                     \
+                                        } while(0)
+
+#define SERIAL_DATA_TO_READ()           (GET_BIT_VALUE(UART_BASE->LSR, RDR_BIT) == 1)
+
+#define SERIAL_GETCHAR()                (UART_BASE->RBR)
+
+// Enable interrupt for RX or TX (SERIAL_INT_RX and SERIAL_INT_TX)
+#define SERIAL_ENABLE_INTERRUPT(value)  do {                                                    \
+                                            UART_BASE->IER = value;                             \
+                                            ENABLE_INTERRUPT(TOKENPASTE2(UART_NUMBER,_IRQn));   \
+                                        } while(0)
+
+extern __INLINE void SERIAL_INIT()
+{
+    // Enable UARTn
+    SET_BIT_VALUE(LPC_SC->PCONP, TOKENPASTE2(UART_NUMBER,_PCONP_BIT) , 1);
+    // Enable FIFO and reset RX/TX FIFO (See 14.4.6 p305)
+    UART_BASE->FCR = 0x07;
+    // 8-bits, No Parity, 1 stop bit (See 14.4.7 p306)
+    UART_BASE->LCR = 0x03;
+    // Set CCLK as Peripheral Clock for UART (96MHz with mbed library)
+    UART_PCLK_REG = (UART_PCLK_REG & (~(3UL << UART_PCLK_OFFSET))) | (1U << UART_PCLK_OFFSET);
+    // Define Pin's functions as UART
+    UARTRX_PINSEL_REG = (UARTRX_PINSEL_REG & (~(3U << UARTRX_PINSEL_OFFSET))) | (UART_PINSEL_VALUE << UARTRX_PINSEL_OFFSET);
+    UARTTX_PINSEL_REG = (UARTTX_PINSEL_REG & (~(3U << UARTTX_PINSEL_OFFSET))) | (UART_PINSEL_VALUE << UARTTX_PINSEL_OFFSET);
+}
+
+// See 14.4.5 p303
+extern __INLINE int SERIAL_CHECK_INTERRUPT(void) {
+    uint32_t serialStatus = UART_BASE->IIR;
+
+    if (serialStatus & 1) // IntStatus, 1 = No Interrupt is pending.
+        return 0;
+
+    serialStatus = (serialStatus >> 1) & 0x3; // IntId, 2 = More than threshold data to read, 6 = Some caracters to read
+    if (serialStatus != 2 && serialStatus != 6)
+        return 0;
+
+    return 1;
+}
+
+extern __INLINE void SERIAL_SETBAUD(unsigned int baud) {
+    // Peripheral Clock Selection register bit values (See Table 42, p57)
+    uint16_t divisorValue = (SystemCoreClock / 16 / baud);
+    #if 0
+        // Peripheral Clock for UART is set to CCLK in SERIAL_INIT. Divisor is then 1.
+        // Else, use code below
+        static int divisors[4] = { 4, 1, 2, 8 };
+        uint16_t divisorValue = ((SystemCoreClock / 16 / baud) / divisors[UART_PCLK]);
+    #endif
+    
+    UART_BASE->LCR |= (1 << DLA_BIT);
+    UART_BASE->DLM = (uint8_t) (divisorValue >> 8);
+    UART_BASE->DLL = (uint8_t)  divisorValue;
+    UART_BASE->LCR &= ~(1 << DLA_BIT);
+}
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/sprites.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,51 @@
+/* THE ALPHABET REPRESENTED IN BINARY FOR FRAMEBUFFER...
+
+EX: The number 0
+
+    01110 .. 0x0E
+    10001 .. 0x11
+    10001 .. 0x11
+    10001 .. 0x11
+    01110 .. 0x0E
+
+*/
+
+const unsigned char alphabet[38][5] = { 
+        {0x0E,0x11,0x11,0x11,0x0E},   // 0
+        {0x04,0x0C,0x04,0x04,0x0E},   // 1
+        {0x0E,0x11,0x06,0x18,0x1F},   // 2
+        {0x0E,0x01,0x06,0x01,0x0E},   // 3
+        {0x0A,0x12,0x1E,0x02,0x02},   // 4
+        {0x1F,0x10,0x1E,0x01,0x1E},   // 5
+        {0x0E,0x10,0x1E,0x11,0x0E},   // 6
+        {0x0E,0x02,0x02,0x04,0x04},   // 7
+        {0x0E,0x11,0x0E,0x11,0x0E},   // 8
+        {0x0E,0x11,0x0F,0x01,0x0E},   // 9
+        {0x04,0x0A,0x1F,0x11,0x11},
+        {0x1E,0x11,0x1E,0x11,0x1E},
+        {0x0E,0x11,0x10,0x11,0x0E},
+        {0x1E,0x11,0x11,0x11,0x1E},
+        {0x1F,0x10,0x1C,0x10,0x1F},
+        {0x1F,0x10,0x1C,0x10,0x10},
+        {0x0E,0x10,0x13,0x11,0x0E},
+        {0x11,0x11,0x1F,0x11,0x11},
+        {0x0E,0x04,0x04,0x04,0x0E},
+        {0x07,0x02,0x02,0x12,0x0E},
+        {0x11,0x12,0x1C,0x12,0x11},
+        {0x08,0x08,0x08,0x08,0x0E},
+        {0x11,0x1B,0x15,0x11,0x11},
+        {0x11,0x19,0x15,0x13,0x11},
+        {0x0E,0x11,0x11,0x11,0x0E},
+        {0x1E,0x11,0x1E,0x10,0x10},
+        {0x0E,0x11,0x11,0x13,0x0F},
+        {0x1E,0x11,0x1E,0x12,0x11},
+        {0x0F,0x10,0x1E,0x01,0x1E},
+        {0x1F,0x04,0x04,0x04,0x04},
+        {0x11,0x11,0x11,0x11,0x0F},
+        {0x11,0x11,0x11,0x0A,0x04},
+        {0x11,0x11,0x15,0x15,0x0A},
+        {0x11,0x0A,0x04,0x0A,0x11},
+        {0x11,0x0A,0x04,0x04,0x04},
+        {0x1F,0x02,0x04,0x08,0x1F},
+        {0x00,0x00,0x00,0x00,0x00},
+        {0x00,0x00,0x00,0x00,0x04} };
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbedGC/timers.h	Sat Apr 02 23:23:07 2011 +0000
@@ -0,0 +1,165 @@
+/*
+* Copyright or &#65533; or Copr. 2010, Thomas SOETE
+* 
+* Author e-mail: thomas@soete.org
+* Library website : http://mbed.org/users/Alkorin/libraries/SimpleLib/
+* 
+* This software is governed by the CeCILL license under French law and
+* abiding by the rules of distribution of free software.  You can  use, 
+* modify and/ or redistribute the software under the terms of the CeCILL
+* license as circulated by CEA, CNRS and INRIA at the following URL
+* "http://www.cecill.info". 
+* 
+* As a counterpart to the access to the source code and  rights to copy,
+* modify and redistribute granted by the license, users are provided only
+* with a limited warranty  and the software's author,  the holder of the
+* economic rights,  and the successive licensors  have only  limited
+* liability. 
+* 
+* In this respect, the user's attention is drawn to the risks associated
+* with loading,  using,  modifying and/or developing or reproducing the
+* software by the user in light of its specific status of free software,
+* that may mean  that it is complicated to manipulate,  and  that  also
+* therefore means  that it is reserved for developers  and  experienced
+* professionals having in-depth computer knowledge. Users are therefore
+* encouraged to load and test the software's suitability as regards their
+* requirements in conditions enabling the security of their systems and/or 
+* data to be ensured and,  more generally, to use and operate it in the 
+* same conditions as regards security. 
+* 
+* The fact that you are presently reading this means that you have had
+* knowledge of the CeCILL license and that you accept its terms.
+*/
+
+#ifndef __SIMPLELIB_TIMERS_H__
+#define __SIMPLELIB_TIMERS_H__
+
+#include "mbed_globals.h"
+#include "interrupts.h"
+
+/**********************************
+ *    Simple Timers Managment     *
+ **********************************
+ * The interrupt handler is :     *
+ * TIMERn_INTERRUPT_HANDLER(void) *
+ **********************************/
+
+/** Registers **/
+#define TIMER0_BASE (LPC_TIM0)
+#define TIMER1_BASE (LPC_TIM1)
+#define TIMER2_BASE (LPC_TIM2)
+#define TIMER3_BASE (LPC_TIM3)
+#define TIMER_BASE(timer) TOKENPASTE2(timer,_BASE)
+
+// Peripheral Clock Selection registers (See 4.7.3 p56)
+#define TIMER0_PCLK_REG (LPC_SC->PCLKSEL0)
+#define TIMER1_PCLK_REG (LPC_SC->PCLKSEL0)
+#define TIMER2_PCLK_REG (LPC_SC->PCLKSEL1)
+#define TIMER3_PCLK_REG (LPC_SC->PCLKSEL1)
+#define TIMER_PCLK_REG(timer)  TOKENPASTE2(timer,_PCLK_REG)
+
+#define TIMER0_PCLK_OFFSET   2
+#define TIMER1_PCLK_OFFSET   4
+#define TIMER2_PCLK_OFFSET  12
+#define TIMER3_PCLK_OFFSET  14
+#define TIMER_PCLK_OFFSET(timer)   TOKENPASTE2(timer,_PCLK_OFFSET)
+
+/** Interrupt handlers **/
+#define TIMER0_INTERRUPT_HANDLER TIMER_INTERRUPT_HANDLER(TIMER0)
+#define TIMER1_INTERRUPT_HANDLER TIMER_INTERRUPT_HANDLER(TIMER1)
+#define TIMER2_INTERRUPT_HANDLER TIMER_INTERRUPT_HANDLER(TIMER2)
+#define TIMER3_INTERRUPT_HANDLER TIMER_INTERRUPT_HANDLER(TIMER3)
+#define TIMER_INTERRUPT_HANDLER(timer) EXTERN_C void __IRQ TOKENPASTE2(timer,_IRQHandler)
+
+/** Bits **/
+// Power Control for Peripherals (PCONP, 4.8.7.1 p63)
+#define TIMER0_PCONP_BIT  1
+#define TIMER1_PCONP_BIT  2
+#define TIMER2_PCONP_BIT 22
+#define TIMER3_PCONP_BIT 23
+
+// Match Control Register (TnMCR, 21.6.8 p496)
+#define MATCH_INTERRUPT   1
+#define MATCH_RESET       2
+#define MATCH_STOP        4
+#define MR0_OFFSET        0
+#define MR1_OFFSET        3
+#define MR2_OFFSET        6
+#define MR3_OFFSET        9
+
+// Interrupt Register (TnIR, 21.6.1, p493)
+#define MR0_INT    (1U << 0)
+#define MR1_INT    (1U << 1)
+#define MR2_INT    (1U << 2)
+#define MR3_INT    (1U << 3)
+#define CR0_INT    (1U << 4)
+#define CR1_INT    (1U << 5)
+
+/** Macros **/
+// Enable TIMERn
+#define TIMER0_INIT() TIMER_INIT(TIMER0)
+#define TIMER1_INIT() TIMER_INIT(TIMER1)
+#define TIMER2_INIT() TIMER_INIT(TIMER2)
+#define TIMER3_INIT() TIMER_INIT(TIMER3)
+#define TIMER_INIT(timer)   do {                                                                                                   \
+                                SET_BIT_VALUE(LPC_SC->PCONP, TOKENPASTE2(timer,_PCONP_BIT) , 1); /* Enable Timer                */ \
+                                TIMER_BASE(timer)->TCR = 0x2;                                    /* Reset Timer, Table 427 p493 */ \
+                            } while(0)
+
+// Set Peripheral Clock
+#define TIMER0_SETPCLK(clk) TIMER_SETPCLK(TIMER0, clk)
+#define TIMER1_SETPCLK(clk) TIMER_SETPCLK(TIMER1, clk)
+#define TIMER2_SETPCLK(clk) TIMER_SETPCLK(TIMER2, clk)
+#define TIMER3_SETPCLK(clk) TIMER_SETPCLK(TIMER3, clk)
+#define TIMER_SETPCLK(timer, clk)  TIMER_PCLK_REG(timer) = ((TIMER_PCLK_REG(timer) & (~(3U << TIMER_PCLK_OFFSET(timer)))) | (clk << TIMER_PCLK_OFFSET(timer)))
+
+// Set Prescale Register
+#define TIMER0_SETPRESCALE(value) TIMER_SETPRESCALE(TIMER0, value)
+#define TIMER1_SETPRESCALE(value) TIMER_SETPRESCALE(TIMER1, value)
+#define TIMER2_SETPRESCALE(value) TIMER_SETPRESCALE(TIMER2, value)
+#define TIMER3_SETPRESCALE(value) TIMER_SETPRESCALE(TIMER3, value)
+#define TIMER_SETPRESCALE(timer, value)  TIMER_BASE(timer)->PR = (value)
+
+// Set Match Register (MR0-3, 21.6.7 p496)
+#define TIMER0_SETMATCH(id, value) TIMER_SETMATCH(TIMER0, id, value)
+#define TIMER1_SETMATCH(id, value) TIMER_SETMATCH(TIMER1, id, value)
+#define TIMER2_SETMATCH(id, value) TIMER_SETMATCH(TIMER2, id, value)
+#define TIMER3_SETMATCH(id, value) TIMER_SETMATCH(TIMER3, id, value)
+#define TIMER_SETMATCH(timer, id, value)  TIMER_BASE(timer)->TOKENPASTE2(MR,id) = (value)
+
+// Set Match Control Register (TnMCR, 21.6.8 p496)
+#define TIMER0_SETMATCHCONTROL(id, value) TIMER_SETMATCHCONTROL(TIMER0, id, value)
+#define TIMER1_SETMATCHCONTROL(id, value) TIMER_SETMATCHCONTROL(TIMER1, id, value)
+#define TIMER2_SETMATCHCONTROL(id, value) TIMER_SETMATCHCONTROL(TIMER2, id, value)
+#define TIMER3_SETMATCHCONTROL(id, value) TIMER_SETMATCHCONTROL(TIMER3, id, value)
+#define TIMER_SETMATCHCONTROL(timer, id, value)  TIMER_BASE(timer)->MCR = (value) << (MR ## id ## _OFFSET)
+
+// Enable interrupt for TIMERn
+#define TIMER0_ENABLE_INTERRUPT() TIMER_ENABLE_INTERRUPT(TIMER0)
+#define TIMER1_ENABLE_INTERRUPT() TIMER_ENABLE_INTERRUPT(TIMER1)
+#define TIMER2_ENABLE_INTERRUPT() TIMER_ENABLE_INTERRUPT(TIMER2)
+#define TIMER3_ENABLE_INTERRUPT() TIMER_ENABLE_INTERRUPT(TIMER3)
+#define TIMER_ENABLE_INTERRUPT(timer)  ENABLE_INTERRUPT(TOKENPASTE2(timer,_IRQn))
+
+// Interrut Register (TnIR, 21.6.1, p493)
+#define TIMER0_CLEAR_INTERRUPT(value) TIMER_CLEAR_INTERRUPT(TIMER0, value)
+#define TIMER1_CLEAR_INTERRUPT(value) TIMER_CLEAR_INTERRUPT(TIMER1, value)
+#define TIMER2_CLEAR_INTERRUPT(value) TIMER_CLEAR_INTERRUPT(TIMER2, value)
+#define TIMER3_CLEAR_INTERRUPT(value) TIMER_CLEAR_INTERRUPT(TIMER3, value)
+#define TIMER_CLEAR_INTERRUPT(timer, value)  TIMER_BASE(timer)->IR = (value)
+
+// Start Timer
+#define TIMER0_START() TIMER_START(TIMER0)
+#define TIMER1_START() TIMER_START(TIMER1)
+#define TIMER2_START() TIMER_START(TIMER2)
+#define TIMER3_START() TIMER_START(TIMER3)
+#define TIMER_START(timer)  TIMER_BASE(timer)->TCR = 0x1 /* Counter Enable, Table 427 p493*/
+
+// Get Timer Value
+#define TIMER0_VALUE() TIMER_VALUE(TIMER0)
+#define TIMER1_VALUE() TIMER_VALUE(TIMER1)
+#define TIMER2_VALUE() TIMER_VALUE(TIMER2)
+#define TIMER3_VALUE() TIMER_VALUE(TIMER3)
+#define TIMER_VALUE(timer)  (TIMER_BASE(timer)->TC)
+
+#endif
\ No newline at end of file