uart.c

来自「USB测试程序」· C语言 代码 · 共 47 行

C
47
字号
#include		"config.h"



void uart0_init(uint32 bps)
{
	uint16	Fdiv;
	
    PINSEL0   &= ~(0x0F <<  4);                 // Clear the UART0 Function bits
    PINSEL0   |=  (0x01 <<  4);                 // Configure P0.2 for use with UART0 TxD
    PINSEL0   |=  (0x01 <<  6);  

    U0FCR = 0x07;								// Set the FIFO enable bit in the FCR register
    							   				//	This bit must be set for proper UART operation
    
    /* Set baudrate */    
	U0LCR=0x83;									// 8位数据传输,使能访问除数锁存器
	Fdiv=(Fpclk/16)/bps;
    U0DLL = Fdiv%256;
    U0DLM = Fdiv/256;
	U0LCR=0x03;									// 8 bit word length, 1 stop bit, No parity
    U0IER = 1; 									// Enable byte received interrupt
	
    VICIntSelect &= ~(1 << VIC_UART0);  				// IRQ on UART0
    VICVectPriority6 =  VIC_UART0; 						// Enable vector interrupt for UART0
    VICVectAddr6 = (uint32) uart0_handler;
    VICIntEnable |= (1 << VIC_UART0);    				// Enable UART 1 interrupt
}


void uart0_sendbyte()
{
	


}

void uart0_exception()
{
	





}

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?