Welcome to EDAboard.com

Welcome to our site! EDAboard.com is an international Electronic Discussion Forum focused on EDA software, circuits, schematics, books, theory, papers, asic, pld, 8051, DSP, Network, RF, Analog Design, PCB, Service Manuals... and a whole lot more! To participate you need to register. Registration is free. Click here to register now.

Register Log in

hardware interrupts and parallel in visual c+ or c++ builder

Status
Not open for further replies.

is_razi

Full Member level 3
Joined
Apr 6, 2002
Messages
159
Helped
13
Reputation
26
Reaction score
7
Trophy points
1,298
Location
Tabriz
Activity points
1,156
interrupt builder c++

hi
is there anyone who can introduce me an ebook about hardware interrupts and interfacing in microsoft visualc++ or c++ builder .

thanks very much.
:? :? :?
 

bobcat1

Advanced Member level 4
Joined
Jul 10, 2002
Messages
1,288
Helped
99
Reputation
198
Reaction score
34
Trophy points
1,328
Activity points
8,547
hardware interrupt + c

Hi I have writeen some code for accessing hradware for win 32 platform
e.g. win NT XP & 95 & 98 for BCC builder using a public libeary (dll)

PM me if your intersted



bobi
 

boonreans

Junior Member level 3
Joined
Jun 24, 2001
Messages
28
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,281
Activity points
114
return c++ buider

Hi..

You can use WinDriver from jungo to create parallel interrupt
with c++ builder/MS VC++
 

littleboy-yz

Newbie level 1
Joined
May 20, 2003
Messages
0
Helped
0
Reputation
0
Reaction score
0
Trophy points
1,280
Activity points
18
isa interruppt level affinity vector

Can you Help me ?
Give me some sample code to create parallel interrupt ?
 

tcsa35

Full Member level 3
Joined
Mar 19, 2002
Messages
171
Helped
10
Reputation
20
Reaction score
8
Trophy points
1,298
Activity points
1,507
use rtlinitunicodestring

/******************************************************************/
/* Example NT/2000/XP Interrupt & DPC Driver */
/* Copyright 2001 Craig Peacock, Craig.Peacock@beyondlogic.org */
/* See http://www.beyondlogic.org for a complete description */
/* Last Updated 11th November 2001 */
/******************************************************************/

#include <ntddk.h>

#define PortAddress 0x378
#define CONTROL PortAddress+2
#define outportb(ADDR,BYTE) outp(ADDR,BYTE)
#define inportb(ADDR) inp(ADDR)

typedef struct _LOCAL_DEVICE_INFO {
PKINTERRUPT InterruptObject;
ULONG Level;
ULONG Vector;
KAFFINITY Affinity;
} LOCAL_DEVICE_INFO, *PLOCAL_DEVICE_INFO;

NTSTATUS InterruptCreateDispatch(
IN PDEVICE_OBJECT DeviceObject,
IN PIRP Irp
)
{
Irp->IoStatus.Information = 0;
Irp->IoStatus.Status = STATUS_SUCCESS;
IoCompleteRequest(Irp, IO_NO_INCREMENT);
return STATUS_SUCCESS;
}

BOOLEAN InterruptIsr(IN PKINTERRUPT Interrupt, IN OUT PVOID Context)
{
PDEVICE_OBJECT DeviceObject = Context;

KdPrint( ("Interrupt.sys: Interrupt Service Routine\n") );

/* We should check if the interrupt comes from us and return */

IoRequestDpc(DeviceObject,
DeviceObject->CurrentIrp,
NULL);

return TRUE;
}

VOID InterruptDpcRoutine(IN PKDPC Dpc, PDEVICE_OBJECT DeviceObject, IN PIRP Irp, IN PVOID Context)
{
PLOCAL_DEVICE_INFO DeviceExtension;
PIRP pIrp;

pIrp = DeviceObject->CurrentIrp;
DeviceExtension = DeviceObject->DeviceExtension;

KdPrint( ("Interrupt.sys: DPC Routine - Completing Interrupt Request\n") );

/* Do any processing here */

return;
}

