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

📄 root.c

📁 dvr
💻 C
字号:
//==============================================================
// ROOT.C
// Common rom code for back switching.
//==============================================================

#include "types.h"

#include <absacc.h>
#include "gio.h"
#include "audio.h"
#include "socket.h"
#include "sio.h"
#ifdef TMP_DEL
#include "lan.h"
#include "bfpga.h"
#endif

xdata	u16	timeout_counter;				// Variable used for delay routines
xdata	u8	time_read_flag1 = 0;
xdata	u8	time_read_flag2 = 0;
xdata	u8	time_read_flag3 = 0;
xdata 	u8 	gv_connection_closing = FALSE;
xdata	u8 	gv_int0_flag = LOW;
#ifdef LANIF
xdata	u8	gv_int1_flag = 0;
#endif
xdata 	u8 	gv_bfpga_move_done = 0;
xdata	u8 	gv_bfpga_move_start = 0;

#ifdef RECORD_STOP_PASSWORD
xdata   u8      blink_time = 0;
#endif

extern void gmain(void);
extern void hdd_pre_write(u8 aud_rec_intr);

#ifdef ROM128K
sfr ROMCON = 0xAB;
#endif

//==============================================================
//
//==============================================================
void main(void)
{
#ifdef ROM128K
	ROMCON = 0x0E;
#endif
	gmain();
}


//================================================================
//
//================================================================
timer0() interrupt 1 using 1
{
	//if(gv_int0_flag == LOW) // 2002.11.02
	{
		timeout_counter++;
		if(timeout_counter > 49)    // 1SEC TIMER : 40Mhz
		{
			time_read_flag2 = 1;
			timeout_counter = 0;
  		}
		else if((timeout_counter % 5) == 0)   // 100msec
		{
			time_read_flag1 = 1;
#ifdef RECORD_STOP_PASSWORD
                        if(blink_time)
                               blink_time--;
#endif
		}
		else if((timeout_counter % 2) == 0)	// 40msec
			time_read_flag3 = 1;
#ifdef DISPLAY_IP_ADDRESS
		if(r_timeout != 0)
		        r_timeout++;
		if(t_timeout != 0)
		        t_timeout++;
#endif

		TH0 = TIMER0_50_HI;
		TL0 = TIMER0_50_LOW;

	}
}

//================================================================
//
//================================================================
idata u8 int0_gpio_g1;
idata u8 int0_gpio_lan;
idata u8 int0_gpio_aud;
idata u8 int0_flag = 0;

void int0(void) interrupt 0
{

	EX0 = 0;	// In external interrupt-0 service routine

	if(gv_connection_closing){

		// save current GPIO port
		int0_gpio_g1 = SEL_GENESIS;
		int0_gpio_lan = SEL_LAN;
		if(gv_audif) int0_gpio_aud = SEL_AUDIO;

		gv_audio_reg_play = audioif_get_regPLAY();
		if(gv_audio_reg_play&0x02)// interrupt happen just when recording mode
		{
			audioif_clear_internal_flag(0x00);
			audioif_clear_interrupt();
			_audioif_clear_IDE_request();
			int0_flag = 1;
		}

		// restore gpio selection
		SEL_GENESIS = int0_gpio_g1;
		SEL_LAN = int0_gpio_lan;
		if(gv_audif) SEL_AUDIO = int0_gpio_aud;

	}

	if(int0_flag==0)
	{
		gv_int0_flag = HIGH;
	}
	else
	{
		EX0 = 1; // In external interrupt-0 service routine -- audio int0 service done.
	}


}



//====================================================================
// Interrupt service routine for external interrupt 1
// External interrupt 1 is from FPGA and W3100A.
// We will save current GPIO value for chip select (GENESIS,OSD,W3100A+FPGA)
// and set the GPIO to access W3100A and FPGA.
// After finishing interrupt service routine, restore the GPIO value.
//====================================================================
idata u8 int1_status;
idata int1_gpio_g1;
idata int1_gpio_lan;
idata int1_gpio_aud;		// bdata bit

void int1(void) interrupt 2//	using 3// External Interrupt number 1
{


#ifdef DEBUG_GPIO
	P11_INT1 = HIGH;
#endif
	//==============================================================
	// disable interrupt
	EX1 = 0;
	
	// save current GPIO port

	int1_gpio_g1 = SEL_GENESIS;
	int1_gpio_lan = SEL_LAN;
	if(gv_audif) int1_gpio_aud = SEL_AUDIO;


	//#####################################################################	
    #ifdef TMP_DEL
	lan_enable();

	// save idm address value
	idm_save();

	// check interrupt source
	int1_status = BFREG_STATUS;

	if (int1_status & TXINT) {

		//BFREG_STATUS = status | TXINT;						// Clear interrupt(TXINT)
		BFREG_STATUS = TXINT;						// Clear interrupt(TXINT)
		gv_bfpga_move_done = 1;
		gv_bfpga_move_start = 0;
	}

	if (int1_status & WNINT) {
#ifdef DEBUG_GPIO
		P15_INTWZ = HIGH;
#endif
		SOCK_ISR_W3100A(&gv_lan_interrupt_flag);	// check W3100A interrupt
#ifdef DEBUG_GPIO
		P15_INTWZ = LOW;
#endif
	}

	lan_enable();
	// restore idm address value

	idm_restore();
    #endif
	gv_int1_flag = HIGH;

	//#####################################################################
	// restore GPIO port
	
	SEL_GENESIS = int1_gpio_g1;
	SEL_LAN = int1_gpio_lan;
	if(gv_audif) SEL_AUDIO = int1_gpio_aud;

	// enable interrupt
	EX1 = 1;
#ifdef DEBUG_GPIO
	P11_INT1 = LOW;
#endif
}


//====================================================================
//
//====================================================================
//extern void osd_showhexdword(u32 bData, u8 bXPos, u8 bYPos, u8 bType);
static void sio_isr (void) interrupt 4 using 2
{
	if(RI != 0) // If receive a byte,
	{
		RI = 0;
		if(((r_in + 1)%RBUF_SIZE) != r_out)	// If rx buffer is not full
		{
			rbuf[r_in] = SBUF;
			if((r_in+1)==RBUF_SIZE)
				r_in = 0;
			else
				r_in++;
		}
	}

	if(TI != 0) // Tx interrupt happnes
	{
		if(t_in != t_out) // If tx buffer is not empty
		{
			SBUF = tbuf[t_out];
			if((t_out+1)==TBUF_SIZE)
				t_out = 0;
			else 
				t_out++;
#ifdef RS232_TO_PC_TRANSFER
//			num00++;
#endif
		}
		//else//20051103 remove by paul
		//	t_disable = 1;
		TI = 0;
	}
}

⌨️ 快捷键说明

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