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

📄 eeprom_24c02.c

📁 这是一个TDA7540的模版程序
💻 C
字号:
/***************************************************************************
Project  :   TDA7540 Jig board 
Compiler : ST7 HiCross C (HiWARE)
Module   :  eeprom_24C02.c
Version  :  V 1.0
Created  : Jan.24th,2005
Author   :  Jerry HE / ST-ShenZhen
Description
         -  EEPROM read write
Modified
	  -     
***************************************************************************/
#include "system.h"


/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Routine : ReadBoardEEPROM
Input   :  
Output  : 
Description 
        - Read data from Broad EEPROM
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void ReadBoardEEPROM(unsigned char start, unsigned char end , unsigned char *p)
{
	unsigned char i;
	I2Cm_Start();
	I2Cm_TxData (BoardEEP_ADR);
	I2Cm_TxData(start);

	I2Cm_Start();
	I2Cm_TxData (BoardEEP_ADR|0x01);
	for(i=start;i<=end;i++,p++)
	{
		*p=I2Cm_RxData();
		if(i==end)
		  I2Cm_nAck();
		else
		  I2Cm_Ack();
	}
	I2Cm_Stop();
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Routine : WriteBoardEEPROM
Input   :  
Output  : 
Description 
        - write data to board eeprom
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void WriteBoardEEPROM(unsigned char start, unsigned char end, unsigned char *p)
{
	unsigned char i;
	I2Cm_Start();
	I2Cm_TxData(BoardEEP_ADR);
	I2Cm_TxData(start);
	for(i=start;i<=end;i++,p++)
	{
		I2Cm_TxData(*p);
	}
	I2Cm_Stop();
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Routine : ReadTunerEEPROM
Input   :  
Output  : 
Description 
        - Read data from tuner EEPROM
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void ReadTunerEEPROM(unsigned char start, unsigned char end, unsigned char *p)
{
	unsigned char i;
	I2Cm_Start();
	I2Cm_TxData (TunerEEP_ADR);
	I2Cm_TxData(start);

	I2Cm_Start();
	I2Cm_TxData (TunerEEP_ADR|0x01);
	for(i=start;i<=end;i++,p++)
	{
		*p=I2Cm_RxData();
		if(i==end)
		  I2Cm_nAck();
		else
		  I2Cm_Ack();
	}
	I2Cm_Stop();
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Routine : WriteTunerEEPROM
Input   :  
Output  : 
Description 
        - Write data to tuner eeprom
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void WriteTunerEEPROM(unsigned char start, unsigned char end, unsigned char *p)
{
	unsigned char i;
	I2Cm_Start();
	I2Cm_TxData(TunerEEP_ADR);
	I2Cm_TxData(start);
	for(i=start;i<=end;i++,p++)
	{
		I2Cm_TxData(*p);
	}
	I2Cm_Stop();
}

/*+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Routine : TestEEPROM
Input   :  
Output  : 
Description 
        - Test the eeprom and load the reference setting to the tuner/board eeprom
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/

void TestEEPROM()
{
	unsigned char i;
       //Write our ST default value into Board eeprom... only for test usage.
       Eep_validflag = 0x0c;     
       Eep_Year = 0x05;            
       Eep_Month = 0x06;   
       Eep_Date = 25;                  
       Eep_SiliconVer = 0xAE;                 
       Eep_TunerVer = 0x02;                 
       Eep_GUIVer = 0x24;                  
       Eep_MCUsoftVer =0x11;            
       Eep_Reserved1 = 0x00;      
       Eep_Reserved2 = 0x00;   
       
       Eep_pll_cpump = y10010001;        
       Eep_pll_pcl = y10001100;   
       Eep_pll_pch = y00000111;                 
       Eep_tun_tunvolt1 = y00000000;            
       Eep_tun_tunvolt2 = y01001000;            
       Eep_pll_sampletime = y00010111;         
       Eep_pll_ewcentre = y01101111;            
       Eep_tun_amcontrol = y00000000;          
       Eep_tun_qualityiss = y01100000;          
       Eep_tun_qualdetAdj = y11001000;          
       Eep_tun_qualdetMul = y00100000;          
       Eep_tun_qualdetDev = y00000101;           
       Eep_tun_softmute = y11111000;            
       Eep_tun_adjmute = y11111001;            
       Eep_tun_vcoplldiv = y00100101;          
       Eep_tun_fmagc = y01001111;               
       Eep_tun_amagc = y00000000;               
       Eep_tun_fmdem = y10000001;               
       Eep_tun_smeter = y11100000;             
       Eep_tun_ifgainXtal = y10101111;          
       Eep_tun_ift1ift2 = y10001101;           
       Eep_tun_IQmixer = y11001111;            
       Eep_tun_amifNB = y00000000;              
       Eep_tun_sstop = y10000000;               
       Eep_str_amnoise = y11100111;             
       Eep_str_stringain = y00011100;           
       Eep_str_nb = y00100000;                   
       Eep_str_HiCut = y11101011;                
       Eep_str_blend = y11100101;              
       Eep_str_multipath = y01001011;           
       Eep_str_rolloff = y10000001;             
       Eep_str_afs = y11111101;                 
       Eep_str_amcornerfreq = y00000100;         
       Eep_test1 = 0x00;                    
       Eep_test2 = 0x00;                   
       Eep_test3  = 0x00;                 
       Eep_test4  = 0x00;                  
       Eep_test5  = 0x00;                 
       Eep_test6  = 0xFE;                  
       Eep_str_spike = y11111110;               

       Eep_TV2_Point1 = y01001000;         
       Eep_TV2_Point2  = y01001000;             
       Eep_TV2_Point3 = y01001000;              
       Eep_TV2_Point4  = y01001000;             
       Eep_TV2_Point5 = y01001000;        
       Eep_TV2_Point6  = y01001000;  

#if INIT_BOARD_EEPROM
	WriteBoardEEPROM(0, 7, &I2c_EepBuff[0]);
	WAIT_10ms();
	WriteBoardEEPROM(8,15, &I2c_EepBuff[8]);
       WAIT_10ms();
	WriteBoardEEPROM(16, 23, &I2c_EepBuff[16]);
	WAIT_10ms();
	WriteBoardEEPROM(24,31, &I2c_EepBuff[24]);
	WAIT_10ms();
	WriteBoardEEPROM(32, 39, &I2c_EepBuff[32]);
	WAIT_10ms();
	WriteBoardEEPROM(40,47, &I2c_EepBuff[40]);
	WAIT_10ms();
	WriteBoardEEPROM(48, 55, &I2c_EepBuff[48]);

//    Test if write is OK / not?
       for(i=0;i<56;i++)
	   I2c_EepBuff[i] = 0;
	   
 	ReadBoardEEPROM(0, 7, &I2c_EepBuff[0]);
	WAIT_10ms();
	ReadBoardEEPROM(8,15, &I2c_EepBuff[8]);
	WAIT_10ms();
	ReadBoardEEPROM(16, 23, &I2c_EepBuff[16]);
	WAIT_10ms();
	ReadBoardEEPROM(24,31, &I2c_EepBuff[24]);
	WAIT_10ms();
	ReadBoardEEPROM(32, 39, &I2c_EepBuff[32]);
	WAIT_10ms();
	ReadBoardEEPROM(40,47, &I2c_EepBuff[40]);
	WAIT_10ms();
	ReadBoardEEPROM(48, 55, &I2c_EepBuff[48]);
#endif   

#if INIT_TUNER_EEPROM
	WriteTunerEEPROM(0, 7, &I2c_EepBuff[0]);
	WAIT_10ms();
	WriteTunerEEPROM(8,15, &I2c_EepBuff[8]);
       WAIT_10ms();
	WriteTunerEEPROM(16, 23, &I2c_EepBuff[16]);
	WAIT_10ms();
	WriteTunerEEPROM(24,31, &I2c_EepBuff[24]);
	WAIT_10ms();
	WriteTunerEEPROM(32, 39, &I2c_EepBuff[32]);
	WAIT_10ms();
	WriteTunerEEPROM(40,47, &I2c_EepBuff[40]);
	WAIT_10ms();
	WriteTunerEEPROM(48, 55, &I2c_EepBuff[48]);


//    Test if write is OK / not?
       for(i=0;i<56;i++)
	   I2c_EepBuff[i] = 0;
	   
 	ReadTunerEEPROM(0, 7, &I2c_EepBuff[0]);
	WAIT_10ms();
	ReadTunerEEPROM(8,15, &I2c_EepBuff[8]);
	WAIT_10ms();
	ReadTunerEEPROM(16, 23, &I2c_EepBuff[16]);
	WAIT_10ms();
	ReadTunerEEPROM(24,31, &I2c_EepBuff[24]);
	WAIT_10ms();
	ReadTunerEEPROM(32, 39, &I2c_EepBuff[32]);
	WAIT_10ms();
	ReadTunerEEPROM(40,47, &I2c_EepBuff[40]);
	WAIT_10ms();
	ReadTunerEEPROM(48, 55, &I2c_EepBuff[48]);
#endif   	

}
/*** (c) 2005  STMicroelectronics ****************** END OF FILE ***/

⌨️ 快捷键说明

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