beautypg.com

Appendix f - c language functions – KEPCO BIT 232F User Manual

Page 65

background image

BIT 232 022800

F-1

APPENDIX F - C LANGUAGE FUNCTIONS

F.1

INTRODUCTION

This appendix contains examples of C language functions which can be used as the building
blocks for unique programs to interface the BIT Card and associated power supply with an IBM-
PC-compatible computer. These functions are used in the sample programs shown in Appendi-
ces D and E.

F.2

OPEN SERIAL PORT USING ROM BIOS ROUTINE

This function opens the serial port selected by n, using the ROM BIOS routine; if the computer is
not IBM-PC-compatible the ROM BIOS routine must be replaced by an equivalent.

/* open serial port using ROM BIOS routine */

void open_port(int n)

{

union REGS regs;

/* AH has the function code */

regs.h.ah = 0x00;

/* AL has the baud rate for 8 bits No parity 1 Stop bit */

regs.h.al = 0xe3;

/* DX has the port number */

if (n == 1)

regs.x.dx = 0;

else

regs.x.dx = 1;

/* call the ROM BIOS routine */

int86(0x14, ®s, ®s);

}

F.3

PUT CHARACTER TO SERIAL PORT

This function sends a character (c) to the serial port specified by (n) using the ROM BIOS rou-
tine; if the computer is not IBM-PC-compatible the ROM BIOS routine must be replaced by an
equivalent.

/* put character to serial port */

void put_serc(int n, int c)

{

union REGS regs;

/* AH has the function code */

regs.h.ah = 0x01;

/* AL has the character */

regs.h.al = c;

/* DX has the port number */

if (n == 1)

regs.x.dx = 0;

else

regs.x.dx = 1;

/* call the ROM BIOS routine */

int86(0x14, ®s, ®s);

}

This manual is related to the following products: