Chinaunix首页 | 论坛 | 博客
  • 博客访问: 531695
  • 博文数量: 118
  • 博客积分: 3995
  • 博客等级: 中校
  • 技术积分: 1276
  • 用 户 组: 普通用户
  • 注册时间: 2005-11-15 12:15
文章分类

全部博文(118)

文章存档

2014年(1)

2013年(1)

2010年(6)

2009年(27)

2008年(10)

2007年(33)

2006年(38)

2005年(2)

我的朋友

分类: LINUX

2009-02-27 23:06:28

//03F8-03FF ---- serial port (8250,8251,16450,16550,16550A,etc.)// same as 02E8,02F8 and 03E8
void serial_init (void) {
// Turn off the FIFO
outb(COM1+COM_FCR, 0); => outb(0x03FA,0)

// Set speed; requires DLAB latch(锁存器)
//Line Control Register, set Divisor latch access bit
outb(COM1+COM_LCR, COM_LCR_DLAB); => outb(0x03FB,0x80)
//Divisor Latch Low (DLAB=1)
outb(COM1+COM_DLL, (uint8_t)(115200/9600)); => outb(0x03F8,12)
//Divisor Latch High (DLAB=1)
outb(COM1+COM_DLM, 0); => outb(0x03F9,0)

 // 8 data bits, 1 stop bit, parity off; turn off DLAB latch
outb(COM1+COM_LCR, COM_LCR_WLEN8 & ~COM_LCR_DLAB); => outb(0x03FB,0x03)

// set Modem Control Register: No modem controls
outb(COM1+COM_MCR, 0); => outb(0x03FC,0)

// set Interrupt Enable Register: Enable receiver data interrupt
outb(COM1+COM_IER, COM_IER_RDI); => outb(0x03F9,0x01)

// Clear any preexisting overrun indications and interrupts
// Serial port doesn't exist if COM_LSR returns 0xFF
serial_exists = (inb(COM1+COM_LSR) != 0xFF); => inb(0x03FD)
// ??
(void) inb(COM1+COM_IIR); => inb(0x03FA)
(void) inb(COM1+COM_RX); => inb(0x03F8)
}

阅读(1801) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~