URL
https://opencores.org/ocsvn/openrisc/openrisc/trunk
Go to most recent revision |
Only display areas with differences |
Details |
Blame |
View Log
Rev 158 |
Rev 816 |
/*
|
/*
|
io.c -- Test the serial I/O.
|
io.c -- Test the serial I/O.
|
*/
|
*/
|
|
|
#define BUFSIZE 80
|
#define BUFSIZE 80
|
#include <stdio.h>
|
#include <stdio.h>
|
|
|
main()
|
main()
|
{
|
{
|
char buf[100];
|
char buf[100];
|
char *tmp;
|
char *tmp;
|
int result;
|
int result;
|
|
|
/* test the lowest level output function */
|
/* test the lowest level output function */
|
result = outbyte ('&');
|
result = outbyte ('&');
|
if (result != 0x0) {
|
if (result != 0x0) {
|
pass ("outbyte");
|
pass ("outbyte");
|
} else {
|
} else {
|
fail ("outbyte");
|
fail ("outbyte");
|
}
|
}
|
|
|
/* try writing a string */
|
/* try writing a string */
|
result = write ("Write Test:\n", 12);
|
result = write ("Write Test:\n", 12);
|
print ("result was ");
|
print ("result was ");
|
putnum (result);
|
putnum (result);
|
outbyte ('\n');
|
outbyte ('\n');
|
if (result == 12) {
|
if (result == 12) {
|
pass ("write");
|
pass ("write");
|
} else {
|
} else {
|
fail ("write");
|
fail ("write");
|
}
|
}
|
|
|
/* try the print() function too */
|
/* try the print() function too */
|
result = print ("Print Test:\n");
|
result = print ("Print Test:\n");
|
print ("result was ");
|
print ("result was ");
|
putnum (result);
|
putnum (result);
|
outbyte ('\n');
|
outbyte ('\n');
|
if (result == 12) {
|
if (result == 12) {
|
pass ("print");
|
pass ("print");
|
} else {
|
} else {
|
fail ("print");
|
fail ("print");
|
}
|
}
|
|
|
/* try the iprintf() function too */
|
/* try the iprintf() function too */
|
result = print ("Iprintf Test:\n");
|
result = print ("Iprintf Test:\n");
|
print ("result was ");
|
print ("result was ");
|
putnum (result);
|
putnum (result);
|
outbyte ('\n');
|
outbyte ('\n');
|
if (result == 14) {
|
if (result == 14) {
|
pass ("iprintf");
|
pass ("iprintf");
|
} else {
|
} else {
|
fail ("iprintf");
|
fail ("iprintf");
|
}
|
}
|
|
|
/* try to read a string */
|
/* try to read a string */
|
print ("Type 5 characters");
|
print ("Type 5 characters");
|
|
|
result = 0;
|
result = 0;
|
result = read (0, buf, 5);
|
result = read (0, buf, 5);
|
print (buf);
|
print (buf);
|
if (result == 5) {
|
if (result == 5) {
|
pass ("read");
|
pass ("read");
|
} else {
|
} else {
|
fail ("read");
|
fail ("read");
|
}
|
}
|
|
|
/* clear everything out */
|
/* clear everything out */
|
fflush (stdout);
|
fflush (stdout);
|
}
|
}
|
|
|
|
|
|
|
© copyright 1999-2024
OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.