}
}
isr_handler (void *arg, int id)
{
// look at the hardware to see if it caused the interrupt
// if not, simply return (NULL);
// return a pointer to an event structure (preinitialized
// by main) that contains SIGEV_INTR as its notification type.
// This causes the InterruptWait in “int_thread” to unblock.
return (&event);
}
main ()
{
pthread_create (NULL, NULL, int_thread, NULL);
...
}
struct sigevent event;
void * int_thread (void *arg)
{
SIGEV_INTR_INIT(&event);
硬件初始化
...
InterruptAttach (IRQ7, isr_handler, NULL, 0, 0);/*跳线设置中断等级为7*/
while (1)
{
InterruptWait (NULL, NULL); /*等待中断发生,信号SIGEV_INTR*/
采集数据
...
}
}
isr_handler (void *arg, int id)
{
// look at the hardware to see if it caused the interrupt
// if not, simply return (NULL);
// return a pointer to an event structure (preinitialized
// by main) that contains SIGEV_INTR as its notification type.
// This causes the InterruptWait in "int_thread" to unblock.
return (&event);
}