static int bma250_read_accel_xyz(struct i2c_client *client, struct bmasensoracc *acc) { int comres; unsigned char data[6]; comres = bma250_smbus_read_byte_block(client, BMA250_ACC_X_LSB__REG, data, 6); acc->x = BMA250_GET_BITSLICE(data[0], BMA250_ACC_X_LSB) |(BMA250_GET_BITSLICE(data[1], BMA250_ACC_X_MSB)<<BMA250_ACC_X_LSB__LEN); acc->x = acc->x << (sizeof(short)*8-(BMA250_ACC_X_LSB__LEN + BMA250_ACC_X_MSB__LEN)); acc->x = acc->x >> (sizeof(short)*8-(BMA250_ACC_X_LSB__LEN + BMA250_ACC_X_MSB__LEN)); acc->y = BMA250_GET_BITSLICE(data[2], BMA250_ACC_Y_LSB) | (BMA250_GET_BITSLICE(data[3], BMA250_ACC_Y_MSB)<<BMA250_ACC_Y_LSB__LEN); acc->y = acc->y << (sizeof(short)*8-(BMA250_ACC_Y_LSB__LEN + BMA250_ACC_Y_MSB__LEN)); acc->y = acc->y >> (sizeof(short)*8-(BMA250_ACC_Y_LSB__LEN + BMA250_ACC_Y_MSB__LEN)); acc->z = BMA250_GET_BITSLICE(data[4], BMA250_ACC_Z_LSB) | (BMA250_GET_BITSLICE(data[5], BMA250_ACC_Z_MSB)<<BMA250_ACC_Z_LSB__LEN); acc->z = acc->z << (sizeof(short)*8-(BMA250_ACC_Z_LSB__LEN+ BMA250_ACC_Z_MSB__LEN)); acc->z = acc->z >> (sizeof(short)*8-(BMA250_ACC_Z_LSB__LEN+ BMA250_ACC_Z_MSB__LEN)); return comres; }
static int bma250_read_accel_z(struct i2c_client *client, short *a_z) { int comres; unsigned char data[2]; comres = bma250_smbus_read_byte_block(client, BMA250_ACC_Z_LSB__REG, data, 2); *a_z = BMA250_GET_BITSLICE(data[0], BMA250_ACC_Z_LSB) | BMA250_GET_BITSLICE(data[1], BMA250_ACC_Z_MSB) <<BMA250_ACC_Z_LSB__LEN; *a_z = *a_z << (sizeof(short)*8 -(BMA250_ACC_Z_LSB__LEN+BMA250_ACC_Z_MSB__LEN)); *a_z = *a_z >> (sizeof(short)*8 -(BMA250_ACC_Z_LSB__LEN+BMA250_ACC_Z_MSB__LEN)); return comres; }