C language drivers, 4programming – Sensoray 417 User Manual
Page 12

11
Sensoray Model 417
Chapter
4
Programming
C Language Drivers
//======================================================
// Write a command byte to the 417 command register.
//======================================================
void adSendByte ( short base_port, short cmd_byte )
{
while ( ( inp( base_port + 1 ) & 128 ) == 0 ) ;
// wait for CRMT
outp ( base_port, cmd_byte ) ;
// send the byte
}
//======================================================
// Read a data byte from the 417 data register
//======================================================
short adReadByte ( short base_port )
{
while ( ( inp ( base_port + 1 ) & 64 ) == 0 ) ;
// wait for DAV
return ( inp ( base_port ) ) ;
// read the byte
}
//======================================================
// Write 16-bit value to the 417
//======================================================
void adSendByte ( short base_port, short cmd_word )
{
adSendByte ( base_port, cmd_word >> 8 ) ;
// send high byte
adSendByte ( base_port, cmd_word ) ;
// send low byte
}
//======================================================
// Read 16-bit value from the 417
//======================================================
short adReadWord ( short base_port )
{
short hiByte = adReadByte ( base_port ) << 8 ;
// read hi byte
return ( hiByte | adReadByte ( base_port ) ) ;
// rd/concat lo byte
}