#include "uart.h"
#include "app.c"
char uartGetC(void) {
    char tmp;
    
    // wait for data receiving
    while( eltNb == 0 ){
        BSP_LEDToggle(BSP_LED_2);
//        uartPutC('E');
    }

    // character echo with connected device
    tmp = uartBuffer[indexR];
    uartPutC( tmp );
            
    // circular mode processing
    eltNb--;
    if ( indexR > UART_BUFFER_SIZE)
        indexR = 0;
    else
        indexR++;

    return tmp;
}
void uartPutS(char* stringToSend) {
    int i;

        for (i=0; stringToSend[i] != '\0'; i++)
            uartPutC( stringToSend[i] );
}


void uartGetS(char* rxString) {
    char tmp;
    int i=0;

    // wait for data receiving and check for ENTER key ascii code
    while ( (tmp = uartGetC()) != '\r')
        rxString[i++] = tmp;
        
    // replace ENTER key ascii code
    rxString[i] = '\0';
    uartPutS("\r\n");
}