while (1) {
/* Check if host has connected and opened the VCOM port */
if ((vcom_connected() != 0) && (prompt == 0)) {
vcom_write((unsigned char *)"Presione 1 para encender LED, 2 para apagarlo\r\n", 47);
prompt = 1;
}
/* If VCOM port is opened echo whatever we receive back to host. */
if (prompt) {
rdCnt = vcom_bread(&g_rxBuff[0], 256);
if (rdCnt) {
vcom_write(&g_rxBuff[0], rdCnt);
if(g_rxBuff[0] == '1'){
vcom_write((unsigned char *)" -> Encendiendo LED\r\n", 21);
Board_LED_Set(0, 1);
}else if(g_rxBuff[0] == '2'){
vcom_write((unsigned char *)" -> Apagando LED\r\n", 18);
Board_LED_Set(0, 0);
}else{
vcom_write((unsigned char *)" -> Comando no reconocido\r\n", 27);
}
}
}
/* Sleep until next IRQ happens */
__WFI();
}
}
|