October 31, 2012

LPC1114 GPIO example

A couple of exmaples for LPCXpresso are shown below.

1
Writing data
int myPort, myPin;

myPort = PORT3;
myPin = 2;

GPIOSetDir(myPort, myPin, 1);   /** Pay attention for the 1 value */
GPIOSetValue(myPort, myPin, 1);
2
Reading data
int myPort, myPin;

myPort = PORT2;
myPin = 9;

GPIOSetDir(myPort, myPin, 0);  /** Pay attention for the 0 value */

if ((LPC_GPIO2->DATA & (1 << myPin)) == 0)
{
  // onMyPinActive();
}