Mail Archives: djgpp/2001/02/22/10:21:36
Hello,
i have a routine to controll the rs 232 serial Port.
It is writen in turbo C.
Compiling with GCC he makes some Errors.
"oldirq" undefined refernce.
At the Top of the file i found:
...
static void (interrupt far *oldirq)(void);
...
int init_232(serial_232_t *sr)
{
int com;
unsigned cntlword;
com=sr->comport ; /* -1 ; */
uart_adrs=irq_adr_table[com-1]; /* get base address */
/* set default IRQ */
/* set IRQ=4 for COM1/3, 3 for COM 2/4 */
sr->irq=(com & 1) == 1 ? 4 : 3;
irqnum=sr->irq;
/* calculate irq mask bit for PIC */
irqmask=1<<sr->irq;
oldirq=getvect(sr->irq+8); /* get old IRQ vector */
setvect(sr->irq+8,comint); /* instal serial interupt handler */
outportb(uart_adrs+LCR,0x83); /* none/8/1 - DLAB set */
/* set baud rate */
outportb(uart_adrs+DATA_REG,baud_table[sr->baud]&0xFF);
outportb(uart_adrs+IER,baud_table[sr->baud]>>8);
/* calculate control word for LCR */
cntlword=(2*sr->parity-sr->parity?1:0)<<4;
cntlword|=2*(sr->stops-1);
cntlword|=sr->bits-5;
outportb(uart_adrs+LCR,cntlword);
outportb(uart_adrs+MCR,0xF); /* enable interrupts */
outportb(uart_adrs+IER,0xF);
outportb(0x21,inportb(0x21)&~irqmask);
return 0;
}
/*
CALL THIS FUNCTION BEFORE PROGRAM EXIT!
or before calling init_232() for a second time
*/
void deinit_232(void)
{
outportb(uart_adrs+IER,0); /* clear UART interrupts */
outportb(uart_adrs+MCR,0);
outportb(0x21,inportb(0x21)|irqmask); /* clear PIC */
setvect(irqnum+8,oldirq); /* restore interrupt vector */
}
How can i compile this serial stuff with GCC.
If you want i send it complete.
It is from Alex Russel written in turbo C.
Thanks
Dietmar
- Raw text -