platform: s3c2440 + uboot-1.1.4 + linux-2.6.18
买来的开发板串口大多数都是用了 串口0的,而现在要使 串口1和串口2都能够收发数据.
要使其他的串口都能用,只需设置2个地方的可以了。
1) board/smdk2440/smdk2440.c board_init()
// set GPH6,7 as TXD2,RXD2
// set GPH4,5 as TXD1,RXD1
gpio->GPHCON = 0x0015AAAA;
gpio->GPHUP = 0x000007FF;
gpio->GPHDAT &= 0x000006FF;
2) cpu/arm920t/serial.c serial_setbrg()
/* for serial 0 */
S3C24X0_UART * const uart = S3C24X0_GetBase_UART(UART_NR);
int i;
unsigned int reg = 0;
/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
reg = (get_PCLK()/(16*gd->baudrate)) - 1;
/* FIFO enable, Tx/Rx FIFO clear */
uart->UFCON = 0x0;
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;
uart->UBRDIV = reg;
#ifdef CONFIG_HWFLOW
uart->UMCON = 0x1; /* RTS up */
#endif
for (i = 0; i < 100; i++);
/* for touch panel */
uart = S3C24X0_GetBase_UART(UART_TouchPanel_Inf);
/* value is calculated so : (int)(PCLK/16./baudrate) -1 */
// set baudrate as 19200
reg = (get_PCLK()/(16*19200)) - 1;
/* FIFO enable, Tx/Rx FIFO clear */
uart->UFCON = 0x0;
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;
uart->UBRDIV = reg;
#ifdef CONFIG_HWFLOW
uart->UMCON = 0x1; /* RTS up */
#endif
for (i = 0; i < 100; i++);
改了这两个地方串口2就可以正常收发数据了,串口0-2在/dev 目录下的设备名称分别为s3c2410_serial0, s3c2410_serial1, s3c2410_serial2.
但在串口驱动中没有 Read的函数,而在上层中直接调用 read就可以进行读操作.为什么呢?在设备驱动这本书中也提到没有Read函数的,为什么就可以直接读了?
阅读(532) | 评论(0) | 转发(0) |