English
Language : 

FXLS8471Q Datasheet, PDF (11/75 Pages) Freescale Semiconductor, Inc – Linear Accelerometer
{
return (I2C_ERROR);
}
// normal return
return (I2C_OK);
}
3.5 FXLS8471Q Data Read function
This function performs a block read of the status and acceleration data and places the bytes read into the structures of type
SRAWDATA as signed short integers.
Example 6.
// read status and the three channels of accelerometer data from
// FXLS8471Q (7 bytes)
int16_t ReadAccel(SRAWDATA *pAccelData)
{
MQX_FILE_PTR fp;
// I2C file pointer
uint8_t Buffer[FXLS8471Q_READ_LEN];
// read buffer
// read FXLS8471Q_READ_LEN=7 bytes (status byte and the three channels of data)
if (s_i2c_read_regs(fp, FXLS8471Q_SLAVE_ADDR, FXLS8471Q_STATUS, Buffer,
FXLS8471Q_READ_LEN) == FXLS8471Q_READ_LEN)
{
// copy the 14 bit accelerometer byte data into 16 bit words
pAccelData->x = ((Buffer[1] << 8) | Buffer[2])>> 2;
pAccelData->y = ((Buffer[3] << 8) | Buffer[4])>> 2;
pAccelData->z = ((Buffer[5] << 8) | Buffer[6])>> 2;
}
else
{
// return with error
return (I2C_ERROR);
}
// normal return
return (I2C_OK);
}
Sensors
Freescale Semiconductor, Inc.
FXLS8471Q
11