Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Device driver question

3 views
Skip to first unread message

Nick Popoff

unread,
May 21, 2002, 7:01:09 PM5/21/02
to
Greetings all,

I'm writing my first device driver for QNX (for a PC104 DAQ board) and
everything is going very well up to the point of getting my ISR to
actually run. :-) I'm using RTP 6.1 on a P3, compiling with the GCC
that comes with the big RTP ISO.

My program initializes my hardware successfully, and I'm able to
attach a scope to the interrupt line on my hardware to see that it is
indeed triggering, but QNX never runs the ISR I've attached to that
IRQ. I've tried a number of different unused IRQs to make sure it
isn't a simple conflict. I'm only compiling with -O2 so if there's
some compiler option I'm missing that may be the cause of this.

I'm using the driver architecture suggested at the QDN website. Code
to my driver follows. I would very much appreciate any suggestions on
troubleshooting this, or good paper or web resources besides the
obvious qnx.com pages on writing device drivers for QNX 6.

When I run the following, the hardware begins generating interrupts,
but my code blocks at InterruptWait() forever and the ISR is never
called.

---------------

struct sigevent event;

const struct sigevent *isr_handler (void *arg, int id)
{
InterruptMask(IRQ, -1);
return (&event);
}

void *int_thread (void *arg)
{
int status;

status = InterruptAttach (IRQ, isr_handler, NULL, 0, 0);
if ( status == -1 )
return &errno;

my_hardware_startints();

while (1) {
status = InterruptWait(NULL, NULL);
if ( status == -1 )
return &errno;

my_hardware_handleint();

status = InterruptUnmask(IRQ, -1);
if ( status == -1 )
return &errno;
}
}

int main (int argc, char *argv[])
{
pthread_t thread_id;
void *thread_result;
int status;

SIGEV_INTR_INIT(&event);

if ( ThreadCtl(_NTO_TCTL_IO, 0) == -1 )
return 1;

my_hardware_initialize();

status = pthread_create(&thread_id, NULL, int_thread, NULL);
if ( status != 0 )
return 1;

status = pthread_join(thread_id, &thread_result);
}

Nick Popoff

unread,
May 24, 2002, 1:49:47 PM5/24/02
to
goo...@tre.bloodletting.com (Nick Popoff) wrote:
> I'm writing my first device driver for QNX (for a PC104 DAQ board) and
> everything is going very well up to the point of getting my ISR to
> actually run. :-) I'm using RTP 6.1 on a P3, compiling with the GCC
> that comes with the big RTP ISO.

Ah, replying to my own post...

For the benefit of future Google searchers, I'm posting this followup
to point out that my problem was caused by a silly IRQ conflict, so
the simple driver source code in my previous post is actually fine,
and not a bad starting point for folks getting started with QNX6
interrupt handling.

0 new messages