![](/media/cache/profiles/5c98b0539591b13b7ba78b3b614407ef.50x50_q85.jpg)
Demo program for using MMA8451Q double tap detection and responding to associated interrupt on the FRDM KL25Z board
Revision 0:c2d23138786f, committed 2013-03-10
- Comitter:
- JoKer
- Date:
- Sun Mar 10 04:41:35 2013 +0000
- Commit message:
- MMA8451Q Double Tap and Interrupt example for FRDM KL25Z board
Changed in this revision
diff -r 000000000000 -r c2d23138786f MMA8451Q.lib --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/MMA8451Q.lib Sun Mar 10 04:41:35 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/JoKer/code/MMA8451Q/#2d14600116fc
diff -r 000000000000 -r c2d23138786f main.cpp --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/main.cpp Sun Mar 10 04:41:35 2013 +0000 @@ -0,0 +1,38 @@ +#include "mbed.h" +#include "MMA8451Q.h" + +#define MMA8451_I2C_ADDRESS (0x1d<<1) +#define ON 0 +#define OFF !ON + +//Setup the interrupts for the MMA8451Q +InterruptIn accInt1(PTA14); +InterruptIn accInt2(PTA15);//not used in this prog but this is the other int from the accelorometer + +uint8_t togstat=0;//Led status +DigitalOut bled(LED_BLUE); + + +void tapTrue(void){ + if(togstat == 0){ + togstat = 1; + bled=ON; + } else { + togstat = 0; + bled=OFF; + } + +} + + +int main(void) { + + MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);//accelorometer instance + + acc.setDoubleTap();//Setup the MMA8451Q to look for a double Tap + accInt1.rise(&tapTrue);//call tapTrue when an interrupt is generated on PTA14 + + while (true) { + //Interrupt driven so nothing in main loop + } +}
diff -r 000000000000 -r c2d23138786f mbed.bld --- /dev/null Thu Jan 01 00:00:00 1970 +0000 +++ b/mbed.bld Sun Mar 10 04:41:35 2013 +0000 @@ -0,0 +1,1 @@ +http://mbed.org/users/mbed_official/code/mbed/builds/5e5da4a5990b \ No newline at end of file