codepad
[
create a new paste
]
login
|
about
Language:
C
C++
D
Haskell
Lua
OCaml
PHP
Perl
Plain Text
Python
Ruby
Scheme
Tcl
#define DeviceID '1' void main(void) { SYSTEM_Initialize(); INTERRUPT_GlobalInterruptEnable(); INTERRUPT_PeripheralInterruptEnable(); uint8_t InputCount = 0; bool DeviceSelectFlag = 0; while (1) { if (EUSART_is_rx_ready()) { uint8_t ReceiveValue = EUSART_Read(); EUSART_Write(ReceiveValue); InputCount++; if (ReceiveValue == '\n') { InputCount = 0; DeviceSelectFlag = 1; } else { if (InputCount == 1) { if (ReceiveValue != DeviceID) { DeviceSelectFlag = 0; } } if (InputCount == 2) { if (ReceiveValue != ',') { DeviceSelectFlag = 0; } } if (InputCount == 3 && DeviceSelectFlag == 1) { printf("deviceID 1 data1 Recive\n"); } if (InputCount == 4 && DeviceSelectFlag == 1) { printf("deviceID 1 data2 Recive\n"); } if (InputCount == 5 && DeviceSelectFlag == 1) { printf("deviceID 1 data3 Recive\n"); } } } } }
Private
[
?
]
Run code
Submit