VOID InterruptUnload(IN PDRIVER_OBJECT DriverObject)
{
WCHAR DOSNameBuffer[] = L"\\DosDevices\\Interrupt";
UNICODE_STRING uniDOSString;
PLOCAL_DEVICE_INFO extension = DriverObject->DeviceObject->DeviceExtension;

KdPrint( ("Interrupt.sys: Interrupt.sys is Unloading") );

/* Disable Parallel Port IRQ's */
outportb(CONTROL, inportb(CONTROL) & 0xEF);

/* Disconnect Interrupt */
IoDisconnectInterrupt(extension->InterruptObject);

/* Delete Symbolic Link */
RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);
IoDeleteSymbolicLink (&uniDOSString);

/* Delete Device */
IoDeleteDevice(DriverObject->DeviceObject);
}

NTSTATUS DriverEntry(
IN PDRIVER_OBJECT DriverObject,
IN PUNICODE_STRING RegistryPath
)
{
PDEVICE_OBJECT DeviceObject;
NTSTATUS status;
PLOCAL_DEVICE_INFO DeviceExtension;

ULONG MappedVector;
KIRQL Irql;

WCHAR NameBuffer[] = L"\\Device\\Interrupt";
WCHAR DOSNameBuffer[] = L"\\DosDevices\\Interrupt";
UNICODE_STRING uniNameString, uniDOSString;

KdPrint( ("Interrupt.sys: Interrupt.sys Loading") );

RtlInitUnicodeString(&uniNameString, NameBuffer);
RtlInitUnicodeString(&uniDOSString, DOSNameBuffer);

status = IoCreateDevice(DriverObject, // DriverObject
sizeof(LOCAL_DEVICE_INFO), // DeviceExtensionSize
&uniNameString, // DeviceName
FILE_DEVICE_UNKNOWN, // DeviceType
0, // DeviceCharacteristics
TRUE, // Exclusive
&DeviceObject); // *DeviceObject

if(!NT_SUCCESS(status)) return status;

DeviceExtension = DeviceObject->DeviceExtension;

status = IoCreateSymbolicLink (&uniDOSString, &uniNameString);

if (!NT_SUCCESS(status)) return status;

DeviceExtension->Level = 7;
DeviceExtension->Vector = DeviceExtension->Level;

MappedVector = HalGetInterruptVector(Isa,
0,
DeviceExtension->Level,
DeviceExtension->Vector,
&Irql,
&DeviceExtension->Affinity);

KdPrint( ("Interrupt.sys: MappedVector = 0x%08X\n",MappedVector) );
KdPrint( ("Interrupt.sys: Level = 0x%08X\n",DeviceExtension->Level) );
KdPrint( ("Interrupt.sys: Vector = 0x%08X\n",DeviceExtension->Vector) );
KdPrint( ("Interrupt.sys: Irql = 0x%08X\n",Irql) );
KdPrint( ("Interrupt.sys: Affinity = 0x%08X\n",DeviceExtension->Affinity) );

if (MappedVector == 0) DbgPrint("Interrupt.sys: HalGetInterruptVector failed\n");

IoInitializeDpcRequest(DeviceObject,InterruptDpcRoutine);

status = IoConnectInterrupt(&DeviceExtension->InterruptObject, // InterruptObject
InterruptIsr, // ServiceRoutine
DeviceObject, // ServiceContext
NULL, // SpinLock
MappedVector, // Vector
Irql, // Irql
Irql, // SynchronizeIrql
Latched, // InterruptMode
FALSE, // ShareVector
DeviceExtension->Affinity, // ProcessorEnableMask
FALSE); // FloatingSave

if (!NT_SUCCESS (status)) DbgPrint("Interrupt.sys: IoConnectInterrupt Failed\n");

/* Enable Parallel Port IRQ's */
outportb(CONTROL, inportb(CONTROL) | 0x10);

DriverObject->MajorFunction[IRP_MJ_CREATE] = InterruptCreateDispatch;
DriverObject->DriverUnload = InterruptUnload;

return STATUS_SUCCESS;
}
 

Status
Not open for further replies.
Toggle Sidebar

Part and Inventory Search

Welcome to EDABoard.com

Sponsor

Top