tv.h

来自「CS8955控制TV软件。用MCU做模拟电视的控制。」· C头文件 代码 · 共 272 行

H
272
字号
/******************************************************************************\
     Project Version:   MTKCARDVD()
********************************************************************************
     Filename:          Tv.h

     Author:            Bonson chen

     Company:           CoreTek/ACT Company

********************************************************************************
     File Version:      1.01
     File Created:      July 2007

     Compiled Using:    keil uVision2 Version 2.23 

********************************************************************************
     Files Required:

********************************************************************************
     File Description:

********************************************************************************
     File History:

--------------------------------------------------------------------------------
  Date         Name           Description
--------------------------------------------------------------------------------
  Mar. 2007    bonson chen    File Created
  
\******************************************************************************/

#ifdef ENABLE_TV

#if 1 //#ifdef MARTIN_TEST_TV_IIC   //martin 29May08
#define I2C_TVPLL_ADDR	       0xc0 // 0xc2
#else
#define I2C_TVPLL_ADDR	       0xc2  // 0xc2
#endif
#define I2C_TVIF_ADDR		0x86 // 0x86


#define I2C_TVADC_ADDR	       0xc0 // 0xc2




#define SV_PAL               0
#define SV_AUTO              1
#define SV_NTSC              2
#define SV_SECAM_L	     3
#define SV_SECAM_L2     4
#define SV_PAL_M           5
#define SV_PAL_N	    6

#define TV_SYSTEM_DEFAULT   SV_PAL

#define SV_MN              0    //tv sound:M/N/L
#define SV_BG              1
#define SV_I              2
#define SV_DK	     3
#define TV_SOUND_MAX 4
#define TV_SOUND_DEFAULT    SV_I
/*
enum {
TV_SOUND_MN_L=0,
TV_SOUND_BG, 
TV_SOUND_I, 
TV_SOUND_DK, 
TV_SOUND_MAX
};
#define TV_SOUND_DEFAULT   TV_SOUND_I
*/

//// TV SYSTEM DEFAUL   11Sep08
#define SV_DEFAUL_PAL_I           0xd0
#define SV_DEFAUL_PAL_DK           0xd8
#define SV_DEFAUL_PAL_BG           0xC8
#define SV_DEFAUL_NTSC_MN           0xC2

////

#define TV_TYPE_TNJ7355    0x00
#define TV_TYPE_XF6A         0x01
#define TV_TYPE_DEFAULT  TV_TYPE_XF6A


//#define IF_SWITCH_DEFAUL   0xd0  // bTunerVal  //0xd0      //TV_SOUND_I +SV_PAL                   0xc8 //AFCAdj_on + Skip_off + TV_SOUND_BG +SV_PAL 




// PLL
#define VHF_LOW_BAND			0
#define VHF_HIGH_BAND			1
#define UHF_BAND				2
#define PAL_PIF				3890
#define NTSC_PIF				3890

#define US_TV_CABLE				0
#define US_TV_AIR				1


#ifdef MARTIN_TV_FREQUENCE_DATA_USE_HEX
#define VHF_LOW_BOT		0x0572   //48.25 0x0532	// 44.25	
#define VHF_LOW_TOP		0x0c82	// 161.25
#define VHF_HIGH_BOT		0x0cf2	// 168.25
#define VHF_HIGH_TOP		0x1f62	// 463.25
#define UHF_BOT				0x1fe2	// 471.25
#define UHF_TOP				0x3862	//863.25 0x383a  //860.25M  //0x3862	//863.25

#define VHF_LOW_BOT_XF6A		0x0572   // 48.25 0x0532	// 44.25	
#define VHF_LOW_TOP_XF6A		0x0b32	// 140.25
#define VHF_HIGH_BOT_XF6A		0x0b72	// 144.25
#define VHF_HIGH_TOP_XF6A		0x1d22	// 427.25
#define UHF_BOT_XF6A			0x1d62	// 431.25
#define UHF_TOP_XF6A			0x37e2	//863.25 0x383a  //860.25M  //0x3862	//863.25


#else
#define VHF_LOW_BOT		1330	// 44.25	
#define VHF_LOW_TOP		3202	// 161.25
#define VHF_HIGH_BOT		3314	// 168.25
#define VHF_HIGH_TOP		8034	// 463.25
#define UHF_BOT				8162	// 471.25
#define UHF_TOP				14434	//863.25
#endif

