Device driver for the Freescale MMA845x family of accelerometers.
Dependents: MMA845x_test KL05_accel-test
MMA845x Class Reference
API abstraction for the MMA845x 3-axis accelerometer IC. More...
#include <MMA845x.h>
Public Types | |
enum | MMA845x_SA0 { SA0_VSS = 0, SA0_VDD } |
Possible terminations for the ADDR pin. More... | |
enum | MMA845x_WHO_AM_I { MMA8451 = 0x1a, MMA8452 = 0x2a, MMA8453 = 0x3a } |
Device ID's that this class is compatible with. More... | |
enum | MMA845x_REGISTER |
The device register map. More... | |
Public Member Functions | |
MMA845x (I2C &i2c, InterruptIn &int1, InterruptIn &int2, MMA845x_SA0 const i2c_addr) | |
Create the MMA845x object. | |
uint16_t | getX (void) const |
Get the X data. | |
uint16_t | getY (void) const |
Get the Y data. | |
uint16_t | getZ (void) const |
Get the Z data. | |
MMA845x_DATA | getXYZ (void) const |
Get the XYZ data structure. | |
void | disable (void) |
Put the MMA845x in the lowest possible power mode and suspend operation. | |
void | writeRegister (uint8_t const reg, uint8_t const data) const |
Write to a register (exposed for debugging reasons) Note: most writes are only valid in stop mode. | |
uint8_t | readRegister (uint8_t const reg) const |
Read from a register (exposed for debugging reasons) | |
void | registerDump (void) const |
print the register map and values to the console |
Detailed Description
API abstraction for the MMA845x 3-axis accelerometer IC.
Definition at line 105 of file MMA845x.h.
Member Enumeration Documentation
enum MMA845x_REGISTER |
enum MMA845x_SA0 |
enum MMA845x_WHO_AM_I |
Constructor & Destructor Documentation
MMA845x | ( | I2C & | i2c, |
InterruptIn & | int1, | ||
InterruptIn & | int2, | ||
MMA845x_SA0 const | i2c_addr | ||
) |
Create the MMA845x object.
- Parameters:
-
i2c - A defined I2C object int1 - A defined InterruptIn object int2 - A defined InterruptIn object i2c_addr - Connection of the address line
Definition at line 27 of file MMA845x.cpp.
Member Function Documentation
void disable | ( | void | ) |
Put the MMA845x in the lowest possible power mode and suspend operation.
uint16_t getX | ( | void | ) | const |
Get the X data.
- Returns:
- The last valid reading from the accelerometer
Definition at line 101 of file MMA845x.cpp.
MMA845x_DATA getXYZ | ( | void | ) | const |
Get the XYZ data structure.
- Returns:
- The last valid reading from the accelerometer
Definition at line 116 of file MMA845x.cpp.
uint16_t getY | ( | void | ) | const |
Get the Y data.
- Returns:
- The last valid reading from the accelerometer
Definition at line 106 of file MMA845x.cpp.
uint16_t getZ | ( | void | ) | const |
Get the Z data.
- Returns:
- The last valid reading from the accelerometer
Definition at line 111 of file MMA845x.cpp.
uint8_t readRegister | ( | uint8_t const | reg ) | const |
Read from a register (exposed for debugging reasons)
- Parameters:
-
reg - The register to read from
- Returns:
- The register contents
Definition at line 138 of file MMA845x.cpp.
void registerDump | ( | void | ) | const |
print the register map and values to the console
Definition at line 162 of file MMA845x.cpp.
void writeRegister | ( | uint8_t const | reg, |
uint8_t const | data | ||
) | const |
Write to a register (exposed for debugging reasons) Note: most writes are only valid in stop mode.
- Parameters:
-
reg - The register to be written data - The data to be written
Definition at line 121 of file MMA845x.cpp.
Generated on Tue Jul 12 2022 13:55:36 by 1.7.2