AD2817C Operation Manual
{ send_port( PORT,0xaa );
for( n = 100;n;n-- )
{
delay( 2 ); /* wait about 2ms */
if( kbhit() && ( getch() == 27 ) ) /* if escape key keypress */
{ printf( "\nE20:Serial Port Write Canceled!" );
exit(1);
}
if( check_stat(PORT) & 256 )
{ c = read_port( PORT );
break;
}
}
if( n ) break;/*AD2817C/C not ready for receive*/
}
if( c != 0xcc )/*check receive*/
{ printf( "\nE10:Serial Port HandShake Failure!" );
exit(1);
}
/*handshake success,begin send string */
for( ;*ps; )
{
send_port( PORT,*ps++ );
delay(2);
}
send_port( PORT,'\n' );
delay(2);
}
/* read string from serial port */
void string_rd( char *ps )
{
unsigned char c,i;
for( i = 0;i < 255;i++ )
{
while( ! (check_stat(PORT) & 256) ) /* wait serial recieve ready */
if( kbhit() && (getch() == 27) ) /* if escape key keypress */
{ printf( "\nE21:Serial Port Read Canceled!" );
exit(1);
}
c = read_port( PORT );
if( c == 0xcc ) continue;/*skip the more handshake characters*/
/* max read 256 characters */
45