void InitUart();
void InitSPI();
void SendUart(BYTE dat); //send data to PC
BYTE RecvUart(); //receive data from PC
BYTE SPISwap(BYTE dat); //swap SPI data between master and slave
while (1)
{
#ifdef MASTER //for master (receive UART data from PC and send it to slave, in the meantime
// receive SPI data from slave and send it to PC)
SendUart(SPISwap(RecvUart()));
#else //for salve (receive SPI data from master and
ACC = SPISwap(ACC); // send previous SPI data to master)
#endif
}
}