ADXL345的数据处理,可以参考下面的方式。
ADXL345 Data Processing
unsigned char buf[6];
signed short int AccX, AccY, AccZ;
xl345Read(6, XL345_DATAX0, buf);
//Read DATAX/Y/Z registers
AccX = (buf[1] << 8) | buf[0];
AccY = (buf[3] << 8) | buf[2];
AccZ = (buf[5] << 8) | buf[4];
UploadToHAL(XL345, AccX, AccY, AccZ);
The data processing can be optimized as below
signed short int AccBuffer[3];
xl345Read(6, XL345_DATAX0, AccBuffer);
UploadToHAL(XL345, AccBuffer[0], AccBuffer[1], AccBuffer[2]);
如果数据处理正确,依然看到这么大offset偏置的话,说明器件已坏。
ADXL345的数据处理,可以参考下面的方式。
ADXL345 Data Processing
unsigned char buf[6];
signed short int AccX, AccY, AccZ;
xl345Read(6, XL345_DATAX0, buf);
//Read DATAX/Y/Z registers
AccX = (buf[1] << 8) | buf[0];
AccY = (buf[3] << 8) | buf[2];
AccZ = (buf[5] << 8) | buf[4];
UploadToHAL(XL345, AccX, AccY, AccZ);
The data processing can be optimized as below
signed short int AccBuffer[3];
xl345Read(6, XL345_DATAX0, AccBuffer);
UploadToHAL(XL345, AccBuffer[0], AccBuffer[1], AccBuffer[2]);
如果数据处理正确,依然看到这么大offset偏置的话,说明器件已坏。
举报