void testMotor(void) { char c; Serialflush(); Serialprint("Motor Test\n"); while(1) { if(uartNewLineFlag == 1) { Serialprint("LF received\n"); c = uartReadBuffer[0]; Serialflush(); switch(c) { case 'a': motorForward(); Serialprint("Motor FW\n"); break; case 'b': motorBackward(); Serialprint("Motor BW\n"); break; case 'c': motorLeft(); Serialprint("Motor Left\n"); break; case 'd': motorRight(); Serialprint("Motor Right\n"); break; case 'e': motorStop(); Serialprint("Motor Stop\n"); break; } } } }
/*** Function : main ** Parameters : None ** Return : int ** Description : It is the entry point of program **/ int main(void) { SetOsc(OSC_FREQ); // Set Oscillator Freq Serialbegin(BAUD_RATE); // Set Baud Rate Serialflush(); // Clear the buffers Serialprint("uart test\n\r"); // Print a string setSerialinterrupt(); // Enable Serial Interrupt while(1) { while(uartNewLineCount<NEW_LINE_THRESHOLD); // Wait until new line count reaches threshold Serialprint(uartReadBuffer); // Print the uart read buffer Serialflush(); // Flush the buffer } }
void uartISRTest(void) { while(1) { if(uartNewLineFlag == 1) { Serialprint((char*)uartReadBuffer); Serialflush(); } } }
/** * Empty the buffer of tx and rx instead waiting for outgoing completed. */ void Serial_::flush(void) { Serialflush(dev); }