/* ****************************************************************************** C Language Sample #2 : SAMPLE2.C This program will display the status of each bit in the status register and displays the temperature inside your computer. Last Modified On: 2/11/98 ****************************************************************************** */ #include #include unsigned int BASE; unsigned char CurBit; float Tmp; unsigned AskForBaseAddress(unsigned int OldOne) { char msg[7]; int NewOne = 0, Success = 0, Dummy; int AddrInputPosX, AddrInputPosY; puts("\nPlease enter the Base Address for your card (in hex)"); printf("or press ENTER for %X.\n>", OldOne); AddrInputPosX = wherex(); AddrInputPosY = wherey(); do { gotoxy(AddrInputPosX, AddrInputPosY); clreol(); msg[0] = 5; msg[1] = 0; cgets(msg); sscanf(msg + 2, "%x", &NewOne); Success = 1; Dummy = NewOne; if (msg[1] == 0) { gotoxy(AddrInputPosX, AddrInputPosY); printf("%X", OldOne); Success = 1; Dummy = OldOne; } } while(!Success); return (Dummy); } /* end of AskForBaseAddress */ void main(void) { clrscr(); BASE = AskForBaseAddress(0x350); clrscr(); puts("C Sample #2: Reading Control Register and Temperature"); puts("This program demonstrates how to read the Control Register and"); puts("Temperature at BASE+4 and BASE+5, respectively."); puts("Please note that some feature require that options be installed."); puts("A keystroke will stop the program."); puts(""); puts("Press any key to start."); getch(); /* Grab keystroke */ clrscr(); puts(" Status Control Register Values "); puts(" "); puts(" Bit Number Value Description "); puts(" 0 1 When 0, CTR1 has timed out "); puts(" 1 1 When 0, temperature is too high OPTION 2"); puts(" 2 1 Isolated digital input #0 OPTION 4"); puts(" 3 1 Isolated digital input #1 OPTION 4"); puts(" 4 0 When 0, Speed of fan is correct OPTION 4"); puts(" 5 1 When 0, the Voltage is too high OPTION 1"); puts(" 6 1 When 0, the Voltage is too low OPTION 1"); puts(" 7 1 When 0, an INT has occured "); puts(""); puts(" Temperature inside computer is 000.0øC. OPTION 3 (=194.0 if not installed.)"); puts(" Press any key to exit this program..."); do { for (CurBit = 0; CurBit <= 7; CurBit++) { gotoxy(19, 4 + CurBit); /* Go to correct line */ printf("%hu", (unsigned char)((inp(BASE+4) & (1 << CurBit)) == (1 << CurBit))); /* check bit */ } gotoxy(34, 13); Tmp = (inp(BASE+5) * (11.0 / 15.0)) + 7; printf("%5.1f", Tmp); /* Temperature is simply ((BASE+5) * 11/15) + 7*/ } while (!kbhit()); puts(""); }