SIGNAL (SIG_USART_RECV) { unsigned char UARTemp; UARTemp=UDR0; UARTTimer = 0x2; if (!(UARTStatu & _BV(HeadIn))) { if (UARTemp!=HeadChar) return; else { UARTStatu |= _BV(HeadIn); return; } } if (!(UARTStatu & _BV(LengtIn))) { DataLong=UARTemp; if (DataLong > MAXLength) { UARTStatu = 0; return; } UARTbuffer[0]=UARTemp; ByteOfRead=0; UARTStatu |= _BV(LengtIn); return; } if (ByteOfRead < DataLong) { UARTbuffer[ByteOfRead+1]=UARTemp; if (ByteOfRead < MAXLength) ByteOfRead++; if (ByteOfRead == DataLong) { if (UARTemp == Crc8fun(UARTbuffer,DataLong)) UARTStatu |= _BV(PackageOk); else UARTStatu=0; } } } |