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.
Fork of MMA8451Q8_v1 by
Revision 8:993bb9e96a4b, committed 2015-02-03
- Comitter:
- scohennm
- Date:
- Tue Feb 03 17:59:00 2015 +0000
- Parent:
- 7:ed7e11d269f8
- Child:
- 9:84011f06d1ea
- Commit message:
- set pulse configuraton
Changed in this revision
| MMA8451Q8.cpp | Show annotated file Show diff for this revision Revisions of this file |
| MMA8451Q8.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/MMA8451Q8.cpp Wed Jan 28 21:39:04 2015 +0000
+++ b/MMA8451Q8.cpp Tue Feb 03 17:59:00 2015 +0000
@@ -26,6 +26,9 @@
#define REG_OUT_Y_MSB 0x03
#define REG_OUT_Z_MSB 0x05
#define XYZ_DATA_CFG 0x0E
+// adding tap config register adderesses
+#define REG_PULSE_SRC 0x22
+#define REG_PULSE_CFG 0x21
#define UINT14_MAX 16383
@@ -64,7 +67,21 @@
data[DATA_INDEX] = 0x01;
writeRegs(data, 2); // make active
}
-
+// add Puse configuratioin register access
+// Also add function prototype to .h file
+void MMA8451Q::setPulseConfiguration(uint8_t latch,uint8_t axisSet) {
+ uint8_t configBits;
+ uint8_t data[NUM_DATA] = {REG_CTRL_REG_1, 0x00}; // put in standby mode
+// set up configuration bits.
+ configBits = latch | axisSet;
+ writeRegs(data, NUM_DATA); // put in standby
+ data[ADDRESS_INDEX ] = REG_PULSE_CFG;
+ data[DATA_INDEX] = configBits;
+ writeRegs(data, NUM_DATA);
+ data[ADDRESS_INDEX ] = REG_CTRL_REG_1; // put back in active mode
+ data[DATA_INDEX] = 0x01;
+ writeRegs(data, 2); // make active
+}
float MMA8451Q::getAccX() {
return (float(getAccAxis(REG_OUT_X_MSB))/gScaling[gChosen]);
}
--- a/MMA8451Q8.h Wed Jan 28 21:39:04 2015 +0000 +++ b/MMA8451Q8.h Tue Feb 03 17:59:00 2015 +0000 @@ -110,6 +110,8 @@ Allow user to set max g's **/ void setGLimit(int gSelect); + // added in .cpp file for tap configuration + void setPulseConfiguration(uint8_t latch,uint8_t axisSet); void readRegs(int addr, uint8_t * data, int len); void writeRegs(uint8_t * data, int len);
