From 317651316221a3ddc2e3564f9ff1b775b86f77b5 Mon Sep 17 00:00:00 2001 From: troth Date: Tue, 11 Feb 2003 23:50:31 +0000 Subject: [PATCH] * linux_ppdev.h: New file. * ppi.c: Include system dependant parallel port interface file. (ppi_open): Add call to ppi_claim(). (ppi_close): Add call to ppi_release(). * ppi.h: Define ppi_claim() and ppi_release() as NOPs if not previously defined. * stk500.c: Include inttypes header to quell compiler warning. git-svn-id: svn://svn.savannah.nongnu.org/avrdude/trunk/avrdude@184 81a1dc3b-b13d-400b-aceb-764788c761c2 --- linux_ppdev.h | 37 +++++++++++++++++++++++++++++++++++++ ppi.c | 9 +++++++++ ppi.h | 6 ++++++ stk500.c | 1 + 4 files changed, 53 insertions(+) create mode 100644 linux_ppdev.h diff --git a/linux_ppdev.h b/linux_ppdev.h new file mode 100644 index 00000000..afa3982b --- /dev/null +++ b/linux_ppdev.h @@ -0,0 +1,37 @@ +#ifndef __linux_ppdev_h__ +#define __linux_ppdev_h__ + +#define OBSOLETE__IOW _IOW + +#include +#include +#include + +#include + +#define PPISDATA PPWDATA +#define PPIGDATA PPRDATA + +#define PPISCTRL PPWCONTROL +#define PPIGCTRL PPRCONTROL + +#define PPISSTATUS PPWSTATUS +#define PPIGSTATUS PPRSTATUS + +#define ppi_claim(pgm) \ + if (ioctl(pgm->fd, PPCLAIM)) { \ + fprintf(stderr, "%s: can't claim device \"%s\": %s\n\n", \ + progname, port, strerror(errno)); \ + close(pgm->fd); \ + exit(1); \ + } + +#define ppi_release(pgm) \ + if (ioctl(pgm->fd, PPRELEASE)) { \ + fprintf(stderr, "%s: can't release device: %s\n\n", \ + progname, strerror(errno)); \ + exit(1); \ + } + + +#endif /* __linux_ppdev_h__ */ diff --git a/ppi.c b/ppi.c index fb9d1a6b..ddc327f8 100644 --- a/ppi.c +++ b/ppi.c @@ -25,7 +25,12 @@ #include #include #include + +#if defined(__FreeBSD__) #include +#elif defined(__linux__) +#include "linux_ppdev.h" +#endif #include "avr.h" #include "pindefs.h" @@ -760,11 +765,15 @@ void ppi_open(PROGRAMMER * pgm, char * port) progname, port, strerror(errno)); exit(1); } + + ppi_claim(pgm); } void ppi_close(PROGRAMMER * pgm) { + ppi_release(pgm); + close(pgm->fd); pgm->fd = -1; } diff --git a/ppi.h b/ppi.h index 7b0571c0..bf319462 100644 --- a/ppi.h +++ b/ppi.h @@ -29,7 +29,13 @@ void ppi_initpgm (PROGRAMMER * pgm); int ppi_getpinmask(int pin); +#if !defined(ppi_claim) +# define ppi_claim(pgm) +#endif +#if !defined(ppi_release) +# define ppi_release(pgm) +#endif #endif diff --git a/stk500.c b/stk500.c index 240fb9f5..c68f847d 100644 --- a/stk500.c +++ b/stk500.c @@ -36,6 +36,7 @@ #include #include #include +#include #include "avr.h" #include "pgm.h"