|
我用stm32fs103cb芯片编了段,要与主机串口通信getkey,进行判断后进行处理数据。但在buf区始终无法得到我要的键值。请大虾帮忙!!具体代码如下:
int main (void) {
int uart3_ok = 0;
int j3;
int i,j;
stm32_Init (); // STM32 setup
buffer_Init();
// init RX / TX buffers
for(i=0; i<4000; i++)
for(j=0; j<5000; j++){}
uart_sel = 2;
for(i=0; i<4; i++){
SendChar(mycode);
}
while (1){
// Uart1 Receive.
uart1_buf_length = SIO_RBUFLEN;
if(uart1_buf_length > 0)
{
uart_sel = 1;
if(uart1_condition4==0)
{
uart1_temp = GetKey();
if(uart1_temp == 0x55)
{
uart1_condition1 = 1;
}
}
if(uart1_condition1==1 && uart1_condition2==0)
{
uart1_temp = GetKey(); //获得第一个key值后无法获得此处的key值
if(uart1_temp== 0xaa)
{
uart1_condition2 = 1;
}
}
if(uart1_condition1 ==1 && uart1_condition2==1)
{
test_i=1;
uart1_temp=GetKey(); //此处也同样无法获得key值
test_i=22;
switch(uart1_temp)
{
case 0x54:
uart1_condition3=1;
break; //TTS start
case 0x43:
uart1_condition3=2;
break; //TTS stop
case 0x52:
uart1_condition3=3;
break; //Screen query
default:
uart1_condition1 = 0;
break;
}
}
}
|
|