Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
InterruptMask.cpp
00001 //***************************************************************************// 00002 /* InterruptMask Library */ 00003 /* Napoleon Leoni, February 18,2014*/ 00004 /* This class enables masking a GPIO interrupt from a specific MBED pin */ 00005 // Note to get the actual pin number in the LPC of an mbed pin in P0 00006 // simply do pN-P0_0, for example p12-P0_0=17, that is pin 12 in the mbed 00007 // corresponds to Port[0].17 or bit 17 of port 0. 00008 //***************************************************************************// 00009 // Example Code is in the header file: InterruptMask.h // 00010 #include "InterruptMask.h" 00011 00012 //default constructor required, should not be use will yield error 00013 InterruptMask::InterruptMask(void){ 00014 exit(1); 00015 }; 00016 00017 //Constructor to be used, initialize with any valid mbed pin (p5 thru p30 except pins 19-20) 00018 //you will need one InterruptMask for every pin you want ot have control over. The constructor 00019 //will only accept a valid pin, otherwise it will cause the prgram to exit with an error. 00020 InterruptMask::InterruptMask(PinName somePin){ 00021 switch(somePin){ 00022 case p5: 00023 case p6: 00024 case p7: 00025 case p8: 00026 case p9: 00027 case p10: 00028 case p11: 00029 case p12: 00030 case p13: 00031 case p14: 00032 case p15: 00033 case p16: 00034 case p17: 00035 case p18: 00036 //These pins are in Port 0 of the LPC1768, so the proper register is selected below 00037 IOIntEnF = &(LPC_GPIOINT->IO0IntEnF); 00038 IOIntEnR = &(LPC_GPIOINT->IO0IntEnR); 00039 IOIntClr = &(LPC_GPIOINT->IO0IntClr); 00040 this->mPin=somePin; //assign pin to internal member variable 00041 mask=~(1<<( (this->mPin)-P0_0)); 00042 unmask=~mask; 00043 break; 00044 case p21: 00045 case p22: 00046 case p23: 00047 case p24: 00048 case p25: 00049 case p26: 00050 case p27: 00051 case p28: 00052 case p29: 00053 case p30: 00054 //These pins are in Port 2 of the LPC1768, so the proper register is selected below 00055 IOIntEnF = &(LPC_GPIOINT->IO2IntEnF); 00056 IOIntEnR = &(LPC_GPIOINT->IO2IntEnR); 00057 IOIntClr = &(LPC_GPIOINT->IO2IntClr); 00058 this->mPin=somePin; //assign pin to internal member variable 00059 mask=~(1<<( (this->mPin)-P2_0)); 00060 unmask=~mask; 00061 break; 00062 default: 00063 exit(1); 00064 } 00065 } 00066 00067 00068 //This method will mask (disable) any rising edge interrupts of the specified pin 00069 void InterruptMask::maskIntR(void){ 00070 (*(this->IOIntEnR)) &= this->mask; 00071 } 00072 00073 //This method will mask (disable) any faling edge interrupts of the specified pin 00074 void InterruptMask::maskIntF(void){ 00075 (*(this->IOIntEnF)) &= this->mask; 00076 } 00077 00078 //This method will unmask (enable) any rising edge interrupts of the specified pin 00079 void InterruptMask::unMaskIntR(void){ 00080 (*(this->IOIntEnR)) |= this->unmask; 00081 } 00082 00083 //This method will unmask (enable) any falling edge interrupts of the specified pin 00084 void InterruptMask::unMaskIntF(void){ 00085 (*(this->IOIntEnF)) |= this->unmask; 00086 } 00087 00088 //This method will clear any pending interrupts of the specified pin 00089 void InterruptMask::ClrInt(void){ 00090 (*(this->IOIntClr)) |= this->unmask; 00091 } 00092
Generated on Sat Jul 16 2022 06:30:35 by
1.7.2