110425
OPERATIONS MANUAL PCM-UIO48B
7
WS16C48 Programming Reference
Introduction
This section provides basic documentation for the included I/O routines. It is intended
that the accompanying source code equip the programmer with a basic library of I/O
functions for the WS16C48 or can serve as the basis from which application specific code
can be derived.
Function Definitions
This section describes each of the functions contained in the driver. Where necessary,
short examples will be provided to illustrate usage. Any application making use of any of
the driver functions should include the header file UIS48.H, which includes the function
prototypes and the needed constant definitions.
Note that all of the functions utilize the concept of bit_number. The bit_number is a value
from 1 to 48 (1 to 24 for interrupt related functions) that correlates to a specific I/O pin.
Bit_number 1 is port 0 bit 0 and continues through to bit_number 48 at port 5 bit 7.
INIT_IO
– Initializes I/O, set all ports to input
Syntax
void init_io(unsigned io_address);
Description
This function takes a single argument:
io_address – The I/O address of the WS16C48 chip.
There is no return value. This function initializes all I/O
pins for input (sets them high), disables all interrupt
settings, and sets the image values.
READ_BIT
– Reads an I/O port Pin
Syntax
int read_bit(int bit_number);
Description
This function takes a single argument:
bit_number – a value from 1 to 48 specifying the I/O
pin to read from.
This function returns the state of the I/O pin. A
1
is
returned if the I/O pin is low and a
0
is returned if the
pin is high.