cpu/arm920t/s3c24x0/serial.c
#ifdef CONFIG_SERIAL1
#define UART_NR S3C24X0_UART0
int serial_init (void)
{
return serial_init_dev(UART_NR);
}
|
这里使用uart0
static int serial_init_dev(const int dev_index)
{
S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);
/* FIFO enable, Tx/Rx FIFO clear */
uart->UFCON = 0x07;
uart->UMCON = 0x0;
/* Normal,No parity,1 stop,8 bit */
uart->ULCON = 0x3;
/*
* tx=level,rx=edge,disable timeout int.,enable rx error int.,
* normal,interrupt or polling
*/
uart->UCON = 0x245;
_serial_setbrg(dev_index); //设置波特率
return (0);
}
|
这里与vivi中的设置不同,vivi中的串口始终没有开FIFO,而这里开了。
uart->UFCON = 0x07; -> FIFO enable, Rx FIFO reset, Tx FIFO reset
uart->UMCON = 0x0; -> disable modem
uart->ULCON = 0x3;
-> 8bit, one stop bit pre frame, no parity, normal mode operation uart->UCON = 0x245;
[3:2] transmit mode: 01 = interrupt request or polling mode
[1:0] receive mode : 01 = interrupt request or polling mode
[4] send break signal :0 = normal transmit
[5] lookback mode : 0 = normal transmit
[6] Rx Error Status Interrupt Enables : 1 = generate receive error status interrupt
[7] Rx time out enable :0 = disable
[8] Rx interrupt type : 0 = pulse
[9] Tx interrupt type : 1 = level
void _serial_setbrg(const int dev_index)
{
S3C24X0_UART * const uart = S3C24X0_GetBase_UART(dev_index);
unsigned int reg = 0;
int i;
/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
reg = get_PCLK() / (16 * gd->baudrate) - 1;
uart->UBRDIV = reg;
for (i = 0; i < 100; i++);
}
|
骤3中获得的波特率baudrate,现在将这个值写入UBRDIV寄存器中。
计算公式见2410数据手册
好了,现在设置好串口了,那么之后的信息可以通过串口向pc机上的minicom打印出来了。
阅读(2661) | 评论(0) | 转发(0) |