Menu

#19 Support for Interrupt Service Routine with parameter

open
nobody
libnds (16)
5
2014-02-18
2008-05-03
Peter
No

I would find it enormously useful if the interrupt service routine you specify with irqSet has a void pointer to custom user data.

This allows the irq initializer to pass an object to the ISR without using global variables.

For example, the current way to go is:
[code]
void* global_data;

void isr()
{
// do stuff with global_data
}

void myclass::setupIrq()
{
// assume data a member of myclass here
// but since we can't pass a pointer
// to isr we have to store it in a global variable
global_data = &data;

irqSet(IRQ_HBLANK, isr);
}
[/code]

But imo it's more useful and also cleaner this way:
[code]
void isr(void* userdata)
{
// do stuff with userdata aka data
}

void myclass::setupIrq()
{
// assume data a member of myclass here
irqSet(IRQ_HBLANK, isq, &data);
}
[/code]

Discussion


Log in to post a comment.

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.