状态机。
switch(com_serial_receiveStatus)
{
case FINDING_0X55 :
{
uint8_t byte = 0;
uart1_readReceiveBuffer(&byte,1);
、、、、
if(byte == (uint8_t)(0x55))
com_serial_receiveStatus = NEED_0XAA;
}
break;
case NEED_0XAA :
{
。。。。。。。。。。。
if(byte == (uint8_t)(0xAA))
com_serial_receiveStatus = NEED_LENGTH;
else
com_serial_receiveStatus = FINDING_0X55;
}
break;
case NEED_LENGTH :
{
。。。。。。。。。。。
com_serial_receiveLength = length;
com_serial_receiveStatus = GETTING_DATA;
}
break;
case GETTING_DATA :
{
。。。。。。。。。。。。。。。。。
com_serial_receiveStatus = FINDING_0X55;
}
break;
}
|