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.
Diff: InterruptMask.cpp
- Revision:
- 0:9db76e6c71ce
- Child:
- 2:0e3b2bc65131
--- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/InterruptMask.cpp Tue Feb 18 02:29:52 2014 +0000 @@ -0,0 +1,72 @@ +#include "InterruptMask.h" + +InterruptMask::InterruptMask(void){ + }; + +InterruptMask::InterruptMask(int somePin){ + switch(somePin){ + case p5: + case p6: + case p7: + case p8: + case p9: + case p10: + case p11: + case p12: + case p13: + case p14: + case p15: + case p16: + case p17: + case p18: + //These pins are in Port 0 of the LPC1768, so the proper register is selected below + IOIntEnF = &(LPC_GPIOINT->IO0IntEnF); + IOIntEnR = &(LPC_GPIOINT->IO0IntEnR); + IOIntClr = &(LPC_GPIOINT->IO0IntClr); + this->mPin=somePin; //assign pin to internal member variable + mask=~(1<<( (this->mPin)-P0_0)); + unmask=~mask; + break; + case p21: + case p22: + case p23: + case p24: + case p25: + case p26: + case p27: + case p28: + case p29: + case p30: + //These pins are in Port 0 of the LPC1768, so the proper register is selected below + IOIntEnF = &(LPC_GPIOINT->IO2IntEnF); + IOIntEnR = &(LPC_GPIOINT->IO2IntEnR); + IOIntClr = &(LPC_GPIOINT->IO2IntClr); + this->mPin=somePin; //assign pin to internal member variable + mask=~(1<<( (this->mPin)-P2_0)); + unmask=~mask; + break; + default: + exit(1); + } +} + + void InterruptMask::maskIntR(void){ + (*(this->IOIntEnR)) &= this->mask; + } + + void InterruptMask::maskIntF(void){ + (*(this->IOIntEnF)) &= this->mask; + } + + void InterruptMask::unMaskIntR(void){ + (*(this->IOIntEnR)) |= this->unmask; + } + + void InterruptMask::unMaskIntF(void){ + (*(this->IOIntEnF)) |= this->unmask; + } + + void InterruptMask::ClrInt(void){ + (*(this->IOIntClr)) |= this->unmask; + } +