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

📄 sio.c

📁 dvr
💻 C
字号:
/*
********************************************************************************
*
* (c) Copyright 2002, Vineyard Technologies, Inc.
*
* Filename : sio.c
* Programmer(s): Steve KyeongHyeon Lee
* Created : 2003/02/05
* Modified :
*
* Description :
********************************************************************************
*/

//###############################################################################
//
//###############################################################################
#include "types.h"

#include "8052reg.h"
#include <stdio.h>
#include "sio.h"


//###############################################################################
//
//###############################################################################

xdata char tbuf[TBUF_SIZE];
xdata char rbuf[RBUF_SIZE];
xdata u16 t_in = 0;
xdata u16 t_out = 0;
xdata u16 r_in = 0;
xdata u16 r_out = 0;
//xdata u8 t_disable = 0;

#ifdef RS232_TO_PC_TRANSFER
//xdata u16 num00 =0;
//xdata u16 secnum01;
//xdata u16 secnum02;
#endif

#ifdef DISPLAY_IP_ADDRESS
xdata u16 r_timeout = 0;//for remote control IP recieve  time out
xdata u16 t_timeout = 0;//for remote control IP transfer time out
#endif
#ifdef RE_CON
//====================================================================
// Check SIO input buffer length
//====================================================================

u8 sio_rbuflen(void)
{
	return ( (r_in + RBUF_SIZE - r_out) % RBUF_SIZE );
}

//====================================================================
// Get a character form input SIO buffer
//====================================================================

u8 sio_getchar(void)
{
	u8 ch;
	
	ch = rbuf[r_out];
	if(++r_out==RBUF_SIZE) r_out = 0;
	return(ch);
}



//====================================================================
//
//====================================================================
char sio_putchar(u8 c)
{
	while(t_out!=t_in); // Wait until tx buffer is empty	
	
	tbuf[t_in] = c;

	if((t_in+1)==TBUF_SIZE)
		t_in = 0;
	else
		t_in++;
	//if(t_disable)
	//{
	//	t_disable = 0;

		TI = 1;
	//}
	return (0);
}
#endif //RE_CON
#ifdef DEBUG_PRINT
//====================================================================
//
//====================================================================
char putchar(char c)
{
	sio_putchar(c);
	return (c);
}
#endif

//====================================================================
//
//====================================================================
void sio_init(void)
{
	t_in = 0;
	t_out = 0;
//	t_disable = 1;
	r_in = 0;
	r_out = 0;
#ifdef DISPLAY_IP_ADDRESS
	r_timeout = 0;
	t_timeout = 0;
#endif
}


⌨️ 快捷键说明

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