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
Содержание AT-DIO-32F
Страница 19: ......
Страница 101: ......
Страница 102: ......
Страница 123: ......
Страница 124: ......
Страница 125: ......
Страница 126: ......
Страница 127: ......
Страница 128: ......
Страница 129: ......
Страница 130: ......
Страница 131: ......
Страница 132: ......
Страница 133: ......
Страница 134: ......
Страница 135: ......
Страница 136: ......
Страница 137: ......
Страница 138: ......
Страница 139: ......
Страница 140: ......
Страница 141: ......
Страница 142: ......
Страница 143: ......