drivers/mma8x5x: remove use of type param
Driver now accepts all variants of the driver
This commit is contained in:
parent
e0e02c04c8
commit
a63d76b346
@ -95,7 +95,6 @@ enum {
|
||||
typedef struct {
|
||||
i2c_t i2c; /**< I2C bus the device is connected to */
|
||||
uint8_t addr; /**< I2C bus address of the device */
|
||||
uint8_t type; /**< device type */
|
||||
uint8_t rate; /**< sampling rate to use */
|
||||
uint8_t range; /**< scale range to use */
|
||||
uint8_t offset[3]; /**< data offset in X, Y, and Z direction */
|
||||
|
||||
@ -37,9 +37,6 @@ extern "C" {
|
||||
#ifndef MMA8X5X_PARAM_ADDR
|
||||
#define MMA8X5X_PARAM_ADDR (MMA8X5X_I2C_ADDRESS)
|
||||
#endif
|
||||
#ifndef MMA8X5X_PARAM_TYPE
|
||||
#define MMA8X5X_PARAM_TYPE (MMA8X5X_TYPE_MMA8652)
|
||||
#endif
|
||||
#ifndef MMA8X5X_PARAM_RATE
|
||||
#define MMA8X5X_PARAM_RATE (MMA8X5X_RATE_200HZ)
|
||||
#endif
|
||||
@ -53,13 +50,12 @@ extern "C" {
|
||||
#ifndef MMA8X5X_PARAMS
|
||||
#define MMA8X5X_PARAMS { .i2c = MMA8X5X_PARAM_I2C, \
|
||||
.addr = MMA8X5X_PARAM_ADDR, \
|
||||
.type = MMA8X5X_PARAM_TYPE, \
|
||||
.rate = MMA8X5X_PARAM_RATE, \
|
||||
.range = MMA8X5X_PARAM_RANGE, \
|
||||
.offset = MMA8X5X_PARAM_OFFSET }
|
||||
#endif
|
||||
#ifndef MMA8X5X_SAUL_INFO
|
||||
#define MMA8X5X_SAUL_INFO { .name = "mma8652" }
|
||||
#define MMA8X5X_SAUL_INFO { .name = "mma8x5x" }
|
||||
#endif
|
||||
/**@}*/
|
||||
|
||||
|
||||
@ -51,11 +51,18 @@ int mma8x5x_init(mma8x5x_t *dev, const mma8x5x_params_t *params)
|
||||
|
||||
/* test if the target device responds */
|
||||
i2c_read_reg(BUS, ADDR, MMA8X5X_WHO_AM_I, ®, 0);
|
||||
if (reg != dev->params.type) {
|
||||
i2c_release(BUS);
|
||||
DEBUG("[mma8x5x] init - error: invalid WHO_AM_I value [0x%02x]\n",
|
||||
(int)reg);
|
||||
return MMA8X5X_NODEV;
|
||||
switch (reg) {
|
||||
case MMA8X5X_TYPE_MMA8451:
|
||||
case MMA8X5X_TYPE_MMA8452:
|
||||
case MMA8X5X_TYPE_MMA8453:
|
||||
case MMA8X5X_TYPE_MMA8652:
|
||||
case MMA8X5X_TYPE_MMA8653:
|
||||
break;
|
||||
default: /* invalid device type */
|
||||
i2c_release(BUS);
|
||||
DEBUG("[mma8x5x] init - error: invalid WHO_AM_I value [0x%02x]\n",
|
||||
(int)reg);
|
||||
return MMA8X5X_NODEV;
|
||||
}
|
||||
|
||||
/* reset the device */
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user