Interface definition for the MMA7660 accelerometer driver. More...

Detailed Description

Interface definition for the MMA7660 accelerometer driver.

Author
Michael Andersen m.and.nosp@m.erse.nosp@m.n@cs..nosp@m.berk.nosp@m.eley..nosp@m.edu

Definition in file mma7660.h.

#include <stdint.h>
#include <stdbool.h>
#include "periph/i2c.h"
+ Include dependency graph for mma7660.h:
+ This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  mma7660_params_t
 Parameters for an MMA7660 device. More...
 
struct  mma7660_t
 Device descriptor for an MMA7660 device. More...
 
struct  mma7660_data_t
 Data type for the result data. More...
 

Enumerations

enum  {
  MMA7660_OK, MMA7660_I2C_ERR, MMA7660_I2C_READ_ERR, MMA7660_I2C_WRITE_ERR,
  MMA7660_READ_ERR
}
 Return codes. More...
 

Functions

int mma7660_init (mma7660_t *dev, const mma7660_params_t *params)
 Initialize an MMA7660 device. More...
 
int mma7660_set_mode (const mma7660_t *dev, uint8_t active, uint8_t autowake, uint8_t autosleep, uint8_t prescale)
 Set the mode register. More...
 
int mma7660_read_tilt (const mma7660_t *dev, uint8_t *res)
 Read the tilt register. More...
 
int mma7660_write_sleep_count (const mma7660_t *dev, uint8_t sleep)
 Write the sleep count register. More...
 
int mma7660_config_interrupts (const mma7660_t *dev, uint8_t isource_flags)
 Configure the interrupt sources. More...
 
int mma7660_config_samplerate (const mma7660_t *dev, uint8_t amsr, uint8_t awsr, uint8_t filt)
 Configure the sample rate. More...
 
int mma7660_config_pdet (const mma7660_t *dev, uint8_t pdth, uint8_t enabled_axes)
 Configure the tap detection. More...
 
int mma7660_config_pd (const mma7660_t *dev, uint8_t pd)
 Configure the tap detection debounce count. More...
 
int mma7660_read (const mma7660_t *dev, mma7660_data_t *data)
 Read the acceleration counts converted to mG. More...
 
int mma7660_read_counts (const mma7660_t *dev, int8_t *x, int8_t *y, int8_t *z)
 Read the acceleration counts (unconverted) More...
 

MMA7660 constants

#define MODE_ACTIVE_SHIFT   (0U)
 
#define MODE_AUTOWAKE_SHIFT   (3U)
 
#define MODE_AUTOSLEEP_SHIFT   (4U)
 
#define MODE_PRESCALE_SHIFT   (5U)
 
#define MODE_INTERRUPT_DEFAULT   (0x40) /* Active low, push-pull */
 
#define MMA7660_INTSOURCE_NONE   (0x00)
 
#define MMA7660_INTSOURCE_FB   (0x01)
 
#define MMA7660_INTSOURCE_UDLR   (0x02)
 
#define MMA7660_INTSOURCE_TAP   (0x04)
 
#define MMA7660_INTSOURCE_AUTOSLEEP   (0x08)
 
#define MMA7660_INTSOURCE_MEASURE   (0x10)
 
#define MMA7660_INTSOURCE_SHX   (0x20)
 
#define MMA7660_INTSOURCE_SHY   (0x40)
 
#define MMA7660_INTSOURCE_SHZ   (0x80)
 
#define MMA7660_SR_AMPD   (0x00)
 
#define MMA7660_SR_AM64   (0x01)
 
#define MMA7660_SR_AM32   (0x02)
 
#define MMA7660_SR_AM16   (0x03)
 
#define MMA7660_SR_AM8   (0x04)
 
#define MMA7660_SR_AM4   (0x05)
 
#define MMA7660_SR_AM2   (0x06)
 
#define MMA7660_SR_AM1   (0x07)
 
#define MMA7660_SR_AW32   (0x00)
 
#define MMA7660_SR_AW16   (0x08)
 
#define MMA7660_SR_AW8   (0x10)
 
#define MMA7660_SR_AW1   (0x18)
 
#define MMA7660_PDET_X   (0x20)
 
#define MMA7660_PDET_Y   (0x40)
 
#define MMA7660_PDET_Z   (0x80)
 
#define MMA7660_ADDR   (0x4C)
 
#define MMA7660_MG_PER_COUNT   (47U)