Information Technology Reference
In-Depth Information
char status;
do
{
status = inportb(LSR) & 0x40;
} while (status!=0x40);
/*repeat until Tx buffer empty ie bit 6 set*/
outportb(TXDATA,(char) ch);
}
int get_character(void)
{
int status;
do
{
status = inportb(LSR) & 0x01;
} while (status!=0x01);
/* Repeat until bit 1 in LSR is set */
return( (int)inportb(TXDATA));
}
int get_buffer(void)
{
int ch;
if (startbuf == endbuf) return (-1);
ch = (int) buffer[startbuf];
startbuf++;
if (startbuf == RSBUFSIZE) startbuf = 0;
return (ch);
}
void set_vectors(void)
{
oldvect = getvect(0x0C);
setvect(0x0C, rs_interrupt);
}
/* Uninstall interrupt vectors before exiting the program */
void reset_vectors(void)
{
setvect(0x0C, oldvect);
}
void disable_interrupts(void)
{
int ch;
disable();
ch = inportb(IMR) | ~IRQ4; /* disable IRQ4 interrupt */
outportb(IMR, ch);
outportb(IER, 0);
enable();
}
void enable_interrupts(void)
{
int ch;
disable();
/* initialize rs232 port */
ch = inportb(MCR) | MC_INT;
outportb(MCR, ch);
/* enable interrupts for IRQ4 */
outportb(IER, 0x01);
ch = inportb(IMR) & IRQ4;
Search WWH ::




Custom Search