InterruptMask library allows masking/unmasking GPIO interrupts (attached to either the rise or falling edges). It also allows clearing pending interrupts which may come handy before unmasking them.
Revision 4:a34eddd0a2be, committed 2014-02-19
- Comitter:
- nleoni
- Date:
- Wed Feb 19 04:35:24 2014 +0000
- Parent:
- 3:7b8a744ac27a
- Commit message:
- Updated comments in main CPP file
Changed in this revision
InterruptMask.cpp | Show annotated file Show diff for this revision Revisions of this file |
InterruptMask.h | Show annotated file Show diff for this revision Revisions of this file |
diff -r 7b8a744ac27a -r a34eddd0a2be InterruptMask.cpp --- a/InterruptMask.cpp Tue Feb 18 15:44:49 2014 +0000 +++ b/InterruptMask.cpp Wed Feb 19 04:35:24 2014 +0000 @@ -1,3 +1,12 @@ +//***************************************************************************// +/* InterruptMask Library */ +/* Napoleon Leoni, February 18,2014*/ +/* This class enables masking a GPIO interrupt from a specific MBED pin */ +// Note to get the actual pin number in the LPC of an mbed pin in P0 +// simply do pN-P0_0, for example p12-P0_0=17, that is pin 12 in the mbed +// corresponds to Port[0].17 or bit 17 of port 0. +//***************************************************************************// +// Example Code is in the header file: InterruptMask.h // #include "InterruptMask.h" //default constructor required, should not be use will yield error @@ -42,7 +51,7 @@ case p28: case p29: case p30: - //These pins are in Port 0 of the LPC1768, so the proper register is selected below + //These pins are in Port 2 of the LPC1768, so the proper register is selected below IOIntEnF = &(LPC_GPIOINT->IO2IntEnF); IOIntEnR = &(LPC_GPIOINT->IO2IntEnR); IOIntClr = &(LPC_GPIOINT->IO2IntClr);
diff -r 7b8a744ac27a -r a34eddd0a2be InterruptMask.h --- a/InterruptMask.h Tue Feb 18 15:44:49 2014 +0000 +++ b/InterruptMask.h Wed Feb 19 04:35:24 2014 +0000 @@ -1,39 +1,41 @@ +//***************************************************************************// /* InterruptMask Library */ +/* Napoleon Leoni, February 18,2014*/ /* This class enables masking a GPIO interrupt from a specific MBED pin*/ // Note to get the actual pin number in the LPC of an mbed pin in P0 // simply do pN-P0_0, for example p12-P0_0=17, that is pin 12 in the mbed // corresponds to Port[0].17 or bit 17 of port 0. //***************************************************************************// -/* Example usage */ -/* >#include "InterruptMask.h" -/* >InterruptIn upPressed(p15); -/* >InterruptMask maskUpButtonInt(p15); //Interrupt mask object allows easy access to -/* > //mask/unmask interrupts from a GPIO source -/* >void ISRup(void){ -/*> myled1=!myled1; -/*>} -/*>int main() { -/*> upPressed.rise(&ISRup); -/*> //downPressed.rise(&ISRdown); -/*> bool disableInterrupt=false; -/*> int counter=0,tdelay=10; -/*> -/*> while (1) { -/*> //This section of code periodically (every 10 seconds) masks the specified GPIO interrupt -/*> //showing how to both mask it and unmask it as well as how to clear pending interrupts -/*> counter++; -/*> if(counter>=tdelay){ -/*> disableInterrupt=!disableInterrupt; -/*> if(disableInterrupt) maskUpButtonInt.maskIntR() ; //mask interrupt -/*> if(!disableInterrupt){ -/*> maskUpButtonInt.ClrInt(); //clear any pending interrupt before unmasking -/*> maskUpButtonInt.unMaskIntR(); //unmask interrupt -/*> } -/*> counter=0; -/*> } -/*> } -/*>} -*/ +//* Example usage */ +//* >#include "InterruptMask.h" +//* >InterruptIn upPressed(p15); +//* >InterruptMask maskUpButtonInt(p15); //Interrupt mask object allows easy access to +//* > //mask/unmask interrupts from a GPIO source +//* >void ISRup(void){ +//*> myled1=!myled1; +//*>} +//*>int main() { +//*> upPressed.rise(&ISRup); +//*> //downPressed.rise(&ISRdown); +//*> bool disableInterrupt=false; +//*> int counter=0,tdelay=10; +//*> +//*> while (1) { +//*> //This section of code periodically (every 10 seconds) masks the specified GPIO interrupt +//*> //showing how to both mask it and unmask it as well as how to clear pending interrupts +//*> counter++; +//*> if(counter>=tdelay){ +//*> disableInterrupt=!disableInterrupt; +//*> if(disableInterrupt) maskUpButtonInt.maskIntR() ; //mask interrupt +//*> if(!disableInterrupt){ +//*> maskUpButtonInt.ClrInt(); //clear any pending interrupt before unmasking +//*> maskUpButtonInt.unMaskIntR(); //unmask interrupt +//*> } +//*> counter=0; +//*> } +//*> } +//*>} + // // TESTS RUN // // I print to the LCD three important LPC1768 registers: