Johan Kritzinger / Mbed 2 deprecated FRDM_MMA8451Q_DTAP_DEMO

Dependencies:   MMA8451Q mbed

Embed: (wiki syntax)

« Back to documentation index

Show/hide line numbers main.cpp Source File

main.cpp

00001 #include "mbed.h"
00002 #include "MMA8451Q.h"
00003 
00004 #define MMA8451_I2C_ADDRESS (0x1d<<1)
00005 #define ON  0
00006 #define OFF !ON
00007 
00008 //Setup the interrupts for the MMA8451Q
00009 InterruptIn accInt1(PTA14);
00010 InterruptIn accInt2(PTA15);//not used in this prog but this is the other int from the accelorometer
00011 
00012 uint8_t togstat=0;//Led status
00013 DigitalOut bled(LED_BLUE);
00014 
00015 
00016 void tapTrue(void){
00017     if(togstat == 0){
00018         togstat = 1;
00019         bled=ON;
00020     } else {
00021         togstat = 0;
00022         bled=OFF;
00023     }
00024         
00025 }
00026 
00027 
00028 int main(void) {
00029 
00030     MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);//accelorometer instance
00031   
00032     acc.setDoubleTap();//Setup the MMA8451Q to look for a double Tap
00033     accInt1.rise(&tapTrue);//call tapTrue when an interrupt is generated on PTA14
00034     
00035     while (true) {
00036     //Interrupt driven so nothing in main loop
00037     }
00038 }