⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 main.c

📁 杭州立宇泰豪华型44B0开发板
💻 C
字号:
#include <string.h>
#include <stdio.h>

#include "Target\44b.h"
#include "Target\44blib.h"


static int UartNum=0;
void myUart_Init(int whichuart, int baud)//对Uart进行初始化,以所需要的波特率为输入参数
{
   if(whichuart==0)
   {
        UartNum=0;
        rUFCON0=0x0;    //不使用FIFO
        rUMCON0=0x0;   //不使用自动流控制
        rULCON0=0x3; //不采用红外线传输模式,无奇偶校验位,1个停止位,8个数据位
        rUCON0=0x245;   //发送中断为电平方式,接收中断为边沿方式,禁止超时中断,允许产生错误状态中断,禁止回送模式,禁止中止信号,传输模式为中断请求模式,接收模式也为中断请求模式。
        rUBRDIV0 = ( (int)(MCLK/16./baud + 0.5) -1 ); //根据波特率计算UBRDIV0的值
    }
    else if(whichuart==1)
    {
        UartNum=1;
        rUFCON1=0x0;    
        rUMCON1=0x0;   
        rULCON1=0x3; 
        rUCON1=0x245; 
        rUBRDIV1 = ( (int)(MCLK/16./baud + 0.5) -1 );
    }
}

void myUart_SendByte(char ch)
{
	if (UartNum ==0)
    {
		if(ch=='\n')
		{
		    while(!(rUTRSTAT0 & 0x2));//等待,直到发送缓冲区为空
		    //Delay(10);	//超级中断的响应速度较慢 
		    WrUTXH0('\r');//发送回车符
		}
		while(!(rUTRSTAT0 & 0x2)); //等待,直到发送缓冲区为空
		Delay(10);
		WrUTXH0(ch);//发送字符
   	}
	else
    {
		if(ch=='\n')
	    {
		    while(!(rUTRSTAT1 & 0x2));
		    Delay(10);	//because the slow response of hyper_terminal 
		    rUTXH1='\r';
	    }
	    while(!(rUTRSTAT1 & 0x2));  //Wait until THR is empty.
	    Delay(10);
	    WrUTXH1(ch);
    }	
}	


void myUart_Send (char *str)
{
    myUart_Init(0,115200);
	while (*str)
	  myUart_SendByte(*str++);
}


void Main(void)
{
	char aa;
	
    Port_Init();
	Led_Display(0xf);
	Beep(0x1);
	myUart_Send("\n*************************************************************************");
	myUart_Send("\n*                             立宇泰电子                                *");
	myUart_Send("\n*                            -UART test-                                *");
	myUart_Send("\n*                           Version 1.21                                *");    
	myUart_Send("\n*                     Email:Support@hzlitai.com.cn                      *");
	myUart_Send("\n*               UART0 Config--COM:115.2kbps,8Bit,NP,UART0               *");
	myUart_Send("\n*-----------------------------------------------------------------------*");
    Beep(0x0);
	Led_Display(0x0);
    while(1);
	
}

⌨️ 快捷键说明

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