General purpose digital i/o – Measurement Computing TempBook rev.3.0 User Manual
Page 43

TempBook User’s Manual
Standard API Programming of the TempBook with C 6-11
tbkGetBackStat(&active, &count);
sprintf(tempstr,"Transfer in progress : %2d scans acquired.\r",count);
strcat(response,tempstr);
}
while (active != 0);
sprintf(tempstr,"\r\nAcquisition complete.\r\n\r\n");
strcat(response,tempstr);
/* Print results using a 12 bit data format */
sprintf(tempstr,"Data Acquired:\r\n");
strcat(response,tempstr);
for (scan=0 ; scan<8 ; scan++)
{
sprintf(tempstr,"\r\nScan %d:", scan);
strcat(response,tempstr);
for (chan=0 ; chan <8; chan++) {
sprintf(tempstr," %4d", data[(scan * 8) + chan]>4);
strcat(response,tempstr);
}
}
sprintf(tempstr,"\r\n");
strcat(response,tempstr);
SendDlgItemMessage(myDlg, 101, WM_SETTEXT, 0, (LONG)(LPSTR)response);
EmptyMessageQueue(myDlg);
}
General Purpose Digital I/O
/***********************************************
File: Adcex3.c
Description:This example demonstrates the use of the TempBook/66's general
purpose digital I/O ports.
Functions Used:tbkRdBit(unsigned char bitNum, unsigned char *bitVal)
tbkRdByte(unsigned char *byteVal)
tbkWtBit(unsigned char bitNum, unsigned char bitVal)
tbkWtByte(unsigned char byteVal)
***********************************************/
*/ unsigned char bit, in_bit, out_byte, in_byte;
sprintf(response,"\r\nDigex1.c\r\n\r\n");
/* Read the state of digital input DI3 */
tbkRdBit(3, &in_bit);
if (in_bit) {
sprintf(tempstr,"Digital input #3 is set\r\n\r\n");
strcat(response,tempstr); } else {
sprintf(tempstr,"Digital input #3 is clear\r\n\r\n");
strcat(response,tempstr); }
/* Set digital output DO5 */
tbkWtBit(5, 1);
/* Perform a 'walking bit' test by setting each digital
output in order from DO0 to DO7 */
for (bit=0 ; bit<8 ; bit++)
{
out_byte = 0x01
tbkWtByte(out_byte);
// Write that byte to the digital output port