home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
The C Users' Group Library 1994 August
/
wc-cdrom-cusersgrouplibrary-1994-08.iso
/
vol_300
/
342_01
/
diodesc.txt
< prev
next >
Wrap
Text File
|
1991-02-25
|
7KB
|
190 lines
* ----------------------------------------------------------------------
* File : DIODESC.TXT
* Creator : Blake Miller
* Version : 01.01.00 February 1991
* Purpose : Describe functions in DIOLIB?.LIB
* Revision : February 28, 1991
* -----------------------------------------------------------------------
Collection of routines for digital I/O using a
Computer Boards Inc. CIOAD-16 or a Metrabyte PIO12 compatible
digital I/O board containing at least 1 Intel 8255 Programmable
Peripheral Interface integrated circuit.
The functions can assume a small, medium, or large memory model.
Link your program with the correct DIOLIB?.LIB library memory model:
DIOLIBL.LIB -> Large Memory Model
DIOLIBM.LIB -> Medium Memory Model
DIOLIBS.LIB -> Small Memory Model
Note that some of the functions use inline assembly language as is
compatible with Microsoft Quick C Version 2.0 and later. This inline
assembly is also compatible with Microsoft C Version 6.0, or so I have
been told. The INPort and OUTPort type instructions will have to be
modified or changed to a different function call for use with the
Borland Turbo C C compiler or probably with any other type of compiler.
I would like to make an aesthetic comment.
These routines were written for C programmers. Therefore, all offset
for bits, array elements, data array elements, etc. assume a ZERO (0)
offset! Many of the commercial libraries available use a base of 1.
That seems fine for appeasing Pascal and BASIC programmers, but when I
was modifying my libraries I noticed a lot of code compensating for an
offset of 1. I was adding one to the port or subtracting 1 here and
there. It soon seemed rather pointless. Therefore, I screamed
"NO MORE!" and decided to use offsets of zero!
Look at the source code for each function for an exact description of
what each one does. I wrote the program DIOTST01.C to demonstrate the
use of the functions. Last tiem I chekced, it worked great on a
Metrabyte PIO-12 Digital I/O Board. The functions also correctly
controlled the 8255 digital I/O port on a Computer Boards, Inc. CIO-AD16
data acquisition board.
FUNCTION SYSNOPSES:
-------------------
/*- DIO : Initialize Data Space --------------** DIOFNC01.C
* Initialize the data to safe values.
* DOES NOT do any hardware data modification. That is,
* no input or output to the boards occurs.
* Passed:
* pointer : DIODAT
* short : base address
* Returns:
* nothing
*/
void dio_init (DIODAT *data, short address)
/*- DIO : Configure --------------------------** DIOFNC02.C
* Configure the 8255 for all ports in Mode 0.
* Pass an integer representing the IN or OUT state for each port.
* TRUE (!0) will mean input, and FALSE (0) will mean output.
* Passed:
* pointer : DIODAT
* short : direction Port A
* short : direction Port B
* integer : direction Port C Low
* integer : direction Port C High
* Returns:
* nothing
*/
void dio_config (DIODAT *data, int pa_dir, int pb_dir,
int cl_dir, int ch_dir)
/*- DIO : Bit Put ----------------------------** DIOFNC03.C
* Set/Clear one of the bits in the 8255.
* A state of 1 sets the bit and a state of 0 clears the bit.
* The bit number should be from 0 - 23 as follows:
* 0 = Port A Bit 0; 7 = Port A Bit 7
* 8 = Port B Bit 0; 15 = Port B Bit 7
* 16 = Port C Bit 0; 23 = Port C Bit 7
* Passed:
* pointer : DIODAT
* integer : bit number
* integer : state : TRUE (!0) = SET, FALSE (0) = CLEAR
* Returns:
* nothing
* Loads stat with appropriate error code
*/
void dio_bitput (DIODAT *data, int bit, int state)
/*- DIO : Bit Get ----------------------------** DIOFNC04.C
* Read one of the bits in the 8255.
* A state of 1 indicates a set bit and a state of 0
* indicates a clear bit.
* The bit number should be from 0 - 23 as follows:
* 0 = Port A Bit 0; 7 = Port A Bit 7
* 8 = Port B Bit 0; 15 = Port B Bit 7
* 16 = Port C Bit 0; 23 = Port C Bit 7
* Passed:
* pointer : DIODAT
* integer : bit number
* pointer : integer : state : 1 = SET, 0 = CLEAR
* Returns:
* nothing
* Loads stat with approrpiate error code.
* Loads state with 0 or 1.
*/
void dio_bitget (DIODAT *data, int bit, int *state)
/*- DIO : Byte Put ---------------------------** DIOFNC05.C
* Write one of the bytes in the 8255.
* The port number should be 0 - 2 as follows:
* Use the defines (DIOLIB.H):
* DIO_PORTA = 0 = Port A
* DIO_PORTB = 1 = Port B
* DIO_PORTC = 2 = Port C
* Passed:
* pointer : DIODAT
* integer : port number
* unsigned char : port data
* Returns:
* nothing
* Loads stat with any error ID.
*/
void dio_put_byte (DIODAT *data, int p_num, unsigned char p_dat)
/*- DIO : Byte Get ---------------------------** DIOFNC06.C
* Read one of the bytes in the 8255.
* The port number should be 0 - 2 as follows:
* Use the defines (DIOLIB.H):
* DIO_PORTA = 0 = Port A
* DIO_PORTB = 1 = Port B
* DIO_PORTC = 2 = Port C
* Reads the 8255 and returns data in variable as well as
* loading port data area.
* Passed:
* pointer : DIODAT
* integer : port number
* pointer : unsigned char : returned port data
* Returns:
* nothing
* Loads stat with appropriate error code.
* Loads p_dat with returned data.
*/
void dio_get_byte (DIODAT *data, int p_num, unsigned char *p_dat)
/*- DIO : Dump Bytes -------------------------** DIOFNC07.C
* Write all of the bytes from the data area to the 8255.
* Passed:
* pointer : DIODAT
* Returns:
* nothing
*/
void dio_dump_bytes (DIODAT *data)
/*- DIO : Load Bytes -------------------------** DIOFNC08.C
* Read all of the bytes of the 8255 into the data area.
* Passed:
* pointer : DIODAT
* Returns:
* nothing
*/
void dio_load_bytes (DIODAT *data)
/*- DIO : Byte Put ---------------------------** DIOFNC09.C
* Write a byte to one of the 80X86 ports.
* Duplicates the library function outp()
*/
void dio_bput (int d_port, unsigned char d_byte)
/*- DIO : Byte Get ---------------------------** DIOFNC10.C
* Read a byte from one of the 80X86 ports.
* Duplicates the library function inp()
*/
void dio_bget (int d_port, unsigned char *d_byte)
* ----------------------------------------------------------------------
* END DIODESC.TXT Text Description File
* ----------------------------------------------------------------------