例程主函数
int main(void)
{
uint8_t ledState;
uint32_t i;
/* 初始化 */
TFT_Init();
FLASH_Init();
SYSTICK_Config();
USART1_Config(9600);
LED_Config();
while(ADX345_Init())
{
GUI_Show12Char(60, 42, "ADX345 ERROR!", RED, BLACK);
SYSTICK_Delay1ms(100);
}
GUI_DisplayInit();
ADX345_Adjust();
while(1)
{
i++;
if(i > 0x02FFFF)
{
/* 读取 X,Y,Z 的加速度值 */
ADX_GetXYZData(&Xval, &Yval, &Zval);
printf(" x:%d \n", Xval);
printf(" y:%d \n", Yval);
printf(" z:%d \n", Zval);
/* 将读取到的加速度值转换为角度值 */
Xang=ADX_GetAngle(Xval, Yval, Zval,1);
Yang=ADX_GetAngle(Xval, Yval, Zval,2);
Zang=ADX_GetAngle(Xval, Yval, Zval,0);
GUI_DisplayData();
i = 0;
if(ledState == 0xFE)
{
ledState = 0xFF;
}
else
{
ledState = 0xFE;
}
LED_SetState(ledState);
}
}
} |