// 1 CP T2 T1 T0 RSA RSB WSB
//CP:charge pump current 		0:20uA, 1:100uA
//WSB:wwak signal booster control	0:normal ,no gain increase IF filter
//								1:booster activated,IF filter by-pass
//test bit:	T2  		T1  		T0
//			0		0		0	normal mode
//			0		0		1	normal mode,default at power-on-reset
//			0		1		0	charge pump is 'OFF'
//			0		1		1	byte BB ignored
//			1		1		0	charge pump is sinking current
//			1		1		1	charge pump is sourcing current
//			1		0		0	FREF/2 is available on port P3
//			1		0		1	FDIV/2 is available on port P3
//ratio select:	RSA		RSB
//			x		0			80
//			0		1			128
//			1		1			64
// lun hahaha
//#define TUNER_CB1			0x88	//
#if 1 //#ifndef TUNER_USE_XF6A
#define TUNER_CB1			0xce    //martin 14May08   STEP SIZE
#else
#define TUNER_CB1			0x88	//
#endif
#define TUNER_CB1B			0x89	//

#define TUNER_BB1			0x01	//VHF_LOW band
#define TUNER_BB2			0x02	//VHF_HIGH band
#define TUNER_BB3			0x04	//UHF band  tuner:TNJ7355
#define TUNER_BB3_XF6A        0x08	      //UHF band  tuner:XF6A

//Video IF:		38.9M(B/G , I , D/K)  	           	E4 E3 E2 :	0 1 0
//SOUND 2nD IF:	5.5M(B/G)					E1 E0:		0 1
//				6.0M(I)						E1 E0:		1 0
//				6.5M(D/K,SECAM L,L')			E1 E0:		1 1 
//System Data Format:				B6 	B4 	C7 	C5
//					B/G			0    	1   	1   	1
//					I			0 	1	1	1   
//					D/K			0	1	1	1
//					SECAM L		0	0	0	0
//					SECAM L'		1	0	0	0
#define IF_RESERVED 			0x00
// 1	B6 0 B4 0 1 0 0
// lun hahaha
/////********************************** Negative or Positive  FM TV *******************//////////
//#define IF_SWITCH_1			0x94	//use for B/G, I ,D/K
#define IF_SWITCH_PAL                 0x54 //   0x56         //TVSYSTEM == PAL             //Negative FM TV
#define IF_SWITCH_NTSC               0x54 //   0x16         //TVSYSTEM == NTSC           //Negative FM TV
#define IF_SWITCH_SEACAM_DK      0x54 //   0x46         //TVSYSTEM == SEACAM L    //Negative FM TV
#define IF_SWITCH_SEACAM_L1_DK      0xD4 //   0x46         //TVSYSTEM == SEACAM L'    //Negative FM TV
#define IF_SWITCH_SEACAM_L       0x44 // /  Positive         //TVSYSTEM == SEACAM L    //Positive FM TV
#define IF_SWITCH_SEACAM_L1       0xC4 // /  Positive         //TVSYSTEM == SEACAM L'    //Positive FM TV
#define IF_SWITCH_PAL_M                 0x14 //   0x56         //TVSYSTEM == PAL             //Negative FM TV
#define IF_SWITCH_PAL_N                 0x54 //   0x56         //TVSYSTEM == PAL             //Negative FM TV
/*
#define IF_SWITCH_SEACAM_L       0x54 //   0x46         //TVSYSTEM == SEACAM L    //Negative FM TV
#define IF_SWITCH_SEACAM_L1     0x54//   0xC6         //TVSYSTEM == SEACAM L'    //Negative FM TV
#define IF_SWITCH_SEACAM_POSITIVE     0x44       //secam DK/  Positive 
*/
//#define IF_SWITCH_DEFAUL     IF_SWITCH_PAL
/////********************************** *******************************************************///


/////********************************** *Audio value control******************************************************///
// C7 1 C5 1 0 0 0 0
#define IF_ADJUST_PAL		0x70	//use for Pal
#define IF_ADJUST_NTSC		0x70 //	0x30	//use for Pal
#define IF_ADJUST_SEACAM	0x70 //		0x50	//use for Pal  
//#define IF_ADJUST_SEACAM_L  0x70      
#define IF_ADJUST_DEFAUL    IF_ADJUST_PAL
/////********************************** *******************************************************///


/////********************************** *PIF:38.9m,sound******************************************************///

