int main(void)
{
DDRD = 0b11111010; // PORTD input/output.
DDRC = 0xFF;
uart_init( UART_BAUD_SELECT(UART_BAUD_RATE,F_CPU) );
sei();
unsigned int rec_char;
char buffer[7];
while(1)
{
rec_char=uart_getc();
switch(state)
{
case SYN_s:
{
if ((unsigned char) rec_char == 0x16) // SYN
{
state=DLE_1_s;
}
else
{
state=SYN_s;
}
}
break;
case DLE_1_s:
{
if ((unsigned char) rec_char == 0x10) // DLE
{
state=STX_s;
}
else if ((unsigned char) rec_char == 0x16) // SYN
{
state=DLE_1_s;
}
else
{
state=SYN_s;
}
}
break;
case STX_s:
{
if ((unsigned char) rec_char == 0x02) // STX
{
state=TARGET_NO_1_s;
}
else if ((unsigned char) rec_char == 0x16) // SYN
{
state=DLE_1_s;
}
else
{
state=SYN_s;
}
}
break;