S3C2440的UART程序设计
扫描二维码
随时随地手机看文章
//************UART查询**************
extern void Init_check_uart()
{
rGPHCON |= 0xa0;
rGPHUP = 0x0;
rULCON0 = 0x03;
rUCON0 = 0x05;
rUFCON0 = 0x00;
rUMCON0 = 0x00;
rUBRDIV0 = 53;//PCLK=50MHz,波特率57600
dely(10);
}
extern void send_char(unsigned char c)
{
while(!(rUTRSTAT0 &0x04));
rUTXH0 = c;
}
extern void send_str(unsigned char *str)
{
int i=0;
while(str[i])
{
send_char((unsigned char) str[i++]);
}
}
//************UART中断**************
void __irq uart0_irq(void)
{
unsigned long irqOffSet;
Led_all_on();
dely(350);
Led_all_off();
dely(350);
irqOffSet = rINTOFFSET;// 取得中断号
rSUBSRCPND |= 1<<1;
rSRCPND |= 1< rINTPND |= 1<<28;// 清除中断结果 rUTXH0 = '1'; } extern void Init_Interrupt_uart() { rGPHCON |= 0xa0; rGPHUP = 0x0; rULCON0 = 0x03; rUCON0 = 0x05; rUFCON0 = 0x00; rUMCON0 = 0x00; rUBRDIV0 = 53;//PCLK=50MHz,波特率57600 dely(100); pISR_UART0 = (unsigned int)uart0_irq; rINTSUBMSK &= ~(1<<1); rINTMSK &= ~(1<<28); rUTXH0 = '1'; dely(10); }