Test program for MMA8451Q

Dependencies:   MMA8451Q mbed

Committer:
Rhyme
Date:
Fri Dec 25 07:23:26 2015 +0000
Revision:
0:b9f8aeb1c46b
Child:
1:61ac5dab9c3e
commit before publishing

Who changed what in which revision?

UserRevisionLine numberNew contents of line
Rhyme 0:b9f8aeb1c46b 1 #include "mbed.h"
Rhyme 0:b9f8aeb1c46b 2 #include "MMA8451Q.h"
Rhyme 0:b9f8aeb1c46b 3 #include "MSS.h"
Rhyme 0:b9f8aeb1c46b 4
Rhyme 0:b9f8aeb1c46b 5 MMA8451Q *acc = 0 ;
Rhyme 0:b9f8aeb1c46b 6
Rhyme 0:b9f8aeb1c46b 7 int main() {
Rhyme 0:b9f8aeb1c46b 8 int16_t ix, iy, iz ;
Rhyme 0:b9f8aeb1c46b 9 float fx, fy, fz ;
Rhyme 0:b9f8aeb1c46b 10
Rhyme 0:b9f8aeb1c46b 11 #if 1 // for FRDM-KL25Z ONBOARDSENSOR
Rhyme 0:b9f8aeb1c46b 12 acc = new MMA8451Q(PTE25, PTE24, 0x1D) ;
Rhyme 0:b9f8aeb1c46b 13 #endif
Rhyme 0:b9f8aeb1c46b 14 #if 0 // for MSU MMA8451Q on MSS
Rhyme 0:b9f8aeb1c46b 15 acc = new MMA8451Q(PIN_SDA, PIN_SCL, 0x1C) ;
Rhyme 0:b9f8aeb1c46b 16 #endif
Rhyme 0:b9f8aeb1c46b 17
Rhyme 0:b9f8aeb1c46b 18 while(1) {
Rhyme 0:b9f8aeb1c46b 19 ix = acc->getRawX() ;
Rhyme 0:b9f8aeb1c46b 20 iy = acc->getRawY() ;
Rhyme 0:b9f8aeb1c46b 21 iz = acc->getRawZ() ;
Rhyme 0:b9f8aeb1c46b 22 fx = acc->getAccX() ;
Rhyme 0:b9f8aeb1c46b 23 fy = acc->getAccY() ;
Rhyme 0:b9f8aeb1c46b 24 fz = acc->getAccZ() ;
Rhyme 0:b9f8aeb1c46b 25 printf("X = %d [ %.2f ], Y = %d [ %.2f ], Z = %d [ %.2f ]\n",
Rhyme 0:b9f8aeb1c46b 26 ix, fx, iy, fy, iz, fz ) ;
Rhyme 0:b9f8aeb1c46b 27 wait(0.2) ;
Rhyme 0:b9f8aeb1c46b 28 }
Rhyme 0:b9f8aeb1c46b 29 }