// 1 0 0 E4 E3 E2 E1 E0
// lun hahaha
#ifdef TUNER_USE_TNJ7355
#define IF_DATA_PAL_BG		 0x09	//use for PAL system, PIF:38.9m,sound:B/G  	
#define IF_DATA_PAL_I		 0x0A	//use for PAL system, PIF:38.9m,sound:I
#define IF_DATA_PAL_DK		 0x0B	//use for PAL system, PIF:38.9m,sound:D/K  
#define IF_DATA_PAL_MN		 0x08	//use for PAL system, PIF:38.9m,sound:M/N  //sound4.5M  //12SEP08
#define IF_DATA_NTSC_MN	 0x08	//use for NTSC system, PIF:38.9m,sound:B/G  	
#define IF_DATA_SEACAM_L	 0x4B	//use for SEACAM_L' system, PIF:38.9m,sound:D/K  6.5 	gating in case of 36% positive modus 		
#define IF_DATA_SEACAM_L_I	        0x0A	//use for SEACAM_L' system, PIF:38.9m,sound:I  6.0M 	
#define IF_DATA_SEACAM_L_BG	0x09 // 0x49	//use for SEACAM_L' system, PIF:38.9m,sound:D/K    5.5M 	
#define IF_DATA_SEACAM_L_MN	 0x4B	//use for SEACAM_L' system, PIF:38.9m,sound:D/K    6.5 	gating in case of 36% positive modus 	
#define IF_DATA_SEACAM_L_DK	 0x0B //0x4B	//use for SEACAM_L' system, PIF:38.9m,sound:D/K  	

#define IF_DATA_SEACAM_L1	   0x53	//use for SEACAM_L' system, PIF:33.9m,sound:D/K 	gating in case of 36% positive modus 	
#define IF_DATA_SEACAM_L1_I	 0x12	//use for SEACAM_L' system, PIF:33.9m,sound:I 	
#define IF_DATA_SEACAM_L1_BG	0x11 // 0x51	//use for SEACAM_L' system, PIF:33.9m,sound:B/G 	
#define IF_DATA_SEACAM_L1_MN	 0x53	//use for SEACAM_L' system, PIF:33.9m,sound:DK+gating in case of 36% positive modus 	
#define IF_DATA_SEACAM_L1_DK	   0x13	//use for SEACAM_L' system, PIF:33.9m,sound:D/K 	

#define IF_DATA_DEFAULT     IF_DATA_PAL_BG 
#else
#define IF_DATA1			0x89	//use for video:  	except SECAM L', sound:B/G  	
//#define IF_DATA2			0x8A	//use for video:	except SECAM L', sound:I 	
#define IF_DATA2			0x8A	//use for video:	except SECAM L', sound:I 	
#define IF_DATA3			0x8B	//use for vodeo:	except SECAM L',sound:D/K,SECAM L,L' 	
#define IF_DATA_DEFAULT     IF_DATA1  //martin 09May08
#endif

#define PIF					PAL_PIF
/////////////*********************************************************************/////////////

#define USCABLE_2_4_BASE		1883		//55.25+ 38.9
#define USCABLE_5_6_BASE		2323		//77.25+ 38.9
#define USCABLE_7_13_BASE   	4283  // (175.25 + 38.9)
#define USCABLE_14_22_BASE  	3203  // (121.25 + 38.9)
#define USCABLE_23_94_BASE  	5123  // (217.25 + 38.9)
#define USCABLE_95_99_BASE  	2603  // (91.25 + 38.9)
#define USCABLE_100_BASE    		13763  // (649.25 + 38.9)

#define USAIR_2_4_BASE			1883		//55.25+ 38.9
#define USAIR_5_6_BASE			2323		//77.25+ 38.9
#define USAIR_7_13_BASE   		4283  // (175.25 + 38.9) 
#define USAIR_14_BASE			10203	//(471.25+38.9)

#define TV_AUTO_SEARCH_MODE	0

//////////////////////////////
extern void vInitTV(void);
extern BYTE bTV_PLL_Read(void);  
extern BYTE bTV_IF_Read(void);
#ifndef TUNER_USE_TNJ7355  //martin 14May08
extern void vTVTunerInit(void);
#endif
extern BOOL vTvSetCh();

extern sChannelList ReadTVChannel(BYTE ChInd);
extern void WriteTVChannel(BYTE ChInd,sChannelList sCh);

extern void LoadTVData(void);
extern void LoadDefaultTVData(void);
extern void vTvSetChannel(sChannelList sCh);
extern void vTVSwitchSound(void);
extern void vTVSearch(BIT dir);

extern void vTVKeyPreProc(BYTE save_key);
extern BYTE vTVKeyState(BYTE save_key);
//extern void vTVTempSetSystem(void);
#endif

⌨️ 快捷键说明

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