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.
main.cpp
- Committer:
- skirmish
- Date:
- 2016-12-18
- Revision:
- 11:95e4e04a7dd2
- Parent:
- 9:97b26dcd1035
- Child:
- 12:1c7b59097090
File content as of revision 11:95e4e04a7dd2:
#include "mbed.h" #include "model.h" #include "structures.h" #include "Serial.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); Timer tms; Serial pc(USBTX,USBRX); Model *mModel=new Model(&pc); char breakEm[1]; void tapTrue(void){ if(togstat == 0){ breakEm[0]=0x01; mModel->sendPacket(0xa0,0xf,0x00,breakEm,1); togstat = 1; bled=ON; } else { breakEm[0]=0x00; togstat = 0; bled=OFF; } } int main() { 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(1) { mModel->doSomething(mModel->getSourceAdd()); }; }