Appendix b, Programming the status led – Lanner LEC-3012 User Manual

Page 30

Advertising
background image

30

Programming the Status LED

Appendix B

Embedded and Industrial Computing

#include “../include/config.h”
#include “../include/version.h”

/* standard include file */

#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>

#ifdef DJGPP

/* For DOS DJGPP */
#include <dos.h>
#include <inlines/pc.h>

#ifndef DIRECT_IO_ACCESS
#error ***Error: define DIRECT_IO_ACCESS in config.h for

DOS ***
#endif

#else

/* For Linux */
#if defined(LINUX_ENV)
#include <sys/io.h>
#endif

#if defined(FreeBSD_ENV)
#define SET_IOPL() (iofl=open(“/dev/io”,000))
#define RESET_IOPL() close(iofl)
#include <machine/cpufunc.h>
#endif

#include <time.h>
#include <stdint.h>
#include <fcntl.h>
#include <errno.h>
#include <string.h>

#include “../include/sled_ioctl.h”

#define delay(x) usleep(x)

#ifdef DIRECT_IO_ACCESS
#warning ***** Note: You build with DIRECT_IO_ACCESS

defined *****
#warning ***** Note: undefine this to build for driver code

*****
#endif

#endif

/* local include file */
#include “../include/ioaccess.h”

int main( int argc, char** argv )
{
int devfd;
int value, ret;

#if ( defined(DIRECT_IO_ACCESS) && !defined(DJGPP) )
#if (defined(LINUX_ENV))

iopl(3);

#endif
#if (defined(FreeBSD_ENV))

int iofl;

SET_IOPL();

#endif
#endif

fprintf(stdout,

“===

Lanner

platform

miscellaneous utility ===\n”);;

fprintf(stdout, PLATFORM_NAME” Status LED

“CODE_VERSION”\n\n”);;

#ifdef DIRECT_IO_ACCESS
sled_gpio_init();
printf(“Led status 1 for 4 seconds... \n”);
set_led_status_1();

Advertising