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

📄 44blib.c

📁 一款类linux的操作系统源码
💻 C
字号:
#include <44b.h>

int whichUart = 0;
int delayLoopCount;

void Delay(int time)
// time=0: adjust the Delay function by WatchDog timer.
// time>0: the number of loop time
// 100us resolution.
{
    int i,adjust=0;
    if(time==0)
    {
	time=200;
	adjust=1;
	delayLoopCount=400;
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3);    //MCLK/1M,Watch-dog disable,1/64,interrupt disable,reset disable
	rWTDAT=0xffff;//for first update
	rWTCNT=0xffff;//resolution=64us	@any MCLK 
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3)|(1<<5); //Watch-dog timer start
    }
    for(;time>0;time--)
	for(i=0;i<delayLoopCount;i++);
    if(adjust==1)
    {
	rWTCON=((MCLK/1000000-1)<<8)|(2<<3);//Watch-dog timer stop
	i=0xffff-rWTCNT;		//1count->64us, 200*400 cycle runtime = 64*i us
	delayLoopCount=8000000/(i*64);	//200*400:64*i=1*x:100 -> x=80000*100/(64*i)   
    }
}


void Uart_SendByte(int data)
{
    if(whichUart==0)
    {
	if(data=='\n')
	{
	    while(!(rUTRSTAT0 & 0x2));
	    Delay(10);	//because the slow response of hyper_terminal 
	    WrUTXH0('\r');
	}
	while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
	Delay(10);
	WrUTXH0(data);
    }
    else
    {
	if(data=='\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);
	rUTXH1=data;
    }	
}		

⌨️ 快捷键说明

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