Altera_Forum
Honored Contributor
21 years agowriting to a uart
I've got a uart in my SOPC builder system called uart_0 that I'm trying to write to using the serial example, but slightly modified. However the cyg_io_lookup function does not find this uart. I've no idea where to go from here, can someone give me a clue how to access this uart.
below is the code listing I am using, (simple_prog function only, rest is the same)static void simple_prog(CYG_ADDRESS data)
{
cyg_io_handle_t handle;
Cyg_ErrNo err;
const char test_string = "serial example is working correctly!\n";
cyg_uint32 len = strlen(test_string);
printf("Starting serial example\n");
// err = cyg_io_lookup( "/dev/haldiag", &handle );
err = cyg_io_lookup( "/dev/uart_0", &handle );
printf("error = %d \n",err);
if (ENOERR == err) {
// printf("Found /dev/haldiag. Writing string....\n");
printf("Found /dev/uart_0. Writing string....\n");
err = cyg_io_write( handle, test_string, &len );
}
else {
printf("Device not detected! \n");
}
if (ENOERR == err) {
printf("I think I wrote the string. Did you see it?\n");
}
printf("Serial example finished\n");
}