Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Interupts

Status
Not open for further replies.

elfanddot

Programmer
Feb 21, 2002
28
US
Im having trouble w/ interupts. X-)
I got the code off the web and am modifying it.
here is the code im having trouble w/

struct Ssoundcard card
{
int intcount,autoinit,...
void (interrupt far *oldintvector)(void);
void (interrupt far *inthandler)();//
//**********inthandler wasn't declaired in original code
}

static void interrupt inthandler(Ssoundcard card)
{
card.intcount++;

if (!card.autoinit)/* Start next block first if not using auto-init DMA */
{
startblocksc(card);
copydata(card);
setcurblock(card,!card.curblock); /* Toggle block */
}

updatevoices(card);
mixvoices(card);

if (card.autoinit)
{
copydata(card);
setcurblock(card,!card.curblock);/* Toggle block */
}

inp(card.ackport);//Acknowled interrupt with sound card
outp(0xA0, 0x20);//Acknowledg interrupt with PIC2
outp(0x20, 0x20);//Acknowledg interrupt with PIC1
}

static void installhandler(Ssoundcard card)
{
disable();
outp(card.picmaskport, (inp(card.picmaskport) | card.irqstopmask));

1*:->* card.oldintvector = _dos_getvect(card.irqintvector);
2*:->* _dos_setvect(card.irqintvector, inthandler);

outp(card.picmaskport, (inp(card.picmaskport) & card.irqstartmask));
enable();

card.handlerinstalled = TRUE;
}

static void uninstallhandler(Ssoundcard card)
{
disable();
outp(card.picmaskport, (inp(card.picmaskport) | card.irqstopmask));

3*:->* _dos_setvect(card.irqintvector, card.oldintvector);

enable();

card.handlerinstalled = FALSE;
}


im using borlandc v3.1 and the error messages im recieving
are
1*:->* cannot convert 'void (interrupt far*)(...)' to 'void (interrupt far*)()'
1*:->* cannot convert 'void (interrupt far*)(Ssoundcard)' to 'void (interrupt far*)(...)'
2*:->* type mismatch in parameter '__isr' in call to '_dos_setvect(unsigned int, void (interrupt far*)(...)'
3*:->* cannot convert 'void (interrupt far*)() to void (interrupt far*)(...)'
3*:->* type mismatch in parameter '__isr' in call to '_dos_setvect(unsigned int, void (interrupt far*)(...)'

the original code was writen in C and im compiling in C++.
i understand what the error messages mean yet i don't understand interupt coding very much
any help would be very apprecitated.
 
Better take a peek at your header files and see just WHAT C++ expects the types to be...

I believe your only problem is matching the types. The code looks perfectly fine. You might just need to do type-casting.
"Information has a tendency to be free. Which means someone will always tell you something you don't want to know."
 
this code was written for c, didn't find that out until i change the compiler to c only, i have fixed the code to work with c++ though.
the interrupt handler needed to be
void interrupt inthandler(...) and i pulled the handler and install/uninstall out of the class/struct. im currently working on a way to keep the handler in a class with your interrupt vector help.
youve been a big help so thankyou alot!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top