Appendix C
Application Notes
© National Instruments Corporation
C-3
AT-DIO-32F User Manual
/* set up AT-DIO-32F to communicate with printer */
Setup_DIO(); /* setup the AT-DIO-32F */
/* get the chars to print and send out */
printf("\nEnter the name of the file to print: \n");
scanf("%s",filename);
/* gets(filename);*/
fp = fopen(filename,"r");
if ( Valid_file()) /* test if a valid file opened */
Read_n_Write(); /* read the file and send to printer */
fclose(fp);
} /* main */
/***************** functions *************************************/
/* read file and print */
Read_n_Write()
{
char ch;
while ((ch=fgetc(fp)) != EOF) /* print chars until EOF is reached */
{
Print_char(ch);
}
Print_char(0x0D); /* send linefeed to complete printing */
}
/* check whether given filename is valid */
Valid_file()
{
if (fp == NULL)
{
printf("\nCan't open the file %s.",filename);
return(0);
/* no file access */
}
else
return(1);
/* file exists, go ahead */
}
/* setup the AT-DIO-32F board */
Setup_DIO()
{
outpw(cfg1, 0x0000);
/* initialize the board */
outpw(cfg2, 0x0000);
outpw(cfg3, 0x0000);
outpw(cfg4, 0x0001);
outpw(cfg2, 0x001);
/* OUT2 = *INIT high */
outpw(cfg1, 0x2B44);
/* reset porta handshaking */
outpw(cfg1, 0x2A44); /* porta level, invert ACK1 and REQ1, delay=500ns */
outpw(cfg3, 0x0400);
/* porta write */
}
/* check printer is ready */
Printer_Rdy()
{
int err = 0;
Содержание 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: ......