?? uhal.c
字號:
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include <stdio.h>
#include "uhal.h"
#include "..\inc\44b.h"
void Uart_SendByte(int data);
int Uart_printf(const char *fmt, ...)
{
va_list ap;
static char string[256];
unsigned char *pStr = (unsigned char *)string;
unsigned int i = 0;
va_start(ap,fmt);
vsprintf(string,fmt,ap);
va_end(ap);
while( (*pStr) && i<256) {
Uart_SendByte(*pStr);
pStr++; i++;
}//while
return 1;
}//uHALr_printf
//////////////////////////////////////////////////////////////////
//utilities
//////////////////////////////////////////////////////////////////
void Delay(int time)
{
int i;
for( i = 0 ; i < time*5000 ; i++ );
}
void Uart_SendByte(int data)
{
if(data=='\n')
{
while(!(rUTRSTAT0 & 0x2));
Delay(10); //because the slow response of hyper_terminal
WrUTXH0('\r');
}//if
while(!(rUTRSTAT0 & 0x2)); //Wait until THR is empty.
Delay(10);
WrUTXH0(data);
}//Uart_SendByte
void Uart_Init(int baud)
{
int i,mclk = 66000000;
rUFCON0=0x0; //FIFO disable
rUMCON0=0x0;
//UART0
rULCON0=0x3; //Normal,No parity,1 stop,8 bit
rUCON0=0x5; //rx=edge,tx=level,disable timeout int.,enable rx error int.,normal,interrupt or polling
rUBRDIV0=( (int)(mclk/16/baud + 0.5) -1 );
for(i=0;i<100;i++);
}
char Uart_Getch()
{
while(!(rUTRSTAT0 & 0x1)); //Receive data read
return rURXH0;
}
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -