Library designed as an interface to the mbed Pin Connect Block

Files at this revision

API Documentation at this revision

Comitter:
Blaze513
Date:
Tue Nov 29 05:08:41 2011 +0000
Child:
1:e9f239e90ef4
Commit message:
initial release

Changed in this revision

PinConnectBlock.c Show annotated file Show diff for this revision Revisions of this file
PinConnectBlock.h 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 annotated file Show diff for this revision Revisions of this file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinConnectBlock.c	Tue Nov 29 05:08:41 2011 +0000
@@ -0,0 +1,416 @@
+#include "PinConnectBlock.h"
+
+unsigned char PinConnectBlock::ValidateInput(
+    unsigned char Port, unsigned char Pin, unsigned char Mode)
+{
+    switch (Port)
+    {
+        case 0:
+            if (Pin < 2)
+            {
+                return 0x00;
+            }
+            if ((Pin > 3) && (Pin < 12))
+            {
+                return 0x00;
+            }
+            if ((Pin > 14) && (Pin < 19))
+            {
+                return 0x00;
+            }
+            if ((Pin > 22) && (Pin < 27))
+            {
+                return 0x00;
+            }
+            if ((Mode & 0x03) != 0x03)
+            {
+                if (Pin < 4)
+                {
+                    return 0x00;
+                }
+                if ((Pin > 26) && (Pin < 29) && !(Mode & 0x1C))
+                {
+                    return 0x00;
+                }
+            }
+            if ((Pin > 18) && (Pin < 23) && ((Mode & 0x03) != 0x02))
+            {
+                return 0x00;
+            }
+            if ((Pin > 28) && (Pin < 31) && !(Mode & 0x0E))
+            {
+                return 0x00;
+            }
+            if (Pin < 4)
+            {
+                return 0x0C;
+            }
+            if (Pin < 15)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin < 23)
+            {
+                return 0x0C;
+            }
+            if (Pin < 29)
+            {
+                return (((Mode & 0x03) == 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin < 31)
+            {
+                return ((Mode & 0x02) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00);
+            }
+            if (Pin > 30)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            break;
+        case 1:
+            if ((Pin > 17) && (Pin < 25))
+            {
+                return 0x00;
+            }
+            if ((Pin > 25) && (Pin < 30))
+            {
+                return 0x00;
+            }
+            if (!(Mode & 0x02))
+            {
+                if (Pin < 2)
+                {
+                    return 0x00;
+                }
+                if (Pin == 4)
+                {
+                    return 0x00;
+                }
+                if ((Pin > 7) && (Pin < 11))
+                {
+                    return 0x00;
+                }
+                if ((Pin > 13) && (Pin < 18))
+                {
+                    return 0x00;
+                }
+            }
+            if ((Pin == 25) && ((Mode & 0x03) != 0x02))
+            {
+                return 0x00;
+            }
+            if ((Pin > 29) && (Pin < 32) && ((Mode & 0x03) != 0x01))
+            {
+                return 0x00;
+            }
+            if (Pin < 2)
+            {
+                return 0x0C;
+            }
+            if (Pin < 4)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin == 4)
+            {
+                return 0x0C;
+            }
+            if (Pin < 8)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin < 11)
+            {
+                return 0x0C;
+            }
+            if (Pin < 14)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin < 18)
+            {
+                return 0x0C;
+            }
+            if ((Pin == 25) && ((Mode & 0x03) == 0x02))
+            {
+                return 0x0C;
+            }
+            if ((Pin > 29) && (Pin < 32) && ((Mode & 0x03) == 0x01))
+            {
+                return 0x0C;
+            }
+            if (Pin > 31)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            break;
+        case 2:
+            if ((Pin > 7) && (Pin < 10))
+            {
+                return 0x00;
+            }
+            if ((Pin < 11) && ((Mode & 0x03) != 0x03))
+            {
+                return 0x00;
+            }
+            if ((Pin > 10) && (Pin < 14) && ((Mode & 0x03) != 0x02))
+            {
+                return 0x00;
+            }
+            if (Pin < 14)
+            {
+                return 0x0C;
+            }
+            if (Pin > 13)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            break;
+        case 3:
+            if (Pin == 26)
+            {
+                return 0x00;
+            }
+            if ((Pin == 25) && ((Mode & 0x03) != 0x01))
+            {
+                return 0x00;
+            }
+            if (Pin < 25)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin == 25)
+            {
+                return 0x0C;
+            }
+            if (Pin > 26)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            break;
+        case 4:
+            if ((Pin > 27) && (Pin < 30))
+            {
+                return 0x00;
+            }
+            if (Pin < 28)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            if (Pin > 29)
+            {
+                return 0x02 | ((Mode & 0x03) ? 0x0C : 0x00)
+                    | ((Mode & 0x0C) ? 0x14 : 0x00)
+                    | ((Mode & 0x10) ? 0x24 : 0x00);
+            }
+            break;
+        default:
+            return 0x01 | ((Pin > 31) ? 0x02 : 0x00)
+                | ((Mode & 0x03) ? 0x0C : 0x00)
+                | ((Mode & 0x0C) ? 0x14 : 0x00)
+                | ((Mode & 0x10) ? 0x24 : 0x00);
+    }
+    return 0xFF;
+}
+
+void PinConnectBlock::SetPinConnection(
+    unsigned char Port, unsigned char Pin, unsigned char Mode)
+{
+    if (!((Port == 1) && (Pin < 18) && (Mode & 0x02)))
+    {
+        SetFunctionMode(Port, Pin, Mode & 0x03);
+    }
+    if (!((Port == 0) && (Pin > 26)))
+    {
+        SetResistorMode(Port, Pin, (Mode & 0x0C) >> 2);
+    }
+    if (!((Port == 0) && (Pin > 26) && (Pin < 29)))
+    {
+        SetOpenDrainMode(Port, Pin, Mode & 0x10);
+    }
+    return;
+}
+
+unsigned char PinConnectBlock::GetPinConnection(
+    unsigned char Port, unsigned char Pin)
+{
+    return GetFunctionMode(Port, Pin)
+        | (GetResistorMode(Port, Pin) << 2)
+        | (GetOpenDrainMode(Port, Pin) ? 0x10 : 0x00);
+}
+
+void PinConnectBlock::SetFunctionMode(
+    unsigned char Port, unsigned char Pin, unsigned char Mode)
+{
+    Port *= 2;
+    if (Pin >= 16)
+    {
+        Port++;
+        Pin -= 16;
+    }
+    Pin *= 2;
+    *((unsigned long*)&LPC_PINCON->PINSEL0 + Port)
+        &= ~(0x00000003 << Pin);
+    *((unsigned long*)&LPC_PINCON->PINSEL0 + Port)
+        |= (unsigned long)Mode << Pin;
+}
+
+unsigned char PinConnectBlock::GetFunctionMode(
+    unsigned char Port, unsigned char Pin)
+{
+    Port *= 2;
+    if (Pin >= 16)
+    {
+        Port++;
+        Pin -= 16;
+    }
+    Pin *= 2;
+    return (*((unsigned long*)&LPC_PINCON->PINSEL0 + Port)
+        & (0x00000003 << Pin)) >> Pin;
+}
+
+void PinConnectBlock::SetResistorMode(
+    unsigned char Port, unsigned char Pin, unsigned char Mode)
+{
+    Port *= 2;
+    if (Pin >= 16)
+    {
+        Port++;
+        Pin -= 16;
+    }
+    Pin *= 2;
+    *((unsigned long*)&LPC_PINCON->PINMODE0 + Port)
+        &= ~(0x00000003 << Pin);
+    *((unsigned long*)&LPC_PINCON->PINMODE0 + Port)
+        |= (unsigned long)Mode << Pin;
+    return;
+}
+
+unsigned char PinConnectBlock::GetResistorMode(
+    unsigned char Port, unsigned char Pin)
+{
+    Port *= 2;
+    if (Pin >= 16)
+    {
+        Port++;
+        Pin -= 16;
+    }
+    Pin *= 2;
+    return (*((unsigned long*)&LPC_PINCON->PINMODE0 + Port)
+        & (0x00000003 << Pin)) >> Pin;
+}
+
+void PinConnectBlock::SetOpenDrainMode(
+    unsigned char Port, unsigned char Pin, bool Mode)
+{
+    if (Mode)
+    {
+        *((unsigned long*)&LPC_PINCON->PINMODE_OD0 + Port)
+            |= 0x00000001 << Pin;
+    }
+    else
+    {
+        *((unsigned long*)&LPC_PINCON->PINMODE_OD0 + Port)
+            &= ~(0x00000001 << Pin);
+    }
+    return;
+}
+
+bool PinConnectBlock::GetOpenDrainMode(unsigned char Port, unsigned char Pin)
+{
+    return (*((unsigned long*)&LPC_PINCON->PINMODE_OD0 + Port)
+        & (0x00000001 << Pin)) >> Pin;
+}
+
+void PinConnectBlock::SetTraceMode(bool Mode)
+{
+    if (Mode)
+    {
+        LPC_PINCON->PINSEL10 |= 0x00000008;
+    }
+    else
+    {
+        LPC_PINCON->PINSEL10 &= ~0x00000008;
+    }
+    return;
+}
+
+bool PinConnectBlock::GetTraceMode()
+{
+    return (LPC_PINCON->PINSEL10 & 0x00000008) != 0x00000000;
+}
+
+void PinConnectBlock::SetI2C0Mode(unsigned char Mode)
+{
+
+    if (!(Mode & 0x01))
+    {
+        LPC_PINCON->I2CPADCFG |= 0x0000000A;
+    }
+    else
+    {
+        LPC_PINCON->I2CPADCFG &= ~0x0000000A;
+    }
+    if (Mode & 0x02)
+    {
+        LPC_PINCON->I2CPADCFG |= 0x00000005;
+    }
+    else
+    {
+        LPC_PINCON->I2CPADCFG &= ~0x00000005;
+    }
+    return;
+}
+
+unsigned char PinConnectBlock::GetI2C0Mode()
+{
+    unsigned char Result = 0x00;
+
+    if (!(LPC_PINCON->I2CPADCFG & 0x0000000A))
+    {
+        Result |= 0x01;
+    }
+    else if (!(LPC_PINCON->I2CPADCFG & 0x00000002))
+    {
+        Result |= 0x04;
+    }
+    else if (!(LPC_PINCON->I2CPADCFG & 0x00000008))
+    {
+        Result |= 0x08;
+    }
+    if ((LPC_PINCON->I2CPADCFG & 0x00000005) == 0x00000005)
+    {
+        Result |= 0x02;
+    }
+    else if (LPC_PINCON->I2CPADCFG & 0x00000001)
+    {
+        Result |= 0x10;
+    }
+    else if (LPC_PINCON->I2CPADCFG & 0x00000004)
+    {
+        Result |= 0x20;
+    }
+    return Result;
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/PinConnectBlock.h	Tue Nov 29 05:08:41 2011 +0000
@@ -0,0 +1,189 @@
+#ifndef LPC1768PinConnectBlockLibrary
+#define LPC1768PinConnectBlockLibrary
+
+#include "cmsis.h"
+
+#ifdef __cplusplus
+extern "C"
+{
+#endif
+
+namespace PinConnectBlock
+{
+    unsigned char ValidateInput(
+        unsigned char Port, unsigned char Pin, unsigned char Mode);
+        //This function accepts a Port number, Pin number, and Mode code for
+        //a pin that is to be connected to microcontroller hardware.  It
+        //validates the input for future use as input to connection setting
+        //functions.  It will check for the validity of the Port and Pin and
+        //the validity of the Function, Resistor, and Open Drain mode
+        //selections for a valid Port and Pin.  The Mode codes are specified
+        //as follows:
+        //
+        //Bits 7:5 - Reserved       ------------------------------------------
+        //Bit   4  - OpenDrain Mode |   See documentation for the mapping of |
+        //Bits 3:2 - Resistor Mode  | mode code values to connections.  The  |
+        //Bits 1:0 - Function Mode  | reserved bits must be 0.               |
+        //                          ------------------------------------------
+        //The return value is a code with flags to alert the user of errors in
+        //the input.  The errors are specified as follows:
+        //
+        //Bits 7:6 - Reserved
+        //Bit   5  - OpenDrain Mode
+        //Bit   4  - Resistor Mode  ------------------------------------------
+        //Bit   3  - Function Mode  |   A value of 0 indicates there are no  |
+        //Bit   2  - Mode           | errors.  A value of 1 indicates an     |
+        //Bit   1  - Pin            | error in the input corresponding with  |
+        //Bit   0  - Port           | that bit.  Reserved bits will be 0.    |
+        //                          ------------------------------------------
+    void SetPinConnection(
+        unsigned char Port, unsigned char Pin, unsigned char Mode);
+        //This function accepts a Port number, Pin number, and Mode code and
+        //connects the selected Pin on the selected Port to the hardware
+        //specified in the Mode code.  This function will not check for the
+        //validity of the input and will write to a reserved or unrelated
+        //sector if an invalid Port and Pin are specified.  It will reject any
+        //portion of the Mode code that connects 1.0:1.17 to functions 10 or
+        //11, 0.27:0.30 to resistor hardware, or 0.27:0.28 to open drain mode
+        //hardware, and will complete any valid connections in the Mode code.
+        //The Mode codes are specified as follows:
+        //
+        //Bits 7:5 - Reserved       ------------------------------------------
+        //Bit   4  - OpenDrain Mode |   See documentation for the mapping of |
+        //Bits 3:2 - Resistor Mode  | mode code values to connections.  The  |
+        //Bits 1:0 - Function Mode  | reserved bits must be 0.               |
+        //                          ------------------------------------------
+    unsigned char GetPinConnection(
+        unsigned char Port, unsigned char Pin);
+        //This function accepts a Port number and Pin number and returns a
+        //mode code that specifies the hardware connected to the selected Pin
+        //on the selected Port.  This function will not check for the validity
+        //of the input and will return junk bits from a reserved or unrelated
+        //sector if an invalid Port and Pin are specified.  The Mode codes are
+        //specified as follows:
+        //
+        //Bits 7:5 - Reserved       ------------------------------------------
+        //Bit   4  - OpenDrain Mode |   See documentation for the mapping of |
+        //Bits 3:2 - Resistor Mode  | mode code values to connections.  The  |
+        //Bits 1:0 - Function Mode  | reserved bits must be 0.               |
+        //                          ------------------------------------------
+    void SetFunctionMode(
+        unsigned char Port, unsigned char Pin, unsigned char Mode);
+        //This function accepts a Port number, Pin number, and Mode code and
+        //connects the selected Pin on the selected Port to the function
+        //hardware specified in the Mode code.  This function will not check
+        //for the validity of the input and will write to a reserved or
+        //non-function mode sector if an invalid Port and Pin are specified.
+        //Mode codes are specified as follows:
+        //                          ------------------------------------------
+        //                          |   See documentation for the mapping of |
+        //Bits 7:2 - Reserved       | mode code values to connections.  The  |
+        //Bits 1:0 - Function Mode  | reserved bits and modes must be 0.     |
+        //                          ------------------------------------------
+    unsigned char GetFunctionMode(unsigned char Port, unsigned char Pin);
+        //This function accepts a Port number and Pin number and returns a
+        //mode code that specifies the function hardware connected to the
+        //selected Pin on the selected Port.  This function will not check for
+        //the validity of the input and will return junk bits from a reserved
+        //or non-function mode sector if an invalid Port and Pin are
+        //specified.  The Mode codes are specified as follows:
+        //                          ------------------------------------------
+        //                          |   See documentation for the mapping of |
+        //Bits 2:7 - Reserved       | mode code values to connections.  The  |
+        //Bits 1:0 - Function Mode  | reserved bits will be 0.               |
+        //                          ------------------------------------------
+    void SetResistorMode(
+        unsigned char Port, unsigned char Pin, unsigned char Mode);
+        //This function accepts a Port number, Pin number, and Mode code and
+        //connects the selected Pin on the selected Port to the resistor
+        //hardware specified in the Mode code.  This function will not check
+        //for the validity of the input and will write to a reserved or
+        //non-resistor mode sector if an invalid Port and Pin are specified.
+        //The Mode codes are       -------------------------------------------
+        //specified as follows:    | Value - Connection                      |
+        //                         |-----------------------------------------|
+        //                         |   00  - Pull Up Resistor                |
+        //                         |   01  - Repeater Mode                   |
+        //Bits 7:2 - Reserved      |   10  - No Resistor                     |
+        //Bits 1:0 - Resistor Mode |   11  - Pull Down Resistor              |
+        //                         -------------------------------------------
+    unsigned char GetResistorMode(unsigned char Port, unsigned char Pin);
+        //This function accepts a Port number and Pin number and returns a
+        //mode code that specifies the resistor hardware connected to the
+        //selected Pin on the selected Port.  This function will not check for
+        //the validity of the input and will return junk bits from a reserved
+        //or non-resistor mode sector if an invalid Port and Pin are
+        //specified.  The Mode     -------------------------------------------
+        //codes are specified as   | Value - Connection                      |
+        //follows:                 |-----------------------------------------|
+        //                         |   00  - Pull Up Resistor                |
+        //                         |   01  - Repeater Mode                   |
+        //Bits 7:2 - Reserved      |   10  - No Resistor                     |
+        //Bits 1:0 - Resistor Mode |   11  - Pull Down Resistor              |
+        //                         -------------------------------------------
+    void SetOpenDrainMode(
+        unsigned char Port, unsigned char Pin, bool Mode);
+        //This function accepts a Port number, Pin number, and Mode bit and
+        //connects or disconnects the open drain hardware for the selected Pin
+        //on the selected Port.  A 0 will disconnect the open drain hardware,
+        //and a 1 will connect the open drain hardware.  This function will
+        //not check for the validity of the input before making a connection,
+        //and will write to a reserved or non-open drain mode sector if an
+        //invalid Port and Pin are specified.
+    bool GetOpenDrainMode(unsigned char Port, unsigned char Pin);
+        //This function accepts a Port number and Pin number and returns a
+        //mode bit that specifies the resistor hardware that is connected to
+        //the selected Pin on the selected Port.  A value of 0 indicates that
+        //the open drain hardware is disconnected, and a value of 1 indicates
+        //that the open drain hardware is connected.  This function will not
+        //check for the validity of the input and will return a junk bit from
+        //a reserved or non-open drain sector if an invalid Port and Pin are
+        //specified.
+    void SetTraceMode(bool Mode);
+        //This function accepts a Mode bit and connects or disconnects the
+        //trace port hardware.  A value of 0 will disconnect the trace port
+        //hardware, and a value of 1 will connect the trace port hardware.
+        //The trace port uses pins 2.2:2.6, and will override any function,
+        //resistor, or open drain hardware connected to these pins.
+    bool GetTraceMode();
+        //This function returns a mode bit that specifies the current
+        //connection status of the trace port.  A value of 0 indicates that
+        //the trace port is disconnected, and a value of 1 indicates that the
+        //trace port is connected.
+    void SetI2C0Mode(unsigned char Mode);
+        //This function accepts a Mode code and connects or disconnects
+        //specialized I2C hardware to the I2C0 bus on pins 0.27:0.28.  The
+        //Mode codes are specified as follows:
+        //                     -----------------------------------------------
+        //Bit 1: I2C Fast Mode |   A value of 0 will disconnect the hard-    |
+        //Bit 0: I2C Filter    | ware, and a value of 1 will connect it.     |
+        //                     -----------------------------------------------
+        //For non-I2C of these pins, the Filter and Fast Mode hardware should
+        //be disconnected.  For normal I2C use of these pins, the Filter
+        //hardware should be connected and the Fast Mode hardware should be
+        //disconnected.  For I2C Fast Mode, the Filter hardware and Fast Mode
+        //hardware should both be connected.
+    unsigned char GetI2C0Mode();
+        //This function returns a mode code that specifies the current
+        //connection status of the I2C0 bus with its specialized I2C hardware.
+        //The first two bits indicate the current hardware connection, and
+        //the next four bits indicate errors in the connection.  The
+        //connection status of SCL pin 0.28 must mach that of SDA pin 0.27.
+        //If this is not the case, the bus will not function properly and the
+        //function will return an error code.  The I2C Mode codes are
+        //specified as follows:                   ----------------------------
+        //                                        |   A value of o indicates |
+        //Bit 5: Error - Only SCL Fast Mode is On | the hardware is discon-  |
+        //Bit 4: Error - Only SDA Fast Mode is On | nected or the error is   |
+        //Bit 3: Error - Only SCL Filter is On    | not present.  A value of |
+        //Bit 2: Error - Only SDA Filter is On    | 1 indicates the hardware |
+        //Bit 1: I2C Fast Mode                    | is connected or the      |
+        //Bit 0: I2C Filter                       | error is present.        |
+        //                                        ----------------------------
+}
+
+#ifdef __cplusplus
+}
+#endif
+
+#endif
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp	Tue Nov 29 05:08:41 2011 +0000
@@ -0,0 +1,293 @@
+#include "mbed.h"
+#include "PinConnectBlock.h"
+
+Serial myComputer(USBTX, USBRX);
+void interruptHandler1(void)
+{   myComputer.printf("Testing Pin 1 |"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-");
+    wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-");
+    wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("|");     }
+void interruptHandler2(void)
+{   myComputer.printf("Testing Pin 2 |"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-");
+    wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-");
+    wait(1); myComputer.printf("-"); wait(1); myComputer.printf("-"); wait(1); myComputer.printf("|");     }
+void checkFunctRegisters()
+{
+    for (int i = 0; i < 10; i++)
+    {
+        myComputer.printf("\r\nPinselReg %d:\r\n\t", i);
+        for (int j = 0; j < 4; j++)
+        {
+            myComputer.printf("%X ", *((char*)((unsigned long*)&LPC_PINCON->PINSEL0 + i) + j));
+        }
+    }
+}
+void checkResistRegisters()
+{
+    for (int i = 0; i < 10; i++)
+    {
+        myComputer.printf("\r\nPinmodReg %d:\r\n\t", i);
+        for (int j = 0; j < 4; j++)
+        {
+            myComputer.printf("%X ", *((char*)((unsigned long*)&LPC_PINCON->PINMODE0 + i) + j));
+        }
+    }
+}
+void checkODMRegisters()
+{
+    for (int i = 0; i < 5; i++)
+    {
+        myComputer.printf("\r\nPinmodODReg %d:\r\n\t", i);
+        for (int j = 0; j < 4; j++)
+        {
+            myComputer.printf("%X ", *((char*)((unsigned long*)&LPC_PINCON->PINMODE_OD0 + i) + j));
+        }
+    }
+}
+void checkTMRegister()
+{
+    myComputer.printf("\r\nPinselTMReg:\r\n\t");
+    for (int j = 0; j < 4; j++)
+    {
+        myComputer.printf("%X ", *((char*)&LPC_PINCON->PINSEL10 + j));
+    }
+}
+void checkI2CRegister()
+{
+    myComputer.printf("\r\nI2CPADReg:\r\n\t");
+    for (int j = 0; j < 4; j++)
+    {
+        myComputer.printf("%X ", *((char*)&LPC_PINCON->I2CPADCFG + j));
+    }
+}
+
+int main ()
+{
+    PinConnectBlock::SetPinConnection(2, 11, 0x01);
+    NVIC_SetVector(EINT1_IRQn, (uint32_t)interruptHandler1);
+    NVIC_SetPriority(EINT1_IRQn, 1);
+    NVIC_EnableIRQ(EINT1_IRQn);
+
+    /*InterruptIn hardint(p30);
+    hardint.rise(&interruptHandler2);
+    NVIC_SetPriority(EINT3_IRQn, 0);*/
+
+    /*unsigned char result;
+    for (int i = 1; i < 7; i++)
+    {
+        myComputer.printf("Port %d:\r\n", i);
+        for (int j = 0; j < 35; j++)
+        {
+            myComputer.printf("\tPin %d:\r\n", j);
+            for (int k = 0; k < 4; k++)
+            {
+                result = PinConnectBlock::ValidateInput(i, j, k);
+                myComputer.printf("\t\tMode %d: %d ", k, result);
+                result = PinConnectBlock::ValidateInput(i, j, k | 0x0C);
+                myComputer.printf("Mode %d: %d ", k | 0x0C, result);
+                result = PinConnectBlock::ValidateInput(i, j, k | 0x10);
+                myComputer.printf("Mode %d: %d \r\n", k | 0x10, result);
+                result = PinConnectBlock::ValidateInput(i, j, k | 0x14);
+                myComputer.printf("Mode %d: %d \r\n", k | 0x14, result);
+            }
+        }
+    }*/
+
+    /*PinConnectBlock::SetPinConnection(2, 11, 0x13);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 2.11 Mode: %X\r\n\r\n", PinConnectBlock::GetPinConnection(2, 11));
+    PinConnectBlock::SetPinConnection(2, 11, 0x0C);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 2.11 Mode: %X\r\n\r\n", PinConnectBlock::GetPinConnection(2, 11));
+    PinConnectBlock::SetPinConnection(2, 11, 0x1F);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 2.11 Mode: %X\r\n\r\n", PinConnectBlock::GetPinConnection(2, 11));
+    PinConnectBlock::SetPinConnection(2, 11, 0x00);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 2.11 Mode: %X\r\n\r\n", PinConnectBlock::GetPinConnection(2, 11));
+    PinConnectBlock::SetPinConnection(2, 11, 0x01);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 2.11 Mode: %X\r\n\r\n", PinConnectBlock::GetPinConnection(2, 11));
+    PinConnectBlock::SetPinConnection(1, 10, 0x02);
+    PinConnectBlock::SetPinConnection(0, 28, 0x1F);
+    PinConnectBlock::SetPinConnection(0, 29, 0x1F);
+    checkFunctRegisters();
+    checkResistRegisters();
+    checkODMRegisters();*/
+
+    /*PinConnectBlock::SetFunctionMode(1, 18, 0x02);
+    PinConnectBlock::SetFunctionMode(1, 20, 0x03);
+    checkFunctRegisters();
+    myComputer.printf("\r\nPin 3.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(4, 29));
+    myComputer.printf("\r\nPin 3.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(3, 25));
+    myComputer.printf("\r\nPin 2.11 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(2, 11));
+    myComputer.printf("\r\nPin 1.18 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 18));
+    myComputer.printf("\r\nPin 1.20 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 20));
+    myComputer.printf("\r\nPin 1.0 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 0));
+    myComputer.printf("\r\nPin 0.15 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(0, 15));
+    myComputer.printf("\r\nPin 0.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(0, 25));
+    PinConnectBlock::SetFunctionMode(4, 29, 0x01);
+    PinConnectBlock::SetFunctionMode(3, 25, 0x02);
+    PinConnectBlock::SetFunctionMode(2, 11, 0x01);
+    PinConnectBlock::SetFunctionMode(1, 0, 0x01);
+    PinConnectBlock::SetFunctionMode(0, 15, 0x02);
+    PinConnectBlock::SetFunctionMode(0, 25, 0x03);
+    PinConnectBlock::SetFunctionMode(1, 18, 0x00);
+    PinConnectBlock::SetFunctionMode(1, 20, 0x00);
+    checkFunctRegisters();
+    myComputer.printf("\r\nPin 3.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(4, 29));
+    myComputer.printf("\r\nPin 3.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(3, 25));
+    myComputer.printf("\r\nPin 2.11 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(2, 11));
+    myComputer.printf("\r\nPin 1.18 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 18));
+    myComputer.printf("\r\nPin 1.20 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 20));
+    myComputer.printf("\r\nPin 1.0 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(1, 0));
+    myComputer.printf("\r\nPin 0.15 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(0, 15));
+    myComputer.printf("\r\nPin 0.25 Fmode: %d\r\n\r\n", PinConnectBlock::GetFunctionMode(0, 25));*/
+
+    /*PinConnectBlock::SetResistorMode(1, 18, 0x00);
+    PinConnectBlock::SetResistorMode(1, 20, 0x03);
+    checkResistRegisters();
+    myComputer.printf("\r\nPin 0.0 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(0, 0));
+    myComputer.printf("\r\nPin 0.15 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(0, 15));
+    myComputer.printf("\r\nPin 1.18 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 18));
+    myComputer.printf("\r\nPin 1.20 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 20));
+    myComputer.printf("\r\nPin 1.31 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 31));
+    myComputer.printf("\r\nPin 2.0 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(2, 0));
+    myComputer.printf("\r\nPin 3.26 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(3, 26));
+    myComputer.printf("\r\nPin 4.28 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(4, 28));
+    PinConnectBlock::SetResistorMode(0, 0, 0x01);
+    PinConnectBlock::SetResistorMode(0, 15, 0x02);
+    PinConnectBlock::SetResistorMode(1, 18, 0x03);
+    PinConnectBlock::SetResistorMode(1, 20, 0x00);
+    PinConnectBlock::SetResistorMode(1, 31, 0x01);
+    PinConnectBlock::SetResistorMode(2, 0, 0x02);
+    PinConnectBlock::SetResistorMode(3, 26, 0x03);
+    PinConnectBlock::SetResistorMode(4, 28, 0x01);
+    checkResistRegisters();
+    myComputer.printf("\r\nPin 0.0 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(0, 0));
+    myComputer.printf("\r\nPin 0.15 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(0, 15));
+    myComputer.printf("\r\nPin 1.18 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 18));
+    myComputer.printf("\r\nPin 1.20 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 20));
+    myComputer.printf("\r\nPin 1.31 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(1, 31));
+    myComputer.printf("\r\nPin 2.0 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(2, 0));
+    myComputer.printf("\r\nPin 3.26 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(3, 26));
+    myComputer.printf("\r\nPin 4.28 Rmode: %d\r\n\r\n", PinConnectBlock::GetResistorMode(4, 28));*/
+
+    /*PinConnectBlock::SetOpenDrainMode(3, 26, 1);
+    PinConnectBlock::SetOpenDrainMode(3, 25, 1);
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 0.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 0));
+    myComputer.printf("\r\nPin 0.11 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 11));
+    myComputer.printf("\r\nPin 0.15 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 15));
+    myComputer.printf("\r\nPin 0.26 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 26));
+    myComputer.printf("\r\nPin 0.29 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 29));
+    myComputer.printf("\r\nPin 0.30 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 30));
+    myComputer.printf("\r\nPin 1.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(1, 0));
+    myComputer.printf("\r\nPin 1.31 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(1, 31));
+    myComputer.printf("\r\nPin 2.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(2, 0));
+    myComputer.printf("\r\nPin 2.13 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(2, 13));
+    myComputer.printf("\r\nPin 3.25 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(3, 25));
+    myComputer.printf("\r\nPin 3.26 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(3, 26));
+    myComputer.printf("\r\nPin 4.28 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(4, 28));
+    myComputer.printf("\r\nPin 4.29 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(4, 29));
+    PinConnectBlock::SetOpenDrainMode(0, 0, 1);
+    PinConnectBlock::SetOpenDrainMode(0, 11, 1);
+    PinConnectBlock::SetOpenDrainMode(0, 15, 1);
+    PinConnectBlock::SetOpenDrainMode(0, 26, 1);
+    PinConnectBlock::SetOpenDrainMode(0, 29, 1);
+    PinConnectBlock::SetOpenDrainMode(0, 30, 1);
+    PinConnectBlock::SetOpenDrainMode(1, 0, 1);
+    PinConnectBlock::SetOpenDrainMode(1, 31, 1);
+    PinConnectBlock::SetOpenDrainMode(2, 0, 1);
+    PinConnectBlock::SetOpenDrainMode(2, 13, 1);
+    PinConnectBlock::SetOpenDrainMode(3, 25, 0);
+    PinConnectBlock::SetOpenDrainMode(3, 26, 0);
+    PinConnectBlock::SetOpenDrainMode(4, 28, 1);
+    PinConnectBlock::SetOpenDrainMode(4, 29, 1);
+    checkODMRegisters();
+    myComputer.printf("\r\nPin 0.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 0));
+    myComputer.printf("\r\nPin 0.11 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 11));
+    myComputer.printf("\r\nPin 0.15 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 15));
+    myComputer.printf("\r\nPin 0.26 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 26));
+    myComputer.printf("\r\nPin 0.29 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 29));
+    myComputer.printf("\r\nPin 0.30 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(0, 30));
+    myComputer.printf("\r\nPin 1.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(1, 0));
+    myComputer.printf("\r\nPin 1.31 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(1, 31));
+    myComputer.printf("\r\nPin 2.0 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(2, 0));
+    myComputer.printf("\r\nPin 2.13 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(2, 13));
+    myComputer.printf("\r\nPin 3.25 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(3, 25));
+    myComputer.printf("\r\nPin 3.26 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(3, 26));
+    myComputer.printf("\r\nPin 4.28 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(4, 28));
+    myComputer.printf("\r\nPin 4.29 ODmode: %d\r\n\r\n", PinConnectBlock::GetOpenDrainMode(4, 29));*/
+
+    /*checkTMRegister();
+    myComputer.printf("\r\nTrace mode: %d\r\n\r\n", PinConnectBlock::GetTraceMode());
+    PinConnectBlock::SetTraceMode(1);
+    checkTMRegister();
+    myComputer.printf("\r\nTrace mode: %d\r\n\r\n", PinConnectBlock::GetTraceMode());
+    PinConnectBlock::SetTraceMode(0);
+    checkTMRegister();
+    myComputer.printf("\r\nTrace mode: %d\r\n\r\n", PinConnectBlock::GetTraceMode());*/
+
+    /*checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    PinConnectBlock::SetI2C0Mode(0x03);
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    PinConnectBlock::SetI2C0Mode(0x01);
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    PinConnectBlock::SetI2C0Mode(0x02);
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    PinConnectBlock::SetI2C0Mode(0x00);
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG |= 0x00000001;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG |= 0x00000003;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG |= 0x00000007;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG &= ~0x0000000F;
+    LPC_PINCON->I2CPADCFG |= 0x00000008;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG |= 0x0000000C;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());
+    LPC_PINCON->I2CPADCFG |= 0x0000000E;
+    checkI2CRegister();
+    myComputer.printf("\r\nI2C0mode: %d\r\n\r\n", PinConnectBlock::GetI2C0Mode());*/
+
+    DigitalOut led1(LED1);
+    DigitalOut led2(LED2);
+    DigitalOut led3(LED3);
+    DigitalOut led4(LED4);
+    while (1)
+    {
+        led1 = !led1;
+        wait_ms(250);
+        led2 = !led2;
+        wait_ms(250);
+        led3 = !led3;
+        wait_ms(250);
+        led4 = !led4;
+        wait_ms(250);
+
+        NVIC_SetPendingIRQ(EINT1_IRQn);
+        wait(10);
+    }
+}
\ No newline at end of file
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/mbed.bld	Tue Nov 29 05:08:41 2011 +0000
@@ -0,0 +1,1 @@
+http://mbed.org/users/mbed_official/code/mbed/builds/63bcd7ba4912