/******************************************************************************* * PRIVATE FUNCTION: test_uart2 * * PARAMETERS: * ~ void * * RETURN: * ~ void * * DESCRIPTIONS: * Test the UART2. * *******************************************************************************/ void test_uart2(void) { unsigned char i = 0; while (SW1==1) // Loop until SW2 is press { lcd_clear(); lcd_putstr("SW1 test UART2\nConnect UC00A"); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } lcd_clear(); lcd_putstr("TX Selector=TX2\nRX Selector=RX2"); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } lcd_clear(); lcd_putstr(arr_hyperterminal); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } }//while (SW1 == 1) while(SW1==0); //wait for SW1 to be release uart2_initialize(); // initialize UART2 lcd_clear(); lcd_putstr(arr_enter); // Sending message to the PC through UART2 uart2_transmit(0x0C); //clear HyperTerminal uart2_putstr(arr_thanks); uart2_putstr("\r\n\nDemo UART2 on SKds40A...\r\n"); uart2_putstr(arr_keyboard); uart2_putstr(arr_echo); uart2_putstr(arr_enter_keyboard); do { c_received_data = uc_uart2_receive(); //echo back what is received LED2 = ~LED2; //toggle LED 2 uart2_transmit(c_received_data); } while (c_received_data != '\r' && c_received_data != '\n'); //check for "ENTER" from HyperTerminal // Sending message to the PC. uart2_putstr("\r\n\nUART2 Demo Completed.\r\n"); LED2 = 0; beep(2); lcd_clear(); lcd_putstr("UART2 Pass!"); delay_ms(500); }
/******************************************************************************* * PRIVATE FUNCTION: test_uart2 * * PARAMETERS: * ~ void * * RETURN: * ~ void * * DESCRIPTIONS: * Test the UART2. * *******************************************************************************/ void test_uart2(void) { unsigned char i = 0; while (SW1==1) // Loop until SW2 is press { lcd_clear(); lcd_putstr("SW1 test UART2\nConnect UC00A"); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } lcd_clear(); lcd_putstr("TX Selector=TX2\nRX Selector=RX2"); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } lcd_clear(); lcd_putstr("HyperTerminal\n9600, 8, N, 1"); for (i = 0; i < 50; i++) { if(SW1 == 0) break; delay_ms(30); } }//while (SW1 == 1) while(SW1==0); //wait for SW1 to be release uart2_initialize(); // initialize UART2 lcd_clear(); lcd_putstr("Press enter on\nkeyboard to exit"); // Sending message to the PC through UART2 uart2_transmit(0x0C); //clear HyperTerminal uart2_putstr("\r\n\nThanks for using Cytron Technologies product\r\n"); uart2_putstr("\r\n\nDemo UART2 on SKds40A...\r\n"); uart2_putstr("Press any key on keyboard to demo.\r\n"); uart2_putstr("It will be echo back to HyperTerminal.\r\n"); uart2_putstr("Press enter to exit.\r\n\n"); do { c_received_data = uc_uart2_receive(); //echo back what is received LED2 = ~LED2; //toggle LED 2 uart2_transmit(c_received_data); } while (c_received_data != '\r' && c_received_data != '\n'); //check for "ENTER" from HyperTerminal // Sending message to the PC. uart2_putstr("\r\n\nUART2 Demo Completed.\r\n"); LED2 = 0; beep(2); lcd_clear(); lcd_putstr("UART2 Pass!"); delay_ms(500); }
void ucom_initializePort(uint8_t port){ switch(port){ case UART0: uart0_initialize(); break; case UART2: uart2_initialize(); break; default: //error occured break; } }