28
Digital Input/Output Control
Appendix B
Embedded and Industrial Computing
A sample DIO program in C:
ioaccess.c: IO access code for Lanner Platfomr Digital IO
program
*********************************************************
**********************/
#include “../include/config.h”
#ifdef DJGPP
/* standard include file */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
/* For DOS DJGPP */
#include <dos.h>
#include <inlines/pc.h>
#else //DJGPP
/* For Linux */
#ifdef DIRECT_IO_ACCESS
/* For Linux direct io access code */
/* standard include file */
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#if defined(LINUX_ENV)
#include <sys/io.h>
#endif
#if defined(FreeBSD_ENV)
#include <machine/cpufunc.h>
#endif
#include <time.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>
#define delay(x) usleep(x)
#endif
#ifdef MODULE
#include <linux/kernel.h>
#include <linux/module.h>
#include <linux/kernel.h>
#include <linux/fs.h>
#include <asm/io.h>
#include <linux/delay.h>
#undef delay
#define delay(x) mdelay(x)
#undef fprintf
#define fprintf(S, A) printk(A)
#endif //MODULE
#ifdef KLD_MODULE
#include <sys/types.h>
#include <sys/param.h>
#include <sys/systm.h>
#include <sys/malloc.h>
#include <sys/kernel.h>
#include <sys/bus.h>
#include <sys/errno.h>