User`s manual
TC-6110 Linux User's Manual Programming Guide
5-8
#define DATA_RATE_REG 0x2C
#define POWER_CTL 0x2D
#define DATA_FORMAT_REG 0x31
#define MEASURE_BIT 0x08
#define DATA_RATE 0x0a
#define DATA_FORMAT 0x0b
int main(void)
{
GSENSOR_DATA axis;
int ret;
mx_accelerometer_set_state(I2C_GSENSOR1_ADDR, POWER_CTL, MEASURE_BIT);
mx_accelerometer_set_state(I2C_GSENSOR2_ADDR, POWER_CTL, MEASURE_BIT);
mx_accelerometer_set_state(I2C_GSENSOR1_ADDR, DATA_RATE_REG, DATA_RATE);
mx_accelerometer_set_state(I2C_GSENSOR2_ADDR, DATA_RATE_REG, DATA_RATE);
//full resolution
mx_accelerometer_set_state(I2C_GSENSOR1_ADDR, DATA_FORMAT_REG,
DATA_FORMAT);
mx_accelerometer_set_state(I2C_GSENSOR2_ADDR, DATA_FORMAT_REG,
DATA_FORMAT);
mx_accelerometer_calibrate(I2C_GSENSOR1_ADDR);
sleep (1);
mx_accelerometer_calibrate(I2C_GSENSOR2_ADDR);
if (mx_accelerometer_read(&axis, I2C_GSENSOR1_ADDR) == 0) {
printf("Disk1: x %f y %f z %f\n", axis.x_axis, axis.y_axis, axis.z_axis);
}
if (mx_accelerometer_read(&axis, I2C_GSENSOR2_ADDR) == 0) {
printf("Disk2: x %f y %f z %f\n", axis.x_axis, axis.y_axis,
axis.z_axis);
}
return 0;
}