/*******WkInit*******************************************/
//函数功能:初始化子串口
/*******************************************************/
void wk2168_sub_uart_init(u8 port)
{
u8 gena,grst,gier,sier,scr;
//使能子串口时钟
gena=wk2168_read_g_reg(WK2XXX_GENA);
gena=gena|(1<<(port-1));
wk2168_write_g_reg(WK2XXX_GENA,gena);
//软件复位子串口
grst=wk2168_read_g_reg(WK2XXX_GRST);
grst=grst|(1<<(port-1));
wk2168_write_g_reg(WK2XXX_GRST,grst);
//使能串口总中断
gier=wk2168_read_g_reg(WK2XXX_GIER);
gier=gier|(1<<(port-1));
wk2168_write_g_reg(WK2XXX_GIER,gier);
//使能子串口接收触点中断和超时中断
sier=wk2168_read_s_reg(port,WK2XXX_SIER);
sier |= WK2XXX_RFTRIG_IEN|WK2XXX_RXOUT_IEN;
wk2168_write_s_reg(port,WK2XXX_SIER,sier);
//初始化FIFO和设置固定中断触点
wk2168_write_s_reg(port,WK2XXX_FCR,0XFF);
//设置任意中断触点,如果下面的设置有效,
//那么上面FCR寄存器中断的固定中断触点将失效
wk2168_write_s_reg(port,WK2XXX_SPAGE,1);//切换到page1
wk2168_write_s_reg(port,WK2XXX_RFTL,0X40);//设置接收触点为64个字节
wk2168_write_s_reg(port,WK2XXX_TFTL,0X10);//设置发送触点为16个字节
wk2168_write_s_reg(port,WK2XXX_SPAGE,0);//切换到page0
//使能子串口的发送和接收使能
scr=wk2168_read_s_reg(port,WK2XXX_SCR);
scr|=WK2XXX_TXEN|WK2XXX_RXEN;
wk2168_write_s_reg(port,WK2XXX_SCR,scr);
}
|