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.
Diff: main.cpp
- Revision:
- 0:179836d5c9f5
- Child:
- 1:d77819d695e3
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/main.cpp Mon Oct 09 13:16:46 2017 +0000
@@ -0,0 +1,46 @@
+#include "mbed.h"
+#include "MMA8451Q.h"
+
+#define MMA8451_I2C_ADDRESS (0x1d<<1)
+#define XYZ_DATA_CFG (0x04<<1)
+#define FF_MT_CFG (0x38<<1)
+#define FF_MT_SRC 0x07
+
+
+Serial terminal(USBTX,USBRX);
+
+float xAxis;
+float yAxis;
+float zAxis;
+
+int freefall (){
+
+ if ((FF_MT_SRC >> 0x07) & 1){
+
+ //zavolaj obsluhu prerusenia
+ return 0;
+}
+
+ return 1;
+}
+
+
+
+ int main(void) {
+
+ MMA8451Q acc(PTE25, PTE24, MMA8451_I2C_ADDRESS);
+ terminal.printf("x y z\n\r");
+ while(true){
+ xAxis = acc.getAccX();
+ yAxis = acc.getAccY();
+ zAxis = acc.getAccZ();
+
+
+
+ wait(2.0);
+ terminal.printf("%1.2f, %1.2f, %1.2f,\n\r", xAxis, yAxis, zAxis);
+ }
+
+
+
+ }