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.
Dependents: TALab2B_Part2_ECE595 TALab3C_i2c_acc Project1 FinalProject ... more
FXOS8700Q Class Reference
FXOS8700Q accelerometer example. More...
#include <FXOS8700Q.h>
Inherits MbedComponent::MotionSensor.
Inherited by FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
Public Member Functions | |
| void | readRegs (uint8_t addr, uint8_t *data, uint32_t len) const |
| Read a device register. | |
| uint8_t | whoAmI (void) const |
| Read the ID from a whoAmI register. | |
| virtual void | enable (void) const |
| Enable the sensor for operation. | |
| virtual void | disable (void) const |
| disable the sensors operation | |
| virtual uint32_t | sampleRate (uint32_t frequency) const |
| Set the sensor sample rate. | |
| virtual uint32_t | dataReady (void) const |
| Tells of new data is ready. | |
| virtual int16_t | getX (int16_t &x) const =0 |
| Get the x data in counts. | |
| virtual float | getX (float &x) const =0 |
| Get the x data in units. | |
| virtual int16_t | getY (int16_t &y) const =0 |
| Get the y data in counts. | |
| virtual float | getY (float &y) const =0 |
| Get the y data in units. | |
| virtual int16_t | getZ (int16_t &z) const =0 |
| Get the z data in counts. | |
| virtual float | getZ (float &z) const =0 |
| Get the z data in units. | |
| virtual void | getAxis (motion_data_counts_t &xyz) const =0 |
| Get the x,y,z data in counts. | |
| virtual void | getAxis (motion_data_units_t &xyz) const =0 |
| Get the x,y,z data in units. | |
Protected Member Functions | |
| FXOS8700Q (I2C &i2c, uint8_t addr) | |
| FXOS8700Q constructor. | |
| ~FXOS8700Q () | |
| FXOS8700Q deconstructor. | |
Detailed Description
FXOS8700Q accelerometer example.
#include "mbed.h" #include "FXOS8700Q.h" I2C i2c(PTE25, PTE24); FXOS8700QAccelerometer acc(i2c, FXOS8700CQ_SLAVE_ADDR1); // Configured for the FRDM-K64F with onboard sensors FXOS8700QMagnetometer mag(i2c, FXOS8700CQ_SLAVE_ADDR1); int main(void) { motion_data_units_t acc_data, mag_data; motion_data_counts_t acc_raw, mag_raw; float faX, faY, faZ, fmX, fmY, fmZ, tmp_float; int16_t raX, raY, raZ, rmX, rmY, rmZ, tmp_int; acc.enable(); mag.enable(); while (true) { // counts based results acc.getAxis(acc_raw); mag.getAxis(mag_raw); acc.getX(raX); acc.getY(raY); acc.getZ(raZ); mag.getX(rmX); mag.getY(rmY); mag.getZ(rmZ); // unit based results acc.getAxis(acc_data); mag.getAxis(mag_data); acc.getX(faX); acc.getY(faY); acc.getZ(faZ); mag.getX(fmX); mag.getY(fmY); mag.getZ(fmZ); wait(0.1f); } }
FXOS8700Q driver class
Definition at line 86 of file FXOS8700Q.h.
Constructor & Destructor Documentation
| FXOS8700Q | ( | I2C & | i2c, |
| uint8_t | addr | ||
| ) | [protected] |
FXOS8700Q constructor.
- Parameters:
-
i2c a configured i2c object addr addr of the I2C peripheral as wired
Definition at line 28 of file FXOS8700Q.cpp.
| ~FXOS8700Q | ( | ) | [protected] |
FXOS8700Q deconstructor.
Definition at line 50 of file FXOS8700Q.cpp.
Member Function Documentation
| uint32_t dataReady | ( | void | ) | const [virtual] |
Tells of new data is ready.
- Returns:
- The amount of data samples ready to be read from a device
Implements MotionSensor.
Definition at line 101 of file FXOS8700Q.cpp.
| void disable | ( | void | ) | const [virtual] |
| void enable | ( | void | ) | const [virtual] |
Enable the sensor for operation.
Implements MotionSensor.
Definition at line 83 of file FXOS8700Q.cpp.
| virtual void getAxis | ( | motion_data_units_t & | xyz ) | const [pure virtual, inherited] |
Get the x,y,z data in units.
- Parameters:
-
xyz A referene to the variable to put the data in, 0 denotes not used
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual void getAxis | ( | motion_data_counts_t & | xyz ) | const [pure virtual, inherited] |
Get the x,y,z data in counts.
- Parameters:
-
xyz A referene to the variable to put the data in, 0 denotes not used
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual int16_t getX | ( | int16_t & | x ) | const [pure virtual, inherited] |
Get the x data in counts.
- Parameters:
-
x A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The x data in counts
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual float getX | ( | float & | x ) | const [pure virtual, inherited] |
Get the x data in units.
- Parameters:
-
x A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The x data in units
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual int16_t getY | ( | int16_t & | y ) | const [pure virtual, inherited] |
Get the y data in counts.
- Parameters:
-
y A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The y data in counts
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual float getY | ( | float & | y ) | const [pure virtual, inherited] |
Get the y data in units.
- Parameters:
-
y A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The y data in units
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual float getZ | ( | float & | z ) | const [pure virtual, inherited] |
Get the z data in units.
- Parameters:
-
z A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The z data in units
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| virtual int16_t getZ | ( | int16_t & | z ) | const [pure virtual, inherited] |
Get the z data in counts.
- Parameters:
-
z A referene to the variable to put the data in, 0 denotes not used
- Returns:
- The z data in counts
Implemented in FXOS8700QAccelerometer, and FXOS8700QMagnetometer.
| void readRegs | ( | uint8_t | addr, |
| uint8_t * | data, | ||
| uint32_t | len | ||
| ) | const |
Read a device register.
- Parameters:
-
addr The address to read from data The data to read from it len The amount of data to read from it
- Returns:
- 0 if successful, negative number otherwise
Definition at line 56 of file FXOS8700Q.cpp.
| uint32_t sampleRate | ( | uint32_t | frequency ) | const [virtual] |
Set the sensor sample rate.
- Parameters:
-
frequency The desires sample frequency
- Returns:
- The amount of error in Hz between desired and actual frequency
Implements MotionSensor.
Definition at line 108 of file FXOS8700Q.cpp.
| uint8_t whoAmI | ( | void | ) | const |
Read the ID from a whoAmI register.
- Returns:
- The device whoAmI register contents
Definition at line 63 of file FXOS8700Q.cpp.
Generated on Mon Jul 18 2022 06:31:11 by
1.7.2