User`s manual

Table Of Contents
UC-7400-CE User’s Manual Programming Examples
5-6
Example #3Digital I/O
The UC-7408-CE computer supports 8 programmable digital input channels and 8 programmable
digital output channels for your applications. These IO channels can be accessed at run-time via
the following APIs.
/* this function initialize a connection to the devices. It must be called before you
call other functions
On success, it returns a handle. Otherwise, it return NULL
*/
HANDLE mxdio_init(void);
/* this function requests the system to detect a low-to-high or high-to-low event on
a specified input port every tick_slot milliseconds. On success, it returns 0.
<hndl> handle created by mxdio_init
<port> port number 0~7
<handler> callback function with prototype (unsigned int, unsigned int, unsigned
int)
<low_high> macro DIN_EVENT_LOW_TO_HIGH or DIN_EVENT_HIGH _TO _LOW
<tick_slot> 10 milliseconds minimal
*/
int mxdio_set_input_event( HANDLE hndl,
unsigned int port,
mxdio_input_cb handler,
unsigned int low_high,
unsigned int tick_slot);
/* this function starts a dispatcher to handle events.
<hndl> handle created by mxdio_init
Return non-zero to abort.
*/
int mxdio_dispatch(HANDLE hndl);
/* this function set a digit level for a specified output port
<hndl> handle created by mxdio_init
<port> port number 0~7
<data> 0 or 1
*/
int mxdio_set_dout(HANDLE hndl, unsigned int port, unsigned int
data);