MR raw bit

Fork of MMA8451Q by Emilio Monti

Revision:
5:56050102ef00
Parent:
3:db7126dbd63f
--- a/MMA8451Q.cpp	Fri Oct 12 11:35:07 2012 +0000
+++ b/MMA8451Q.cpp	Mon Feb 20 08:43:35 2017 +0000
@@ -23,8 +23,17 @@
 #define REG_OUT_X_MSB     0x01
 #define REG_OUT_Y_MSB     0x03
 #define REG_OUT_Z_MSB     0x05
+#define XYZ_DATA_CFG      0x0E
 
 #define UINT14_MAX        16383
+#define MAX_2G            0x00
+#define MAX_4G            0X01
+#define MAX_8G            0X10
+
+#define GSCALING          1024.0
+#define                            //define property that will return all bits
+
+
 
 MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
     // activate the peripheral
@@ -32,6 +41,18 @@
     writeRegs(data, 2);
 }
 
+void MMA8451Q::setGLImit()
+{
+    uint8_t data[2] = {EEG_CTRL_REG_1, 0X00};
+    writeRegs(data, 2); //put in standby
+    data[0] = XYZ_DATA_CFG;
+    data[1] = 0x02;
+    writeRegs(data, 2);
+    data[0] = REG_CTRL_REG_1;
+    data[1] = 0x01;
+    writeRegs(data, 2); //make active
+}
+
 MMA8451Q::~MMA8451Q() { }
 
 uint8_t MMA8451Q::getWhoAmI() {
@@ -78,4 +99,7 @@
 
 void MMA8451Q::writeRegs(uint8_t * data, int len) {
     m_i2c.write(m_addr, (char *)data, len);
+
+    //return the values to be able to read
+    return {m_addr, (char *) data, len};
 }