Driver for the Freescale MMA8x5x 3-Axis accelerometer. More...
Driver for the Freescale MMA8x5x 3-Axis accelerometer.
The driver will initialize the accelerometer for best resolution. After the initialization the accelerometer will make measurements at periodic times. The measurements period and scale range can be determined by accelerometer initialization. This driver only implements basic functionality (i.e. no support for external interrupt pins).
This driver provides [S]ensor [A]ctuator [U]ber [L]ayer capabilities.
Modules | |
MMA8x5x Accelerometer driver compile configuration | |
Files | |
file | mma8x5x.h |
Interface definition for the MMA8x5x accelerometer driver. | |
file | mma8x5x_params.h |
Default configuration for MMA8x5x devices. | |
file | mma8x5x_regs.h |
Register definition for the MMA8x5x accelerometer driver. | |
Data Structures | |
struct | mma8x5x_params_t |
Configuration parameters. More... | |
struct | mma8x5x_t |
Device descriptor for MMA8x5x accelerometers. More... | |
struct | mma8x5x_data_t |
Data type for the result data. More... | |
Enumerations | |
enum | { MMA8X5X_TYPE_MMA8652 = 0x4a, MMA8X5X_TYPE_MMA8653 = 0x5a, MMA8X5X_TYPE_MMA8451 = 0x1a, MMA8X5X_TYPE_MMA8452 = 0x2a, MMA8X5X_TYPE_MMA8453 = 0x3a } |
Devices supported by this driver. More... | |
enum | { MMA8X5X_RATE_800HZ = (0 << 3), MMA8X5X_RATE_400HZ = (1 << 3), MMA8X5X_RATE_200HZ = (2 << 3), MMA8X5X_RATE_100HZ = (3 << 3), MMA8X5X_RATE_50HZ = (4 << 3), MMA8X5X_RATE_1HZ25 = (5 << 3), MMA8X5X_RATE_6HZ25 = (6 << 3), MMA8X5X_RATE_1HZ56 = (7 << 3) } |
Available sampling rates. More... | |
enum | { MMA8X5X_RANGE_2G = 0, MMA8X5X_RANGE_4G = 1, MMA8X5X_RANGE_8G = 2 } |
Available range options. More... | |
enum | { MMA8X5X_OK = 0, MMA8X5X_DATA_READY = 1, MMA8X5X_NOI2C = -1, MMA8X5X_NODEV = -2, MMA8X5X_NODATA = -3 } |
Named return values. More... | |
Functions | |
int | mma8x5x_init (mma8x5x_t *dev, const mma8x5x_params_t *params) |
Initialize the MMA8x5x accelerometer driver. More... | |
void | mma8x5x_set_user_offset (const mma8x5x_t *dev, int8_t x, int8_t y, int8_t z) |
Set user offset correction. More... | |
void | mma8x5x_set_active (const mma8x5x_t *dev) |
Set active mode, this enables periodic measurements. More... | |
void | mma8x5x_set_standby (const mma8x5x_t *dev) |
Set standby mode. More... | |
int | mma8x5x_is_ready (const mma8x5x_t *dev) |
Check for new set of measurement data. More... | |
void | mma8x5x_read (const mma8x5x_t *dev, mma8x5x_data_t *data) |
Read accelerometer's data. More... | |
void | mma8x5x_set_motiondetect (const mma8x5x_t *dev, uint8_t int_pin, uint8_t threshold) |
Configure motion detection interrupt. More... | |
void | mma8x5x_ack_int (const mma8x5x_t *dev) |
Acknowledge motion detection interrupt. More... | |
anonymous enum |
anonymous enum |
Available sampling rates.
anonymous enum |
anonymous enum |
void mma8x5x_ack_int | ( | const mma8x5x_t * | dev | ) |
Acknowledge motion detection interrupt.
Acknowledges (clears) a motion detection interrupt. See mma8x5x_set_motiondetect().
[in] | dev | device descriptor of accelerometer |
int mma8x5x_init | ( | mma8x5x_t * | dev, |
const mma8x5x_params_t * | params | ||
) |
Initialize the MMA8x5x accelerometer driver.
[out] | dev | device descriptor of accelerometer to initialize |
[in] | params | configuration parameters |
int mma8x5x_is_ready | ( | const mma8x5x_t * | dev | ) |
Check for new set of measurement data.
[in] | dev | device descriptor of accelerometer |
void mma8x5x_read | ( | const mma8x5x_t * | dev, |
mma8x5x_data_t * | data | ||
) |
Read accelerometer's data.
Acceleration will be calculated as:
if full scale is set to 2g
if full scale is set to 4g
if full scale is set to 8g
[in] | dev | device descriptor of accelerometer |
[out] | data | the current acceleration data [in mg] |
void mma8x5x_set_active | ( | const mma8x5x_t * | dev | ) |
Set active mode, this enables periodic measurements.
[out] | dev | device descriptor of accelerometer to reset |
void mma8x5x_set_motiondetect | ( | const mma8x5x_t * | dev, |
uint8_t | int_pin, | ||
uint8_t | threshold | ||
) |
Configure motion detection interrupt.
User needs to configure MCU side of the selected int pin. mma8x5x will set the pin to low on interrupt. Before another interrupt can occur, the current interrupt must be acknowledged using mma8x5x_ack_int()
.
[in] | dev | device descriptor of accelerometer |
[in] | int_pin | select mma8x5x int pin (1 or 2) |
[in] | threshold | motion detection threshold (see datasheet) |
void mma8x5x_set_standby | ( | const mma8x5x_t * | dev | ) |
Set standby mode.
[in] | dev | device descriptor of accelerometer |
void mma8x5x_set_user_offset | ( | const mma8x5x_t * | dev, |
int8_t | x, | ||
int8_t | y, | ||
int8_t | z | ||
) |
Set user offset correction.
Offset correction registers will be erased after accelerometer reset.
[out] | dev | device descriptor of accelerometer to initialize |
[in] | x | offset correction value for x-axis |
[in] | y | offset correction value for y-axis |
[in] | z | offset correction value for z-axis |