define BUFFERSIZE  xx 
typedef unsigned char queueinfo;
typedef struct
{
    int x_speed;
    int y_speed;
    int x_speed_old;
    int y_speed_old;
    uint8_t flag;
    queueinfo queuebuffer[BUFFERSIZE + 4];//串口信息队列, 防止发送大量信息导致信息丢失
}SerialPortInfo;
学会定义结构体来保存数据,进而当我们定义多个结构体变量时,便可以同时接收多个uart的信息。
这个函数放到串口中断里:
void Get_Serial_Info(unsigned char data, SerialPortInfo *info)
{
      int i=0;
      //队列向前移动
     for(; i
        info->queuebuffer[i] = info->queuebuffer[i+1];
     }
     //添加信息到队尾
     info->queuebuffer[BUFFERSIZE-1] = data;
     info->flag = 1;    //队列发生更新
}
/*
数据传给处理函数   这个函数放到while里
*/
void ProcessInfo(SerialPortInfo *info)
{  
    if(info->flag == 1)
    {
       填入处理函数,根据上位机发送不同数据来区分执行什么功能
       info->flag = 0;  //去除更新标记
    }
}
