/*---------------------------------------------------------------------------- Polled serial output for PC Chris Giese http://SisAndHappy.com/ChrisGiese This code is public domain (no copyright). You can do whatever you want with it. Release date: Oct 13, 2003 ----------------------------------------------------------------------------*/ #include /* inportb(), outportb() */ /****************************************************************************/ void ser_putch(int c) { static unsigned io_addr; /**/ if(io_addr == 0) { io_addr = 0x3F8; /* 3F8=COM1, 2F8=COM2, 3E8=COM3, 2E8=COM4 */ outportb(io_addr + 3, 0x80); /* 115200 baud */ outportb(io_addr + 0, 1); outportb(io_addr + 1, 0); /* 8N1 */ outportb(io_addr + 3, 0x03); /* all interrupts disabled */ outportb(io_addr + 1, 0); /* turn off FIFO, if any */ outportb(io_addr + 2, 0); /* loopback off, interrupts (Out2) off, Out1/RTS/DTR off */ outportb(io_addr + 4, 0); } /* Wait for transmitter ready. You could add a timeout here if you want. */ while((inportb(io_addr + 5) & 0x40) == 0) /* nothing */; /* send char */ outportb(io_addr + 0, c); }