Nios II Classic Software Developer’s Handbook

ID 683282
Date 5/14/2015
Public
Document Table of Contents

6.7.2. General Access to Character Mode Devices

Accessing a character-mode device other than stdin, stdout, or stderr is as easy as opening and writing to a file.
Example 6–4. Writing Characters to a UART Called uart1
#include <stdio.h>
#include <string.h>
int main (void)
{
char* msg = "hello world";
FILE* fp;
fp = fopen ("/dev/uart1", "w");
if (fp!=NULL)
{
fprintf(fp, "%s",msg);
fclose (fp);
}
return 0;
}