#include "mbed.h"
#include "FXOS8700Q.h"
Serial pc(USBTX, USBRX);
I2C i2c(PTE25, PTE24);
FXOS8700QAccelerometer acc(i2c, FXOS8700CQ_SLAVE_ADDR1);
FXOS8700QMagnetometer mag(i2c, FXOS8700CQ_SLAVE_ADDR1);
int main(void)
{
motion_data_units_t acc_data, mag_data;
acc.enable();
mag.enable();
printf("FXOS8700QAccelerometer Who Am I= %X\r\n", acc.whoAmI());
printf("FXOS8700QMagnetometer Who Am I= %X\r\n", acc.whoAmI());
while (true)
{
acc.getAxis(acc_data);
mag.getAxis(mag_data);
printf("ACC: X=%1.4ff Y=%1.4ff Z=%1.4ff \t MAG: X=%4.1ff Y=%4.1ff Z=%4.1ff\r\n", acc_data.x, acc_data.y, acc_data.z, mag_data.x, mag_data.y, mag_data.z);
wait(5.0f);
}
}
|