A simple example that uses the GPIO group and pin interrupts. LED1 turns on when P21 and P22 are grounded (using group 0 interrupt) LED1 turns of when P23 or P24 are grounded (using group 1 interrupt) LED2 turns on when P19 is grounded (using GPIO interrupt 0) LED2 turns off when P18 is grounded (using GPIO interrupt 1)
Diff: main.cpp
- Revision:
- 1:566ac56c130e
- Parent:
- 0:03be1abca74e
- Child:
- 2:7c8d0f7dd79f
--- a/main.cpp Fri May 18 16:51:07 2012 +0000 +++ b/main.cpp Sat May 19 23:33:19 2012 +0000 @@ -1,16 +1,24 @@ /************************************************************************************ Code created using the ARMwizard, visit http://alexan.edaboard.eu ************************************************************************************/ +/* +#include <LPC11Uxx.h> +*/ -#include <LPC11Uxx.h> +#include "mbed.h" + +#define LED1 1UL<<8 +#define LED2 1UL<<9 +#define LED3 1UL<<10 +#define LED4 1UL<<11 /****************************************************************************** GPIO group 0 interrupt service function ******************************************************************************/ -void GINT0_IRQHandler(void) { +extern "C" void GINT0_IRQHandler(void) { /* write code here */ -LPC_GPIO->SET[1] = 1UL<<8; +LPC_GPIO->SET[1] = LED1; LPC_GPIO_GROUP_INT0->CTRL |= (1UL<<0); /* Clear pin group 0 interrupt flag */ } @@ -18,9 +26,9 @@ /****************************************************************************** GPIO group 1 interrupt service function ******************************************************************************/ -void GINT1_IRQHandler(void) { +extern "C" void GINT1_IRQHandler(void) { /* write code here */ -LPC_GPIO->CLR[1] = 1UL<<8; +LPC_GPIO->CLR[1] = LED1; LPC_GPIO_GROUP_INT1->CTRL |= (1UL<<0); /* Clear pin group 1 interrupt flag */ } @@ -28,9 +36,9 @@ /****************************************************************************** GPIO pin interrupt 0 service function ******************************************************************************/ -void FLEX_INT0_IRQHandler(void) { +extern "C" void FLEX_INT0_IRQHandler(void) { /* write code here */ -LPC_GPIO->SET[1] = 1UL<<9; +LPC_GPIO->SET[1] = LED2; /* The following clears the pin interrupt flag when set to EDGE mode, if the pin is set the LEVEL sense then remove the line */ //LPC_GPIO_PIN_INT->IST = (1UL<<0); /* Clear RISING/FALLING EDGE interrupt flag */ @@ -39,9 +47,9 @@ /****************************************************************************** GPIO pin interrupt 1 service function ******************************************************************************/ -void FLEX_INT1_IRQHandler(void) { +extern "C" void FLEX_INT1_IRQHandler(void) { /* write code here */ -LPC_GPIO->CLR[1] = 1UL<<9; +LPC_GPIO->CLR[1] = LED2; /* The foillowing clears the pin interrupt flag when set to EDGE mode, if the pin is set the LEVEL sence then remove the line */ //LPC_GPIO_PIN_INT->IST = (1UL<<1); /* Clear RISING/FALLING EDGE interrupt flag */