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 FXOS8700Q by
Revision 2:ab84f99086e5, committed 2014-04-14
- Comitter:
- JimCarver
- Date:
- Mon Apr 14 17:13:15 2014 +0000
- Parent:
- 1:8b53edef272f
- Commit message:
- Minor feature change
Changed in this revision
| FXOS8700Q.cpp | Show annotated file Show diff for this revision Revisions of this file |
| FXOS8700Q.h | Show annotated file Show diff for this revision Revisions of this file |
--- a/FXOS8700Q.cpp Sun Apr 13 21:22:58 2014 +0000
+++ b/FXOS8700Q.cpp Mon Apr 14 17:13:15 2014 +0000
@@ -3,8 +3,16 @@
FXOS8700Q::FXOS8700Q(PinName sda, PinName scl, int addr) : m_i2c(sda, scl), m_addr(addr) {
+
+}
+
+
+FXOS8700Q::~FXOS8700Q() { }
+
+void FXOS8700Q::enable(void) {
// activate the peripheral
uint8_t data[2] = {FXOS8700Q_CTRL_REG1, 0x00};
+ m_i2c.frequency(400000);
writeRegs(data, 2);
data[0] = FXOS8700Q_M_CTRL_REG1;
data[1] = 0x1F;
@@ -18,11 +26,8 @@
data[0] = FXOS8700Q_CTRL_REG1;
data[1] = 0x19;//0x1D;
writeRegs(data, 2);
-}
-
-
-FXOS8700Q::~FXOS8700Q() { }
-
+ }
+
uint8_t FXOS8700Q::getWhoAmI() {
uint8_t who_am_i = 0;
readRegs(FXOS8700Q_WHOAMI, &who_am_i, 1);
@@ -30,15 +35,15 @@
}
float FXOS8700Q::getAccX() {
- return (float(getAccAxis(FXOS8700Q_OUT_X_MSB))/4096.0);
+ return (float(getAccAxis(FXOS8700Q_OUT_X_MSB))/4096.0f);
}
float FXOS8700Q::getAccY() {
- return (float(getAccAxis(FXOS8700Q_OUT_Y_MSB))/4096.0);
+ return (float(getAccAxis(FXOS8700Q_OUT_Y_MSB))/4096.0f);
}
float FXOS8700Q::getAccZ() {
- return (float(getAccAxis(FXOS8700Q_OUT_Z_MSB))/4096.0);
+ return (float(getAccAxis(FXOS8700Q_OUT_Z_MSB))/4096.0f);
}
@@ -96,7 +101,7 @@
}
void FXOS8700Q::writeRegs(uint8_t * data, int len) {
- m_i2c.write(m_addr, (char *)data, len);
+ if(m_i2c.write(m_addr, (char *)data, len)) printf("WRite Error\r\n");
}
\ No newline at end of file
--- a/FXOS8700Q.h Sun Apr 13 21:22:58 2014 +0000
+++ b/FXOS8700Q.h Mon Apr 14 17:13:15 2014 +0000
@@ -73,6 +73,7 @@
*
* @param res array where acceleration data will be stored
*/
+ void enable(void);
void getAccAllAxis(float * res);
void AccXYZraw(int16_t * d);
void MagXYZraw(int16_t * d);
