![](/media/cache/img/default_profile.jpg.50x50_q85.jpg)
Final
Tap.cpp
- Committer:
- pstephens18
- Date:
- 2016-01-20
- Revision:
- 0:5fd3f73db34f
File content as of revision 0:5fd3f73db34f:
// CS needs to be connected to High in order to do I2C #include "Tap.h" extern I2C acc; DigitalIn int2(p17); char acc_config[2]; const int addr=(0x53<<1); char data1[1]; char ack; Timer b; void Tap_init() { wait(0.1); acc_config[0]=0x31; acc_config[1]=0x0B; //data format ack = acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x2D; acc_config[1]=0x08; //power control->measure mode acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x1D; acc_config[1]=0x50; //Tap Threshold ->5g acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x21; acc_config[1]=0x10; //Tap duration -> 0.01 acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x2A; acc_config[1]=0x07; //Axis -> x&y&z acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x2E; acc_config[1]=0x40; //enable interupt -> single and double tap acc.write(addr,acc_config, 2); wait(0.1); acc_config[0]=0x2F; acc_config[1]=0x40; //map interupt ->int2 acc.write(addr,acc_config, 2); wait(0.1); } void Tap() { acc_config[0]=0x30; acc.write(addr,acc_config,1); acc.read(addr,data1,1); // Get interupt information }