Forum Discussion

Altera_Forum's avatar
Altera_Forum
Icon for Honored Contributor rankHonored Contributor
20 years ago

uart LF LF/CR conversion

How can I enable LF to LF/CR conversion for the UART used as stdio ?

4 Replies

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    I simply replace \n with \r\n in the printf's. Its not elegant but it works.

  • Altera_Forum's avatar
    Altera_Forum
    Icon for Honored Contributor rankHonored Contributor

    only baudrate is suupported by ioctrl(),

    you can take the files altera_avalon_uart.c and

    altera_avalon_uart.h from the components directory and copy it to

    your systemlibrary directory or change them in place.

    there are different functions for the small driver.

    in function "alt_avalon_uart_write"

    ...

    ...

    /* Add the next character to the transmit buffer */

    dev->tx_buf[dev->tx_end] = *ptr++;

    dev->tx_end = next;

    change to (not tested !!!, maybe wrong):

    ...

    ...

    dev->tx_buf[dev->tx_end] = *ptr;

    dev->tx_end = next;

    if(*ptr=='\n') {

    *ptr='\r; // replace 'n' by '\r', do not increment ptr

    }

    else {

    ptr++;

    }

    dev->tx_end = next;

    ...