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.
Dependencies: FreescaleIAP MMA8451Q mbed
Diff: main.cpp
- Revision:
- 1:19cb7d77efe1
- Parent:
- 0:17f544fcad6f
- Child:
- 2:af202a1edd28
--- a/main.cpp Sat Sep 22 23:17:02 2018 +0000
+++ b/main.cpp Sun Sep 23 09:57:41 2018 +0000
@@ -40,7 +40,8 @@
} Accel_Data;
// --- Setup I2C for MMA8451
-MMA8451Q my8451(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+// --- The last argument is the full scale range (FSR). 0x00 for 2G, 0x01 for 4G, 0x02 for 8G
+MMA8451Q my8451(PTE25, PTE24, MMA8451_I2C_ADDRESS, 0x02);
// --- Set Serial Port
Serial Host_Comm(USBTX, USBRX); // tx, rxSerial pc(USBTX, USBRX); // tx, rx
@@ -231,6 +232,7 @@
int Flash_Ptr ;
uint8_t Data_Ptr;
Accel_Data myData[2];
+ uint8_t Ready;
int Led_Counter;
@@ -265,6 +267,12 @@
Led_Counter = 0;
Led_Blue = !Led_Blue;
}
+
+ Ready = 0;
+ while((Ready && 0x01) == 0) // Wait Accelerometer have new data's
+ {
+ Ready = my8451.Read_Status();
+ }
myData[Data_Ptr].X = my8451.getAccAxis(REG_OUT_X_MSB);
myData[Data_Ptr].Y = my8451.getAccAxis(REG_OUT_Y_MSB);