English
Language : 

FXLS8471Q Datasheet, PDF (10/75 Pages) Freescale Semiconductor, Inc – Linear Accelerometer
3.4 FXLS8471Q Configuration function
This function configures the FXLS8471Q for a 200-Hz ODR. The code is self-explanatory and can be easily customized for
different settings.
Example 5.
// function configures FXLS8471Q accelerometer sensor
static _mqx_int s_FXLS8471Q_start(MQX_FILE_PTR aFP)
{
uint8_t databyte;
// read and check the FXLS8471Q WHOAMI register
if (s_i2c_read_regs(aFP, FXLS8471Q_SLAVE_ADDR, FXLS8471Q_WHOAMI, &databyte,
(uint8_t) 1) != 1)
{
return (I2C_ERROR);
}
if (databyte != FXLS8471Q_WHOAMI_VAL)
{
return (I2C_ERROR);
}
// write 0000 0000 = 0x00 to accelerometer control register 1 to place FXLS8471Q into
// standby
// [7-1] = 0000 000
// [0]: active=0
databyte = 0x00;
if (s_i2c_write_regs(aFP, FXLS8471Q_SLAVE_ADDR, FXLS8471Q_CTRL_REG1, &databyte,
(uint8_t) 1) != 1)
{
return (I2C_ERROR);
}
// write 0000 0001= 0x01 to XYZ_DATA_CFG register
// [7]: reserved
// [6]: reserved
// [5]: reserved
// [4]: hpf_out=0
// [3]: reserved
// [2]: reserved
// [1-0]: fs=01 for accelerometer range of +/-4g with 0.488mg/LSB
databyte = 0x01;
if (s_i2c_write_regs(aFP, FXLS8471Q_SLAVE_ADDR, FXLS8471Q_XYZ_DATA_CFG,
&databyte, (uint8_t) 1) != 1)
{
return (I2C_ERROR);
}
// write 0001 0101b = 0x15 to accelerometer control register 1
// [7-6]: aslp_rate=00
// [5-3]: dr=010 for 200Hz data rate
// [2]: lnoise=1 for low noise mode
// [1]: f_read=0 for normal 16 bit reads
// [0]: active=1 to take the part out of standby and enable sampling
databyte = 0x15;
if (s_i2c_write_regs(aFP, FXLS8471Q_SLAVE_ADDR, FXLS8471Q_CTRL_REG1, &databyte,
(uint8_t) 1) != 1)
FXLS8471Q
10
Sensors
Freescale Semiconductor, Inc.