Dan Bryant / firstRig

Dependencies:   BLE_API PinDetect mbed-src-bmd-200

Embed: (wiki syntax)

« Back to documentation index

MMA845x Class Reference

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, MMA8652 = 0x4a }
 

Device ID's that this class is compatible with.

More...
enum  MMA845x_REGISTER
 

The device register map.

More...

Public Member Functions

 MMA845x (I2C &i2c, PinName p_int1, PinName p_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
void setIntMode (int)
 Set display mode of interrupt.

Detailed Description

API abstraction for the MMA845x 3-axis accelerometer IC.

Definition at line 105 of file MMA845x.h.


Member Enumeration Documentation

The device register map.

Definition at line 135 of file MMA845x.h.

Possible terminations for the ADDR pin.

Enumerator:
SA0_VSS 

SA0 connected to VSS

SA0_VDD 

SA0 connected to VDD

Definition at line 113 of file MMA845x.h.

Device ID's that this class is compatible with.

Enumerator:
MMA8451 

MMA8451 WHO_AM_I register content

MMA8452 

MMA8452 WHO_AM_I register content

MMA8453 

MMA8453 WHO_AM_I register content

MMA8652 

MMA8652 WHO_AM_I register content

Definition at line 123 of file MMA845x.h.


Constructor & Destructor Documentation

MMA845x ( I2C &  i2c,
PinName  p_int1,
PinName  p_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 160 of file MMA845x.h.


Member Function Documentation

void disable ( void   )

Put the MMA845x in the lowest possible power mode and suspend operation.

Definition at line 29 of file MMA845x.cpp.

uint16_t getX ( void   ) const

Get the X data.

Returns:
The last valid reading from the accelerometer

Definition at line 297 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 312 of file MMA845x.cpp.

uint16_t getY ( void   ) const

Get the Y data.

Returns:
The last valid reading from the accelerometer

Definition at line 302 of file MMA845x.cpp.

uint16_t getZ ( void   ) const

Get the Z data.

Returns:
The last valid reading from the accelerometer

Definition at line 307 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 338 of file MMA845x.cpp.

void registerDump ( void   ) const

print the register map and values to the console

Definition at line 366 of file MMA845x.cpp.

void setIntMode ( int  intMode )

Set display mode of interrupt.

Returns:
The last valid reading from the accelerometer

Definition at line 42 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 317 of file MMA845x.cpp.