Forum Discussion
Altera_Forum
Honored Contributor
21 years ago --- Quote Start --- originally posted by rugbybloke@Oct 19 2004, 10:29 AM kira,
i think you're missing something here. a uart device driver is provided so that if you wish to send or receive characters over the uart you just use the standard c library calls putc, printf or any of those functions, for receiving you can use getc, scanf etc. see http://sources.redhat.com/newlib/libc.html (http://sources.redhat.com/newlib/libc.html) for the documentation.
you should not really be using the functions in the uart driver directly, unless you wish to re-write the driver, if so why? --- Quote End --- The supplied uart driver does not have all the functions we need, so that's why we've had to tackle it. 1/ Enable ioctl in small driver with ALTERA_AVALON_UART_USE_IOCTL compile flag. 2/ ioctl termios flags for expanding newlines to cr-lf and echoing input characters. 3/ Flush output buffer 4/ XON-XOFF 5/ Check for received character without reading it. 6/ Get a hook to drop RTS after the buffer transmit empties (half-duplex turnaround) scanf requires the full 70k newlib. It would be nice to have finer control over the library build so functions like this can be selectively brought in. scanf and all the above are needed to port the console interface from 8- and 16-bit embedded applications that used very little memory. I notice that the uart driver code will not work if called with a read or write length of 0 because do..while is used. Possibly 'it can't happen'? There's also a hole in (all?) the device initialisation routines, eg alt_flash_open_dev returns dev ('open' successful) during initialisation even if dev->open is null. But this Nios stuff is wonderfully useful for new products, thank you to the Altera team.