Forum Discussion
Altera_Forum
Honored Contributor
17 years agoTry this:
int uart_read(int base, char *ptr, int len, int flags){
int block;
unsigned int status;
block = 1;//!(flags & O_NONBLOCK);
do{
status = IORD_ALTERA_AVALON_UART_STATUS(base);
/* clear any error flags */
IOWR_ALTERA_AVALON_UART_STATUS(base, 0);
if (status & ALTERA_AVALON_UART_CONTROL_RRDY_MSK){
ptr = IORD_ALTERA_AVALON_UART_RXDATA(base);
if (!(status & (ALTERA_AVALON_UART_STATUS_PE_MSK |
ALTERA_AVALON_UART_STATUS_FE_MSK))){
return 1;
}
}
}while (block);
return 0;
}
It's not a completed function but I believe it illustrates what you're missing.