delorie.com/archives/browse.cgi   search  
Mail Archives: djgpp/2001/02/22/10:21:36

From: Dietmar DOT Segbert AT T-ONLINE DOT de (Dietmar Segbert)
Newsgroups: comp.os.msdos.djgpp
Subject: rs 232 stuff
Date: 22 Feb 2001 15:27:00 +0100
Organization: T-Online
Lines: 71
Message-ID: <7wMZ3ulbJVB@0256597511.t-online.de>
Mime-Version: 1.0
X-Trace: news.t-online.com 982854348 07 15702 W+9y-NbSu-YDb 010222 15:05:48
X-Complaints-To: abuse AT t-online DOT com
X-Sender: 0256597511-0001 AT t-dialin DOT net
X-Newsreader: CrossPoint v3.12d R/A22565
X-Mailer: NOS-BOX 2.05
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

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 -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019