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

📄 reimplement.c

📁 ucosII 2.84版源码
💻 C
字号:
#include "includes.h"


extern unsigned char	ucX;									//current cursor colum 0~15
extern unsigned char	ucY;									//current cursor line 0~3
extern unsigned char	Flag;

/*
** These must be defined to avoid linking in stdio.o from the
** C Library
*/
//struct __FILE { int handle;   /* Add whatever you need here */};
FILE __stdout;
FILE __stdin;

/*
** __backspace must return the last char read to the stream
** fgetc() needs to keep a record of whether __backspace was
** called directly before it
*/
int last_char_read;
int backspace_called;

int fputc(int ch, FILE *f)
{
	static unsigned int isHz=0;
	uchar ucTmpch = (uchar)ch;
	uchar ucHz[2];
	
	
	if(f->handle == 0)
	{
		vUartSendByte(UART1, ucTmpch);
	}
	else
	{
		if(ucTmpch == '\r')
		{
			ucX=0;
			return ch;
		}
		if(ucTmpch == '\n')
		{
			//ucX=0;
			ucY+=2*8;
			return ch;
		}
		if(ucX>=40)
		{
			ucX=0;
			ucY+=2*8;
		}
		if(ucY>=240)
		{
			Flag = 0;
			return ch;
		}
		
		if(ucTmpch<0xa1)				//是否是汉字
		{
			WriteChar(ucTmpch);	//不是汉字
		}
		else
		{
			if(isHz==0)
			{
				isHz = 1;
				ucHz[0] = ucTmpch;
			}
			else
			{
				ucHz[1] = ucTmpch;
				WriteChChar(ucHz);	//是汉字
				isHz = 0;
			}
		}
	}
    

    return ch;
}

int fgetc(FILE *f)
{
	f = f;
	return 0;
}

void _ttywrch(int ch)
{
	uchar ucTmpch = (uchar)ch;
	
    vUartSendByte(UART1, ucTmpch);
}

/*
** The effect of __backspace() should be to return the last character
** read from the stream, such that a subsequent fgetc() will
** return the same character again.
*/
int __backspace(FILE *f)
{
    backspace_called = TRUE;
    return 1;
}

int _sys_close(FILEHANDLE fh)
{
	fh = fh;
	return 0;
}

int _sys_write(FILEHANDLE fh, const unsigned char * buf, unsigned len, int mode)
{
	fh = fh;
	buf = buf;
	len =len;
	mode = mode;
	return 0;
}
int _sys_read(FILEHANDLE fh, unsigned char * buf, unsigned len, int mode)
{
	fh = fh;
	buf = buf;
	len =len;
	mode = mode;
	return 0;
}

int _sys_istty(FILEHANDLE fh)
{
	fh = fh;
	return 0;
}
int _sys_seek(FILEHANDLE fh, long pos)
{
	fh = fh;
	return 0;
}
int _sys_ensure(FILEHANDLE fh)
{
	fh = fh;
	return 0;
}

long _sys_flen(FILEHANDLE fh)
{
	fh = fh;
	return 0;
}
int _sys_tmpnam(char * name, int sig, unsigned maxlen)
{
	name = name;
	sig = sig;
	maxlen = maxlen;
	return 0;
}

char *_sys_command_string(char * cmd, int len)
{
	cmd = cmd;
	len = len;
	return 0;
}

int __rt_div0(int a)
{
	a = a;
	return 0;
}

int ferror(FILE *f)
{
    return EOF;
}

void _sys_exit(int return_code)
{
	return_code = return_code;
    while(1);
}

⌨️ 快捷键说明

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