test

Library

Import library

Public Member Functions

MMA8452 (PinName sda, PinName scl, int frequency)
Create an accelerometer object connected to the specified I2C pins.
~MMA8452 ()
Destructor.
int activate ()
Puts the MMA8452 in active mode.
int standby ()
Puts the MMA8452 in standby.
int getDeviceID (char *dst)
Read the device ID from the accelerometer (should be 0x2a)
int getStatus (char *dst)
Read the MMA8452 status register.
int readXYZRaw (char *dst)
Read the raw x, y, an z registers of the MMA8452 in one operation.
int readXRaw (char *dst)
Read the raw x register into the provided buffer.
int readYRaw (char *dst)
Read the raw y register into the provided buffer.
int readZRaw (char *dst)
Read the raw z register into the provided buffer.
int readXYZCounts (int *x, int *y, int *z)
Read the x, y, and z signed counts of the MMA8452 axes.
int readXCount (int *x)
Read the x axes signed count.
int readYCount (int *y)
Read the y axes signed count.
int readZCount (int *z)
Read the z axes signed count.
int readXYZGravity (double *x, double *y, double *z)
Read the x, y, and z accelerations measured in G.
int readXGravity (double *x)
Read the x gravity in G into the provided double pointer.
int readYGravity (double *y)
Read the y gravity in G into the provided double pointer.
int readZGravity (double *z)
Read the z gravity in G into the provided double pointer.
int isXYZReady ()
Returns 1 if data has been internally sampled (is available) for all axes since last read, 0 otherwise.
int isXReady ()
Returns 1 if data has been internally sampled (is available) for the x-axis since last read, 0 otherwise.
int isYReady ()
Returns 1 if data has been internally sampled (is available) for the y-axis since last read, 0 otherwise.
int isZReady ()
Returns 1 if data has been internally sampled (is available) for the z-axis since last read, 0 otherwise.
int readRegister (char addr, char *dst)
Reads a single byte from the specified MMA8452 register.
int readRegister (char addr, char *dst, int nbytes)
Reads n bytes from the specified MMA8452 register.
int writeRegister (char addr, char data)
Write to the specified MMA8452 register.
int writeRegister (char addr, char *data, int nbytes)
Write a data buffer to the specified MMA8452 register.


Please log in to post comments.