CMP EMBEDDED.COM

Login | Register     Welcome Guest   IPS  
HOME DESIGN PRODUCTS COLUMNS E-LEARNING CONFERENCES CODE FORUMS/BLOGS NEWSLETTERS CONTACT FEATURES RSS RSS

Listing 5: Getting an interrupt vector


// thread used as deferred procedure call created in init_module
void *pp_thread_ep(void* arg)
{
while (1) 
{
pthread_wait_np(); // wait to be woken up...
// process interrupt now in realtime kernel context
...
}
}
// interrupt handler
unsigned int irq_handler(unsigned int irq, struct pt_regs *regs) 
{
pthread_wakeup_np(pp_thread); // wake up thread to do IRQ post-processing
rtl_hard_enable_irq(IRQ_LINE); // re-enable IRQ
return 0;
}
int init_module(void) 
{
// create thread pp_thread to wake up by interrupt handler
...
rtl_request_irq(IRQ_LINE, irq_handler); // request...
rtl_hard_enable_irq(IRQ_LINE); // ...and enable interrupt handler
}
void cleanup_module(void) 
{
rtl_free_irq(IRQ_LINE);
// do the rest of clean=up sequence
}

Embedded.com Career Center
Ready for a change?
SEARCH JOBS

Browse all jobs

SPONSOR
RECENT JOB POSTINGS





 :