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

📄 tw2804.c

📁 dvr
💻 C
字号:
 /*
********************************************************************************
*
* (c) Copyright 2004, Vineyard Technologies, Inc.
*
* Filename : tw2804.c
* Programmer(s): KyeongHyeon Steve Lee
* Created : 2004/01/20
* Modified :
*
* Description :
********************************************************************************
*/
#include "types.h"

#ifdef TW2804

#include "i2c.h"
#include "tw2804.h"

#define I2C_BUS_ADDR_TW2804	0xB0 //0x14 SOLTECK, //0xB0 G1PrimeBD

void tw2804_write(BYTE idx, BYTE val);

//**********************************************************************************
//*********************************** NTSC Table ***********************************
//**********************************************************************************

code BYTE tw2804_common[2][38]= // CH1         CH2         CH3         CH4
{
	{ // NTSC
	0x00,0xc4,0xa5,0x1a,	//... 0x00~0x03   0x40~0x43   0x80~0x83   0xc0~0xc3
	0xd0,0x1a,0xd0,0x88,	//... 0x04~0x07   0x44~0x47   0x84~0x87   0xc4~0xc7
	0x20,0x07,0xf0,0x07,	//... 0x08~0x0b   0x48~0x4b   0x88~0x8b   0xc8~0xcb
	0xf0,0x40,0xd2,0x80,	//... 0x0c~0x0f   0x4c~0x4f   0x8c~0x8f   0xcc~0xcf
	0x80,0x80,0x80,0x1f,	//... 0x10~0x13   0x50~0x53   0x90~0x93   0xd0~0xd3
	0x00,0x00,0x00,0x00,	//... 0x14~0x17   0x54~0x57   0x94~0x97   0xd4~0xd7
	0xff,0xff,0xff,0xff,	//... 0x18~0x1b   0x58~0x5b   0x98~0x9b   0xd8~0xdb
	0xff,0xff,0xff,0xff,	//... 0x1c~0x1f   0x5c~0x5f   0x9c~0x9f   0xdc~0xdf
	0x07,0x07,0x00,0x91,	//... 0x20~0x23   0x60~0x63   0xa0~0xa3   0xe0~0xe3 // 0x22[0x00->0x80:Blue Screen
	0x51,0x03
//			 ,0x00,0x00,	//... 0x24~0x27   0x64~0x67   0xa4~0xa7   0xe4~0xe7
//	0x00,0x00,0x00,0x00,	//... 0x28~0x2b   0x68~0x6b   0xa8~0xab   0xe8~0xeb
//	0x00,0x00,0x00,0x00,	//... 0x2c~0x2f   0x6c~0x6f   0xac~0xaf   0xec~0xef
//	0x00,0x00,0x00,0x00,	//... 0x30~0x33   0x70~0x73   0xb0~0xb3   0xf0~0xf3
//	0x00,0x00,0x00,0x00 	//... 0x34~0x37   0x74~0x77   0xb4~0xb7   0xf4~0xf7
	},

	{ // PAL
	0x00,0x84,0xa5,0x28,	//... 0x00~0x03   0x40~0x43   0x80~0x83   0xc0~0xc3
	0xd0,0x28,0xd0,0x88,	//... 0x04~0x07   0x44~0x47   0x84~0x87   0xc4~0xc7
	0x20,0x04,0x20,0x04,	//... 0x08~0x0b   0x48~0x4b   0x88~0x8b   0xc8~0xcb
	0x20,0x4a,0xd2,0x80,	//... 0x0c~0x0f   0x4c~0x4f   0x8c~0x8f   0xcc~0xcf
	0x80,0x80,0x80,0x1f,	//... 0x10~0x13   0x50~0x53   0x90~0x93   0xd0~0xd3
	0x00,0x00,0x40,0x40,	//... 0x14~0x17   0x54~0x57   0x94~0x97   0xd4~0xd7
	0xff,0xff,0xff,0xff,	//... 0x18~0x1b   0x58~0x5b   0x98~0x9b   0xd8~0xdb
	0xff,0xff,0xff,0xff,	//... 0x1c~0x1f   0x5c~0x5f   0x9c~0x9f   0xdc~0xdf
	0x0f,0x0f,0x00,0x91,	//... 0x20~0x23   0x60~0x63   0xa0~0xa3   0xe0~0xe3  // 0x22[0x00->0x80:Blue Screen
	0x51,0x03
//			 ,0x00,0x00,	//... 0x24~0x27   0x64~0x67   0xa4~0xa7   0xe4~0xe7
//	0x00,0x00,0x00,0x00,	//... 0x28~0x2b   0x68~0x6b   0xa8~0xab   0xe8~0xeb
//	0x00,0x00,0x00,0x00,	//... 0x2c~0x2f   0x6c~0x6f   0xac~0xaf   0xec~0xef
//	0x00,0x00,0x00,0x00,	//... 0x30~0x33   0x70~0x73   0xb0~0xb3   0xf0~0xf3
//	0x00,0x00,0x00,0x00 	//... 0x34~0x37   0x74~0x77   0xb4~0xb7   0xf4~0xf7
	}
};

