默认的内核中不支持Uart1,要在内核初始化时将它初始化。修改文件arch/arm/mach-davinci/board-dm355-evm.c,在函数board-init函数中增加如下红色部分
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_McBSP1, 1);
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_SPI, 1);
/* Turn on WatchDog timer LPSC. Needed for RESET to work */
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_TIMER2, 1);
/*add uart1 by xujiaxin*/
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_UART1,1);
/*end add*/
davinci_serial_init(&serial_device);
davinci_writel(0x56837210, DAVINCI_VPSS_REGS_BASE + 0x810);
davinci_writel(0x7b3c0004, DAVINCI_VPSS_REGS_BASE + 0x814);
/*enable uart1 by jiaxinxu*/
ptr_pgmgt = (volatile int *)IO_ADDRESS(DAVINCI_UART1_BASE+0x30);
ptr_ier = (volatile int *)IO_ADDRESS(DAVINCI_UART1_BASE+0x4);
*ptr_pgmgt=0x0;
*ptr_ier =0x0;
int del;
for(del=0;del<100000;del++)
*ptr_pgmgt=0x6001;
/*end enable*/
运行rs232程序,一开始函数在发送0x0a时老是会先发送一个0x0d,后来在程序中加入下面两句话
/*RAW格式 否则会出错*/
options.c_lflag&=~(ICANON|ECHO|ECHOE|ISIG);
options.c_oflag&=~OPOST;
就不会出错了。
board_setup_psc函数用来设置PSC模块,该模块的作用是开启某个模块的电源以及使能某个模块。
对UART2进行初始化的时候,必须注意UART2和SD1是复用的。没有改动前的内核初始化时自动的初始化SD1而不是UART2。需要进行一下几点动作才能将SD1的初始化屏蔽掉。
//choose uart2 instead of sd1 jiaxinxu
PINMUX3&=~0x0000ffff;
PINMUX3|= 0x0000a000;
将引脚功能置成UART2,
//conflict with uart2 by jiaxinxu
board_setup_psc(DAVINCI_GPSC_ARMDOMAIN, DAVINCI_LPSC_MMC_SD1, 0);
禁能PSC
#if defined(CONFIG_MMC_DAVINCI) || defined(CONFIG_MMC_DAVINCI_MODULE)
&mmc0_device,
//conflict with uart2 by jiaxinxu
//&mmc1_device,
没有评论:
发表评论