MMA7660 Accelerometer¶
Driver for the Freescale MMA7660 3-Axis accelerometer.
This driver only implements basic functionality.
-
MODE_ACTIVE_SHIFT
¶ 1
(0U)
-
MODE_AUTOWAKE_SHIFT
¶ 1
(3U)
-
MODE_AUTOSLEEP_SHIFT
¶ 1
(4U)
-
MODE_PRESCALE_SHIFT
¶ 1
(5U)
-
MODE_INTERRUPT_DEFAULT
¶ 1
(0x40) /* Active low, push-pull */
-
MMA7660_INTSOURCE_NONE
¶ 1
(0x00)
-
MMA7660_INTSOURCE_FB
¶ 1
(0x01)
-
MMA7660_INTSOURCE_UDLR
¶ 1
(0x02)
-
MMA7660_INTSOURCE_TAP
¶ 1
(0x04)
-
MMA7660_INTSOURCE_AUTOSLEEP
¶ 1
(0x08)
-
MMA7660_INTSOURCE_MEASURE
¶ 1
(0x10)
-
MMA7660_INTSOURCE_SHX
¶ 1
(0x20)
-
MMA7660_INTSOURCE_SHY
¶ 1
(0x40)
-
MMA7660_INTSOURCE_SHZ
¶ 1
(0x80)
-
MMA7660_SR_AMPD
¶ 1
(0x00)
-
MMA7660_SR_AM64
¶ 1
(0x01)
-
MMA7660_SR_AM32
¶ 1
(0x02)
-
MMA7660_SR_AM16
¶ 1
(0x03)
-
MMA7660_SR_AM8
¶ 1
(0x04)
-
MMA7660_SR_AM4
¶ 1
(0x05)
-
MMA7660_SR_AM2
¶ 1
(0x06)
-
MMA7660_SR_AM1
¶ 1
(0x07)
-
MMA7660_SR_AW32
¶ 1
(0x00)
-
MMA7660_SR_AW16
¶ 1
(0x08)
-
MMA7660_SR_AW8
¶ 1
(0x10)
-
MMA7660_SR_AW1
¶ 1
(0x18)
-
MMA7660_PDET_X
¶ 1
(0x20)
-
MMA7660_PDET_Y
¶ 1
(0x40)
-
MMA7660_PDET_Z
¶ 1
(0x80)
-
MMA7660_ADDR
¶ 1
(0x4C)
-
MMA7660_MG_PER_COUNT
¶ 1
(47U)
-
enum
@133
¶ - MMA7660_OK
- all ok
- MMA7660_I2C_ERR
- i2c bus initialization error
- MMA7660_I2C_READ_ERR
- i2c bus cannot be read
- MMA7660_I2C_WRITE_ERR
- i2c bus cannot be written
- MMA7660_READ_ERR
- error when reading counts
-
int
mma7660_init
(mma7660_t * dev, const mma7660_params_t * params)¶ Initialize an MMA7660 device.
Parameters
dev: device descriptor params: device configuration parameters Return values
- MMA7660_OK on success
- -MMA7660_I2C_ERR on i2c bus initialization error
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_set_mode
(const mma7660_t * dev, uint8_t active, uint8_t autowake, uint8_t autosleep, uint8_t prescale)¶ Set the mode register.
Parameters
dev: device descriptor active: 0=sleep 1=active autowake: see datasheet autosleep: see datasheet prescale: main clock prescalar Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_read_tilt
(const mma7660_t * dev, uint8_t * res)¶ Read the tilt register.
Parameters
dev: device descriptor res: tilt register contents Return values
- MMA7660_OK on success
- -MMA7660_I2C_READ_ERR on i2c bus read error
-
int
mma7660_write_sleep_count
(const mma7660_t * dev, uint8_t sleep)¶ Write the sleep count register.
Parameters
dev: device descriptor sleep: sleep count Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_config_interrupts
(const mma7660_t * dev, uint8_t isource_flags)¶ Configure the interrupt sources.
Parameters
dev: device descriptor isource_flags: interrupt source flags Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_config_samplerate
(const mma7660_t * dev, uint8_t amsr, uint8_t awsr, uint8_t filt)¶ Configure the sample rate.
Parameters
dev: device descriptor amsr: active mode sample rate (pg 18 of DS) awsr: auto wake sample rate (pg 19 of DS) filt: filter samples (pg 19 of DS) Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_config_pdet
(const mma7660_t * dev, uint8_t pdth, uint8_t enabled_axes)¶ Configure the tap detection.
Parameters
dev: device descriptor pdth: pulse detection enabled_axes: enabled axes Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_config_pd
(const mma7660_t * dev, uint8_t pd)¶ Configure the tap detection debounce count.
Parameters
dev: device descriptor pd: pulse debounce Return values
- MMA7660_OK on success
- -MMA7660_I2C_WRITE_ERR on i2c bus write error
-
int
mma7660_read
(const mma7660_t * dev, mma7660_data_t * data)¶ Read the acceleration counts converted to mG.
Parameters
dev: device descriptor data: the acceleration data Return values
- MMA7660_OK on success
- -MMA7660_I2C_READ_ERR on i2c bus read error
-
int
mma7660_read_counts
(const mma7660_t * dev, int8_t * x, int8_t * y, int8_t * z)¶ Read the acceleration counts (unconverted)
Parameters
dev: device descriptor x: the X axis value y: the Y axis value z: the Z axis value Return values
- MMA7660_OK on success
- -MMA7660_I2C_READ_ERR on i2c bus read error
- -MMA7660_READ_ERR on general read error
-
struct
mma7660_params_t
¶ Parameters for an MMA7660 device.
-
i2c.h::i2c_t
i2c
¶ the I2C handle
-
uint8_t
addr
¶ the device I2C address
-
uint8_t
amsr
¶ active mode sample rate
-
uint8_t
awsr
¶ auto wake sample rate
-
uint8_t
filt
¶ filter samples
-
-
struct
mma7660_t
¶ Device descriptor for an MMA7660 device.
-
mma7660_params_t
params
¶ initialization parameters
-
mma7660_params_t