mma8451q driver

Dependents:   nRF51822_DataLogger_PowerImpulseCounter scpi_sx127x NAMote72_Utility scpi_sx127x_firstTest

Revision:
2:4bc96749141e
Parent:
1:778b685c3ad0
--- a/mma8451q.h	Fri May 08 01:31:18 2015 +0000
+++ b/mma8451q.h	Tue Sep 01 00:27:13 2015 +0000
@@ -11,6 +11,10 @@
 #define MMA8451_INT_SOURCE                 0x0c // 
 #define MMA8451_ID                         0x0d
 #define MMA8451_PL_STATUS                  0x10
+#define MMA8451_PL_CFG                     0x11
+#define MMA8451_PL_COUNT                   0x12 // orientation debounce
+#define MMA8451_PL_BF_ZCOMP                0x13
+#define MMA8451_PL_THS_REG                 0x14
 #define MMA8451_FF_MT_SRC                  0x16
 #define MMA8451_TRANSIENT_CFG              0x1d // transient enable
 #define MMA8451_TRANSIENT_SRC              0x1e // transient read/clear interrupt
@@ -46,6 +50,17 @@
     uint8_t octet;
 } mma_int_source_t;
 
+typedef union { 
+    struct {    // at 0x10
+        uint8_t BAFRO  : 1;    // 0     0=front, 1=back
+        uint8_t LAPO   : 2;    // 1,2   up, down, right, left
+        uint8_t res    : 3;    // 3,4,5
+        uint8_t LO     : 1;    // 6    Z-tilt lockout
+        uint8_t NEWLP  : 1;    // 7    1 = BAFRO or LO has changed
+    } bits;
+    uint8_t octet;
+} mma_pl_status_t;
+
 typedef union {
     struct {    // at 0x1d
         uint8_t HPF_BYP : 1;    // 0
@@ -123,8 +138,10 @@
         void read(uint8_t addr, uint8_t *dst_buf, int length);
         void write(uint8_t addr, uint8_t data);
         void transient_detect(void);
-        void service(void);
+        void orient_detect(void);
+        uint8_t service(void); // returns 0 if no interrupt occurred
 
+        bool verbose;   // print interrupt event
         mma_out_t out;
         transient_cfg_t transient_cfg;
         ctrl_reg1_t ctrl_reg1;