Freescale Semiconductor FRDM-FXS-MULTI 데이터 시트

다운로드
페이지 100
FXOS8700CQ
Sensors
Freescale Semiconductor, Inc.
33
if (s_i2c_write_regs(aFP, FXOS8700CQ_SLAVE_ADDR, FXOS8700CQ_M_CTRL_REG2, 
&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 range with 0.488mg/LSB
databyte = 0x01;
if (s_i2c_write_regs(aFP, FXOS8700CQ_SLAVE_ADDR, FXOS8700CQ_XYZ_DATA_CFG, 
&databyte, (uint8_t) 1) != 1)
{
return (I2C_ERROR);
}
// write 0000 1101 = 0x0D to accelerometer control register 1
// [7-6]: aslp_rate=00
// [5-3]: dr=001 for 200Hz data rate (when in hybrid mode)
// [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 = 0x0D; 
if (s_i2c_write_regs(aFP, FXOS8700CQ_SLAVE_ADDR, FXOS8700CQ_CTRL_REG1, &databyte, 
(uint8_t) 1) != 1)
{
return (I2C_ERROR);
}
// normal return
return (I2C_OK);
}
9.5
 Data Read function
This function performs a block read of the status, accelerometer and magnetometer measurement registers and places the bytes 
read into the structures of type SRAWDATA as signed short integers.
Note that this function assumes that the hyb_autoinc_mode bit has been set to 
enable the reading of all accelerometer and 
magnetometer data in a single burst read operat
ion. 
Example 6. 
// read status and the three channels of accelerometer and magnetometer data from 
// FXOS8700CQ (13 bytes)
int16_t ReadAccelMagnData(SRAWDATA *pAccelData, SRAWDATA *pMagnData)
{
MQX_FILE_PTR fp;
// I2C file pointer
uint8_t Buffer[FXOS8700CQ_READ_LEN];
// read buffer
// read FXOS8700CQ_READ_LEN=13 bytes (status byte and the six channels of data)
if (s_i2c_read_regs(fp, _SLAVE_ADDR, FXOS8700CQ_STATUS, Buffer, 
FXOS8700CQ_READ_LEN) == FXOS8700CQ_READ_LEN)