Mail Archives: djgpp/2000/03/01/13:30:56
From: | David Hallberg <david DOT hallberg AT data DOT ing DOT hb DOT se>
|
Newsgroups: | comp.os.msdos.djgpp
|
Subject: | Interrupts on EPP-port
|
Date: | Wed, 01 Mar 2000 11:28:57 +0100
|
Organization: | University of Boras, Sweden
|
Lines: | 96
|
Message-ID: | <38BCF0E9.4C63FC36@data.ing.hb.se>
|
NNTP-Posting-Host: | ing187.ing.hb.se
|
Mime-Version: | 1.0
|
X-Trace: | nyheter.chalmers.se 951906537 27861 193.10.172.187 (1 Mar 2000 10:28:57 GMT)
|
X-Complaints-To: | abuse AT chalmers DOT se
|
NNTP-Posting-Date: | 1 Mar 2000 10:28:57 GMT
|
X-Mailer: | Mozilla 4.5 [en] (WinNT; I)
|
X-Accept-Language: | en
|
To: | djgpp AT delorie DOT com
|
DJ-Gateway: | from newsgroup comp.os.msdos.djgpp
|
Reply-To: | djgpp AT delorie DOT com
|
I'm having problem with getting my program to trigger on interrupts
from the parallel port (EPP-mode)
it works just fine when triggering from the timer, keyboard, and even
the networkcard (I have tried to switch IRQ between the networkcard and
the parallel port, but it still only trigger in the network card and not
the parallel port)
I have read the discussion from 1998 initialized by "Michel Gallant"
<mgallant AT NOSPAM DOT grassroots DOT ns DOT ca>
about this, but could not find any final, working example.
Code:
#include <dpmi.h>
#include <stdio.h>
#include <unistd.h>
#include <pc.h>
#include <termios.h>
//#define VECTOR 8 // Timer
#define VECTOR 9 // keyboard
//#define VECTOR 13 // LPT2 IRQ 5
//#define VECTOR 15 // LPT1 IRQ 7
#define SET_BIT(x, b) ((x) |= (1 << (b)))
#define CLEAR_BIT(x, b) ((x) &= ~(1 << (b)))
#define EPPADRESS 0x278
volatile int tics = 0;
unsigned int i, ii, inter = 0;
unsigned char regbyte, adr21;
unsigned long time1, time2;
tic_handler() // Interrupthandler
{
tics++;
}
int main()
{
_go32_dpmi_seginfo old_handler, new_handler; // Structs for
handler
new_handler.pm_offset = (int)tic_handler; // give the
struct the new handler
new_handler.pm_selector = _go32_my_cs(); // and a pointer
to this code
printf("\nGrabbing interrupts");
// Reading old
handler
_go32_dpmi_get_protected_mode_interrupt_vector(VECTOR,
&old_handler);
_go32_dpmi_allocate_iret_wrapper(&new_handler); // makes the
overhead for interrupthandeler
// Struct is the
new handler
_go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,
&new_handler);
//_go32_dpmi_chain_protected_mode_interrupt_vector(VECTOR,
&new_handler);
printf("\nStatusreg %#x", inportb(EPPADRESS + 1));
printf("\nControlreg %#x", inportb(EPPADRESS + 2));
regbyte = inportb(EPPADRESS + 2); //
reading printerports old controll reg
SET_BIT(regbyte , 4); // enable intr. from port
outportb(EPPADRESS + 2 , regbyte); // writing the modified
reg.
printf("\nStatusreg %#x", inportb(EPPADRESS + 1));
printf("\nControlreg %#x", inportb(EPPADRESS + 2));
inter = enable(); // enabeling interrupts
time1 = rawclock(); // get the current time
tics = 0;
while( tics < 1){} // wating for one
interrupt
time2 = rawclock();
printf("\nNumber of Interrupts during the execution: %d ", tics);
printf("\nTime1: %D",time1);
printf("\nTime2: %D",time2);
printf("\nDIFF : %D",time2 - time1);
// puting back the old
handeler
_go32_dpmi_set_protected_mode_interrupt_vector(VECTOR,
&old_handler);
_go32_dpmi_free_iret_wrapper(&new_handler);
getkey();
return 0;
}
- Raw text -