Library to interface MMA8451Q sensor

Dependents:   LELEC_2811_Accelerometer_2 LELEC_2811_Multiple_Sensors LELEC_2811_acquiring_data LELEC_2811_acquiring_data_working

Revision:
1:51c9ede6bb48
Parent:
0:2a71c4ec3ee2
--- a/MMA8451Q.cpp	Sat Sep 22 23:15:49 2018 +0000
+++ b/MMA8451Q.cpp	Sun Sep 23 09:57:19 2018 +0000
@@ -27,14 +27,13 @@
 
 #define UINT14_MAX        16383
 
-MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
+MMA8451Q::MMA8451Q(PinName sda, PinName scl, int addr, uint8_t fsr) : m_i2c(sda, scl), m_addr(addr) {
     
     // Place the peripheral in standby mode to configure the full scale range
     uint8_t data[2] = {REG_CTRL_REG_1, 0x00};
     writeRegs(data, 2);
     
     // Set the scale
-    uint8_t fsr = 0x02;
     setScale(fsr);
     
     // Activate the peripheral
@@ -96,6 +95,13 @@
     writeRegs(data, 8);
 }
 
+uint8_t MMA8451Q::Read_Status()
+{
+    uint8_t Status;
+    readRegs(0, &Status, 1);
+    return Status;
+}
+
 void MMA8451Q::readRegs(int addr, uint8_t * data, int len) {
     char t[1] = {addr};
     m_i2c.write(m_addr, t, 1, true);