陀螺仪 ADXRS453
最近公司购买了几个ADXRS453陀螺仪,就认真看了一下数据手册和参考的代码,对代码中的一个函数及调用不是很理解。该函数位于ADXRS453.c文件中,函数为int ADXRS453SensorData(void)。该函数的在ADXRS453test.c的main函数中连续多次调用,想提问一下,该函数作用为什么?代码如下:
/*******************************************************************
@brief int ADXRS453SensorData(void)
SPI sensor data command
@param
none
@return
unsigned int ReceiveValue: sensor data
*******************************************************************/
int ADXRS453SensorData(void)
{
unsigned char SendTemp[4];
unsigned char ReceiveTemp[4];
unsigned int ReceiveValue;
SendTemp[0] = 0x20;
SendTemp[1] = 0x00;
SendTemp[2] = 0x00;
SendTemp[3] = 0x00;
SpiFunction(SendTemp, ReceiveTemp, 4);
ReceiveValue = ReceiveTemp[0];
ReceiveValue = (ReceiveValue<<8 )+ ReceiveTemp[1];
ReceiveValue = (ReceiveValue<<8 )+ ReceiveTemp[2];
ReceiveValue = (ReceiveValue<<8 )+ ReceiveTemp[3];
ReceiveValue = (ReceiveValue>>10)&0x0000FFFF;
return(ReceiveValue);
}
期待您的解答,谢谢
回帖(1)
2018-9-7 10:45:56
该函数是读取陀螺的输出数据
该函数是读取陀螺的输出数据
举报
更多回帖