code BYTE tw2804_single_1[8]={	// NTSC, PAL is same
	0x00,0x00,0xf0,0xC4,	//... 0x38~0x3b	// MD configured 0x3b : see below [owen]
	0x80,0x80,0x82,0x82		//... 0x3c~0x3f
	};
	//	MD configuration - 20040511 owen
	//	0x3B register
	//	bit6: NVMD -> 1 : make NVMD pin works for MD
	//	--------------------------------------------
//code BYTE tw2804_single_2[]={	// NTSC, PAL is same
//	0x00,0x00,0x00,0x00,		//... 0x78~0x7b
//	0x00,0x00,0x00,0x00		//... 0x7c~0x7f
//	};


//code BYTE tw2804_single_3[]={	// NTSC, PAL is same
//	0x00,0x00,0x00,0x00,		//... 0xb8~0xbb
//	0x00,0x00,0x00,0x00		//... 0xbc~0xbf
//	};

code BYTE tw2804_single_4[8]={	// NTSC, PAL is same
	0x08,0x42,0x3c,0x20,		//... 0xf8~0xfb	// 0xf9: 40->42, 0xfb: 10->20
	0x00,0x00,0x00,0x00		//... 0xfc~0xff
	};

//===============================================================================
//
//===============================================================================
void tw2804_init(BYTE ntsc_pal)
{
	xdata BYTE reg_off=0;
	xdata BYTE reg_adr;
	xdata BYTE ch;
	xdata BYTE i;

	for(ch=0;ch<4;ch++){

		if     (ch==0) reg_adr = 0x00;
		else if(ch==1) reg_adr = 0x40;
		else if(ch==2) reg_adr = 0x80;
		else           reg_adr = 0xc0;

		for(reg_off=reg_adr,i=0;reg_off<(reg_adr+0x26);reg_off++,i++)
			// channel 1 and 3, we changed the H-delay to remove the vertical black line
			if(ntsc_pal && (reg_off==0x03||reg_off==0x83)) 
				tw2804_write(reg_off, 0x23);
			else
				tw2804_write(reg_off, tw2804_common[ntsc_pal][i]);

		for(reg_off=(reg_adr+0x26);reg_off<(reg_adr+0x38);reg_off++)
			tw2804_write(reg_off, 0);

		if(ch==0){
			for(reg_off=0x38,i=0;reg_off<0x40;reg_off++,i++)
				tw2804_write(reg_off, tw2804_single_1[i]);
		}
		else if(ch==1){
			for(reg_off=0x78;reg_off<0x80;reg_off++)
				tw2804_write(reg_off, 0);
		}
		else if(ch==2){
			for(reg_off=0xb8;reg_off<0xc0;reg_off++)
				tw2804_write(reg_off, 0);
		}
		else if(ch==3){
			for(reg_off=0xf8,i=0;reg_off<0xff;reg_off++,i++)
				tw2804_write(reg_off, tw2804_single_4[i]);
			tw2804_write(0xff,0x00);
		}

	}
}

//===============================================================================
//
//===============================================================================
/*
void tw2804_cam_open(BYTE chs)
{
	return;
	if(chs&0x08)	// channel 1
		tw2804_write(0x22,0x00);
	else
		tw2804_write(0x22,0x80); // BLUE SCREEN

	if(chs&0x04)	// channel 2
		tw2804_write(0x62,0x00);
	else
		tw2804_write(0x62,0x80); // BLUE SCREEN

	if(chs&0x02)	// channel 3
		tw2804_write(0xa2,0x00);
	else
		tw2804_write(0xa2,0x80); // BLUE SCREEN

	if(chs&0x01)	// channel 4
		tw2804_write(0xe2,0x00);
	else
		tw2804_write(0xe2,0x80); // BLUE SCREEN
}
*/
//===============================================================================
//
//===============================================================================
void tw2804_write(BYTE idx, BYTE val)
{
	i2c_pkt_write(I2C_BUS_ADDR_TW2804,idx,val);
}

//===============================================================================
//
//===============================================================================

BYTE tw2804_read(BYTE idx)
{
	return i2c_pkt_read(I2C_BUS_ADDR_TW2804,idx);
}

#endif // TW2804


⌨️ 快捷键说明

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