ARM输入输出

来源:互联网 发布:2008最伤感网络歌曲 编辑:程序博客网 时间:2024/06/10 21:50


//GPA1

#define GPA1CON (volatile unsigned int *)0x11400020
//#define GPA1DAT (volatile unsigned int *)0x11400024


//ULCON2
#define ULCON2 (volatile unsigned int *)0x13820000
#define UCON2  (volatile unsigned int *)0x13820004




#define UBRDIV2   (volatile unsigned int *)0x13820028
#define UFRACVAL2 (volatile unsigned int *)0x1382002c


#define UTXH2 (volatile unsigned int *)0x13820020
#define URXH2 (volatile unsigned int *)0x13820024


#define UTRSTAT2 (volatile unsigned int *)0x13820010






void uart_init(void)
{
*GPA1CON = *GPA1CON & ~(0xff) | 0x22;//复用




*ULCON2 = 0x3;
*UCON2 = *UCON2 & ~(0xf) | 0x5;


*UBRDIV2 = 53;
*UFRACVAL2 = 4;


}


char uart_rxd(void)
{
while(!(*UTRSTAT2 & (0x1)));
return *URXH2;
}


void uart_txd(char c)
{
while(!(*UTRSTAT2 & (0x2)));
*UTXH2 = c;
}




void main(void)
{
uart_init();
while(1)
{
uart_txd(uart_rxd());
}


}
原创粉丝点击