Esempio n. 1
0
/**
 * _read and _write for LM4F
 *
 * _read and _write are used by newlib's I/O routines (think printf, etc.)
 * If you want to use this code in your binary, you will have to initialise
 * the UART in your board's setup code and define STD_CON to your UART's
 * name in your board's Makefile
 */
int _read(int fd, void *buf, size_t count)
{
    int rcvd;
    char *ptr;

    if(fd <= 2){
        ptr = (char *) buf;
        rcvd = 0;

        while(count > 0){
            *ptr = uart_recv_blocking(STD_CON);
            if(*ptr == '\r'){
                *ptr = '\n';
            }

            ++rcvd;
            --count;
        }
    }else{
        rcvd = -1;
        errno = EIO;
    }

    return rcvd;
}
int main(void)
{
	u8 rx;
	
	uart_setup();

	/*
	 * Yes, it's that simple !
	 */
	while(1) {
		rx = uart_recv_blocking(UART0);
		uart_send_blocking(UART0, rx);
	}

	return 0;
}
int main(void)
{
	uint8_t rx;

	gpio_enable_ahb_aperture();
	uart_setup();

	/*
	 * Yes, it's that simple !
	 */
	while(1) {
		rx = uart_recv_blocking(UART0);
		uart_send_blocking(UART0, rx);
	}

	return 0;
}