if ( GPIOGetPinValue( 0, 6) == 0) { // If bit 6 is low set bit 13 high, otherwise set bit 13 low
GPIOSetBitValue( 0, 13, 1 );
} else {
GPIOSetBitValue( 0, 13, 0 );
}
|
if ( GPIOGetBitValue( 0, 6) == 0) { // If bit 6 is low set bit 13 high, otherwise set bit 13 low
GPIOSetBitValue( 0, 13, 1 );
} else {
GPIOSetBitValue( 0, 13, 0 );
}
|
/* Set port p0.6 to input */ GPIOSetDir( 0, 6, 0 ); |
if ( GPIO[color=#f00]Set[/color]BitValue( 0, 6, 0 ) == 0) " GIVING ERROR" |
#ifdef __USE_CMSIS
#include "LPC8xx.h"
#endif
void SwitchMatrix_Init()
{
/* Enable the clock to the Switch Matrix */
LPC_SYSCON->SYSAHBCLKCTRL |= ( 1 << 7 );
/* Pin Assign 1 bit Configuration */
/* SWCLK */
/* SWDIO */
/* XTALIN */
/* XTALOUT */
/* RESET */
LPC_SWM->PINENABLE0 = 0xffffff83UL;
}
void IOCON_Init()
{
/* Enable IOCON clock */
LPC_SYSCON->SYSAHBCLKCTRL |= ( 1 << 18 );
}
int main(void)
{
// Configure the switch matrix
SwitchMatrix_Init();
LPC_IOCON->PIO0_10 = 0x80; // Xtal In
LPC_IOCON->PIO0_11 = 0x80; // Xtal Out
LPC_IOCON->PIO0_6 = 0x90; // Input1
LPC_IOCON->PIO0_7 = 0x90; // Input1
LPC_IOCON->PIO0_13 = 0x90; // Output pin
/* Enable the clock to the Switch Matrix */
LPC_SYSCON->SYSAHBCLKCTRL |= ( 1 << 7);
while(1) {
if ( LPC_IOCON->PIO0_6 || LPC_IOCON->PIO0_7 < 1 ) { // <-- this is most likely not doing what you want it to do
(LPC_IOCON->PIO0_13 = 0);
}
}
}
|