Appendix C
Application Notes
© National Instruments Corporation
C-9
AT-DIO-32F User Manual
printf("\nAn End-of-File has been received.\n");
fclose(fp);
}/* End get_main */
/*... Get the 16-bit word from the AT-DIO-32F ...*/
in_word()
{
int wd;
while(!data_in_rdy()) ;
/* Wait until data is ready. */
wd = inpw(PORTA);
return wd;
/* Return 16-bit data.
*/
}/* End in_word */
/*... Return non-zero value if data is ready to be read ...*/
data_in_rdy()
{
return(inpw(STAT1) & 0x0100); /* Return value of DRDY1 bit. */
}/* End data_in_rdy */
/********************* Modified Unix Commands *********************/
/*... getwd() is a modification of the unix.h function getw().
The returned parameter is the only change in the unix
function. getwd() will return an int EOF (0xFFFF) if
either the first or second byte read was an EOF.
The function getwd(), however, returns the following:
0xFFFF
int EOF if the high byte is an EOF char,
0x..FF
a char EOF in the low byte if a valid char
was read in the high byte,
0x....
a valid char in the high and low byte if no
EOF was read in either.
...*/
getwd(who)
FILE *who;
{
register int
chi, clo;
if ((chi = fgetc(who)) == EOF)
/* EOF will be word length. */
return (EOF);
/* Don't read beyond EOF. */
clo = fgetc(who);
/* Read the high byte.
*/
return((chi & 0xFF) << 8 | (clo & 0xFF)); /* Return word.
*/
}/* End getwd */
/*... putwd() is a unix command.
Note that the functions place characters in the file one at a time
and checks for an EOF with every character. This prevents writing
EOF to a file.
...*/
putw(word, who)
int word;
FILE *who;
{
if ((word>>8) & 0xFF == EOF)
return (EOF);
else
Summary of Contents for AT-DIO-32F
Page 19: ......
Page 101: ......
Page 102: ......
Page 123: ......
Page 124: ......
Page 125: ......
Page 126: ......
Page 127: ......
Page 128: ......
Page 129: ......
Page 130: ......
Page 131: ......
Page 132: ......
Page 133: ......
Page 134: ......
Page 135: ......
Page 136: ......
Page 137: ......
Page 138: ......
Page 139: ......
Page 140: ......
Page 141: ......
Page 142: ......
Page 143: ......