我手头有一块PCA9554的板子,用的主板芯片是intel ICH9R
8-bit I2C-bus and SMBus I/O port with interrupt
里面有一些寄存器一个中断控制器
Command Protocol Function
0 read byte Input Port register
1 read/write byte Output Port register
2 read/write byte Polarity Inversion register
3 read/write byte Configuration register
Interrupt output
The open-drain interrupt output is activated when one of the port pins change state and
the pin is configured as an input. The interrupt is deactivated when the input returns to its
previous state or the Input Port register is read.
Note that changing an I/O from and output to an input may cause a false interrupt to occur
if the state of the pin does not match the contents of the Input Port register.
在操作PCA9554板子时,能通过定时读取到Input Port register的变化,但效率不高,现在希望能通过硬件中断获取系统通知,我实现了一个驱动,在IRP_MN_START_DEVICE时注册中断
case CmResourceTypeInterrupt:
irql = (KIRQL) resource->u.Interrupt.Level;
vector = resource->u.Interrupt.Vector;
affinity = resource->u.Interrupt.Affinity;
mode = (resource->Flags == CM_RESOURCE_INTERRUPT_LATCHED)
? Latched : LevelSensitive;
irqshare = resource->ShareDisposition == CmResourceShareShared;
gotinterrupt = TRUE;
break;
default:
break;
} // switch on resource type
} // for each resource
NTSTATUS status = IoConnectInterrupt(&pdx->InterruptObject, (PKSERVICE_ROUTINE) OnInterrupt,
(PVOID) pdx, NULL, vector, irql, irql, LevelSensitive, TRUE, affinity, FALSE);
IoConnectInterrupt调用返回成功,但是不能进入中断,不知道问题出在哪儿.