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:
- 2:0e3b2bc65131
- Parent:
- 0:9db76e6c71ce
- Child:
- 3:7b8a744ac27a
--- a/InterruptMask.cpp Tue Feb 18 02:41:18 2014 +0000 +++ b/InterruptMask.cpp Tue Feb 18 15:41:47 2014 +0000 @@ -1,8 +1,13 @@ #include "InterruptMask.h" +//default constructor required, should not be use will yield error InterruptMask::InterruptMask(void){ + exit(1); }; - + +//Constructor to be used, initialize with any valid mbed pin (p5 thru p30 except pins 19-20) +//you will need one InterruptMask for every pin you want ot have control over. The constructor +//will only accept a valid pin, otherwise it will cause the prgram to exit with an error. InterruptMask::InterruptMask(int somePin){ switch(somePin){ case p5: @@ -50,22 +55,28 @@ } } + +//This method will mask (disable) any rising edge interrupts of the specified pin void InterruptMask::maskIntR(void){ (*(this->IOIntEnR)) &= this->mask; } + //This method will mask (disable) any faling edge interrupts of the specified pin void InterruptMask::maskIntF(void){ (*(this->IOIntEnF)) &= this->mask; } + //This method will unmask (enable) any rising edge interrupts of the specified pin void InterruptMask::unMaskIntR(void){ (*(this->IOIntEnR)) |= this->unmask; } + //This method will unmask (enable) any falling edge interrupts of the specified pin void InterruptMask::unMaskIntF(void){ (*(this->IOIntEnF)) |= this->unmask; } + //This method will clear any pending interrupts of the specified pin void InterruptMask::ClrInt(void){ (*(this->IOIntClr)) |= this->unmask; }