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

📄 radio.h

📁 一个ST7系列的车载dvd系统源代码
💻 H
字号:
/*********************************************************
	Project:		ST FST(TDA7540)
	File name:	radio.h
	Description:	
	Write/Modify:	Perry Liang
	Time:		2006-1-24- 15:35:43
*********************************************************/
extern void RadioInit(void);
extern void RadioOn(void);
extern void RadioOff(void);
extern void RadioMain(void);
extern void RadioSeek(void);
extern void RadioSetFreq(unsigned int setfreq);
extern void RadioTunerSend(unsigned char start, unsigned char end);
extern void RadioTunerRead(void);
extern void RadioKey(void);
extern void RadioWork(void);
extern unsigned int  RadioFreqCal(unsigned char step);
extern void Radio10msTimer(void);
extern void Radio100msTimer(void);
extern void RadioDisplay(void);
extern void RadioSave(unsigned char pos);
extern void RadioLoad(unsigned char pos);
extern void SeekOn(void);
extern void SeekOff(void);
extern void RadioMute(unsigned char type);
extern void PresetOrder(void);
extern signed char ChangeTV2(unsigned char inputbuff);
extern unsigned char ChangeToTV2(signed char inputbuff);
extern unsigned char GetTV2(unsigned int inputfreq);
unsigned char GetSMeter (void);
unsigned char CheckIFC(unsigned int times,unsigned int all);
unsigned char Radio_PLL_FMISet(unsigned int FMfreq);
unsigned char Radio_PLL_AMISet(unsigned int AMfreq);


#define Pin_AFS		PIN17
#define PD_AFS		PINDDR17
#define PO_AFS		PINOR17

#define Pin_SWFLAG		PIN20
#define PD_SWFLAG		PINDDR20
#define PO_SWFLAG		PINOR20

#define Pin_SSTOP		PIN19
#define PD_SSTOP		PINDDR19
#define PO_SSTOP		PINOR19

#define AD_FSU			AIN16
#define AD_QUAL			AIN18
#define AD_ADJCH		AIN15
#define AD_AMSTMP		AIN14

typedef struct Band_stuct {
	unsigned int BandFreq;
	unsigned int MemFreq[6];
	unsigned char MemSmeter[6];
	unsigned int PI[6];
	unsigned char MemAFList[6][8];
	unsigned char MemAFNum[6];
	unsigned char CurrentMem;
} BandStuct;

typedef struct Radio_stuct {
	unsigned char SeekMode;
	unsigned char WorkMode;
	unsigned char CurrentBand;
	unsigned int ReqFreq;
	unsigned int Freq;
	unsigned int BackupFreq;
	unsigned char TunerBuff[40];
	UCharField ReadBuff;
	unsigned int TestPointFreq;
	signed char TestPointVal;
	signed int Slope;
	signed int Slope2;
	
	//unsigned char TunerBuff[10];
	//unsigned char PllBuff[10];
	BandStuct Band[5];

	unsigned int MaxFreq;
	unsigned int MinFreq;
	unsigned char Step;
	unsigned char SeekStep;
	unsigned char Area;
	signed char Direction;

	unsigned char Smeter;
	
	unsigned F_ForceSetBuff:1;
	unsigned F_GoodStation:1;
	unsigned F_TunerDispReq:1;
	unsigned F_ManualSeek:1;
	unsigned F_LocDx:1;
} RadioStuct;

ext RadioStuct Radio;
ext unsigned char RadioWaitTimer;
ext unsigned char RadioWorkTimer10ms;
ext unsigned char RadioWorkTimer;

/*typedef struct Preset_stuct {
	unsigned int Freq;
	unsigned char Smeter;
} PresetStuct;

ext PresetStuct TempPreset[6];*/
ext unsigned char TempPresetNum;
ext unsigned char TempPresetSMMin;
ext unsigned char TempPresetSMMinNum;

ext unsigned char SaveSmeterSlider;

ext unsigned char SeekKeyTimer;

#define F_TunerISSON				Radio.ReadBuff.field.B0
#define F_TunerISS80kHz				Radio.ReadBuff.field.B1
#define F_TunerStereo				Radio.ReadBuff.field.B2
#define F_TunerPLLLock				Radio.ReadBuff.field.B3
#define F_TunerFieldStrengthLow		Radio.ReadBuff.field.B4
#define F_TunerAdjacentChannel		Radio.ReadBuff.field.B5
#define F_TunerDeviationStrong		Radio.ReadBuff.field.B6
#define F_TunerDeviation				Radio.ReadBuff.field.B7

#define RADIO_SEEK_IDLE				0
#define RADIO_SEEK_INIT				1
#define RADIO_SEEK_CHANGE_FRE		2
#define RADIO_SEEK_AMFSU_WAIT	3
#define RADIO_SEEK_WAIT			4
#define RADIO_SEEK_CHECK			5
#define RADIO_SEEK_GOOD_STATION	6
#define RADIO_SEEK_BAD_STATION	7

#define RADIO_WORK_IDLE			0
#define RADIO_WORK_SEEKMODE		0x10
#define RADIO_WORK_SEEKREQ		0x11
#define RADIO_WORK_SEEKWAIT		0x12
#define RADIO_WORK_SEEKOK			0x13
#define RADIO_WORK_SEEKBREAK		0x14
#define RADIO_WORK_SEEKNEXT		0x15
#define RADIO_WORK_SEEKWAITRDS	0x16
#define RADIO_WORK_SEEKWAITPI		0x17
#define RADIO_WORK_SEEKWAITTP	0x18
#define RADIO_WORK_SEEKWAITPTY	0x19

#define RADIO_WORK_ASPSMODE		0x20
#define RADIO_WORK_PSREQ			0x21
#define RADIO_WORK_PSWAIT			0x22
#define RADIO_WORK_PSEND			0x23
#define RADIO_WORK_ASPSBREAK		0x24
#define RADIO_WORK_ASREQ			0x25
#define RADIO_WORK_ASWAIT			0x26
#define RADIO_WORK_ASEND			0x27
#define RADIO_WORK_ASNEXT			0x28
#define RADIO_WORK_ASWAITRDS		0x29
#define RADIO_WORK_ASWAITPI		0x2A
#define RADIO_WORK_ASWAITAFLIST	0x2B

//#define RADIO_IN_SEARCH			(Radio.WorkMode==RADIO_WORK_ASWAIT ||Radio.WorkMode==RADIO_WORK_SEEKWAIT ||Radio.WorkMode==RADIO_WORK_SEEKNEXT ||Radio.WorkMode==RADIO_WORK_SEEKWAITRDS ||Radio.WorkMode==RADIO_WORK_SEEKWAITPI)
#define RADIO_IN_SEEK				((Radio.WorkMode>>4)==1)
#define RADIO_IN_AS					(Radio.WorkMode>0x25)
#define RADIO_IN_PS					((Radio.WorkMode>0x20)&&(Radio.WorkMode<0x24))
#define RADIO_IN_SEARCH			(RADIO_IN_SEEK||RADIO_IN_AS)


#define AREA_USA			0
#define AREA_LATIN			1
#define AREA_EUROPE		2
#define AREA_OIRT			3

#define LW_FREQ						300
#define AM_FREQ						2000
#define FM_FREQ						2000
#define FM_NORMAL_START_FREQ		8000
#define FM_OIRT_START_FREQ			6000
#define FreqInFM(x)					(x>AM_FREQ)
#define FreqInAM(x)					(x<FM_FREQ)
#define FreqInNormalFM(x)			(x>FM_NORMAL_START_FREQ)
#define FreqInOirtFM(x)				(x>FM_OIRT_START_FREQ && x<FM_NORMAL_START_FREQ)
#define FreqInMWAM(x)				(x>LW_FREQ && x<FM_FREQ)
#define FreqInLWAM(x)				(x<LW_FREQ)

#define TunerEepromAddress			0xA0
#define BoardEepromAddress			0xA2
ext unsigned char TunerEepromBuff[72];
ext unsigned char BoardEepromBuff[72];
ext unsigned char EepromBuff[50];
ext unsigned char OtherPointBuff[7];

#ifdef	DEBUGRADIO
ext unsigned char DebugBuffNum;
ext unsigned char DebugBuffPos;
#endif

//====================================================//
//================ FST register bit define======================//
//====================================================//
//For PLL current Tun_Buff[0]
//Bit3~0
#define PLL_HICURRENT_0MA       			0x00
#define PLL_HICURRENT_0_5mA     		0x01
#define PLL_HICURRENT_1MA       			0x02
#define PLL_HICURRENT_1_5mA     		0x03
#define PLL_HICURRENT_2MA       			0x04
#define PLL_HICURRENT_2_5mA     		0x05
#define PLL_HICURRENT_3MA       			0x06
#define PLL_HICURRENT_3_5mA     		0x07
#define PLL_HICURRENT_4MA       			0x08
#define PLL_HICURRENT_4_5mA     		0x09
#define PLL_HICURRENT_5MA       			0x0A
#define PLL_HICURRENT_5_5mA     		0x0B
#define PLL_HICURRENT_6MA       			0x0C
#define PLL_HICURRENT_6_5mA     		0x0D
#define PLL_HICURRENT_7MA       			0x0E
#define PLL_HICURRENT_7_5mA     		0x0F
//Bit 5~4
#define PLL_LOWCURRENT_0uA      			0x00
#define PLL_LOWCURRENT_50uA     		0x10
#define PLL_LOWCURRENT_100uA    		0x20
#define PLL_LOWCURRENT_150uA    		0x30
//Bit6
#define PLL_LOWCURRENT_MODE     		0x00
#define PLL_HIGHCURRENT_MODE    		0x40
//Bit7
#define PLL_FMSEEK_ON           			0x00
#define PLL_FMSEEK_OFF          			0x80

//Sample time and IFC   Tun_Buff[5]
#define PLL_TSAMPLE_FM20_48_AM128	0x00
#define PLL_TSAMPLE_FM10_24_AM64    	0x01
#define PLL_TSAMPLE_FM5_12_AM32      	0x02
#define PLL_TSAMPLE_FM2_56_AM16      	0x03
#define PLL_TSAMPLE_FM1_28_AM8        	0x04
#define PLL_TSAMPLE_FM0_64_AM4        	0x05
#define PLL_TSAMPLE_FM0_32_AM2        	0x06
#define PLL_TSAMPLE_FM0_16_AM1        	0x07

#define PLL_IFC_DISABLE                       	0x00
#define PLL_IFC_ENABLE                        	0x08

#define PLL_IFC_FMMODE                    		0x10
#define PLL_IFC_AM450K                         	0x20
#define PLL_IFC_AM10_7M                      	0x30

#define DISABLE_MUTEONHOLD               	0x00
#define ENABLE_MUTEONHOLD                	0x40

#define PLL_LOCK_DISABLE                    	0x00
#define PLL_LOCK_ENABLE                     		0x80

//center freqency and delta window   Tun_Buff[5]
#define PLL_IFC_CENTER_10_7MHZ     		0x0F
#define PLL_IFC_CENTER_450KHZ      		0x01

#define PLL_IFC_EW_FM6_25_AM1K     		0x60
#define PLL_IFC_EW_FM12_5_AM2K     		0x80
#define PLL_IFC_EW_FM25_AM4K       		0xA0
#define PLL_IFC_EW_FM50_AM8K       		0xC0
#define PLL_IFC_EW_FM100_AM16K     		0xE0


//For reference freqency
#define PLL_REFERECE_50KHz      			0x20     
#define PLL_REFERECE_25KHz      			0x28
#define PLL_REFERECE_10KHz      			0x30
#define PLL_REFERECE_9KHz       			0x38
#define PLL_REFERECE_2KHz       			0x00

//For SD threshold
#define SSTOP_IFC                      			0x00
#define SSTOP_IFC_0_89V          			0x10    // IFC=H & FSU>0.89V
#define SSTOP_IFC_1_16V           			0x20    // IFC=H & FSU>1.16V
#define SSTOP_IFC_1_43V           			0x30    // IFC=H & FSU>1.43V
#define SSTOP_IFC_1_7V             			0x40    // IFC=H & FSU>1.7V
#define SSTOP_IFC_1_97V           			0x50
#define SSTOP_IFC_2_24V           			0x60
#define SSTOP_IFC_2_51V           			0x70
#define SSTOP_IFC_2_78V           			0x80
#define SSTOP_IFC_3_05V           			0x90
#define SSTOP_IFC_3_32V           			0xA0
#define SSTOP_IFC_3_59V           			0xB0
#define SSTOP_IFC_3_86V           			0xC0
#define SSTOP_IFC_4_13V           			0xD0
#define SSTOP_IFC_4_40V           			0xE0
#define SSTOP_IFC_4_67V           			0xF0

//====================================================//
//=================== frequency  define======================//
//====================================================//
//FM frequency define
#define FM80_0MHZ         					8000  
#define FM83_0MHZ         					8300
#define FM87_0MHZ         					8700
#define FM106_1MHZ						10610	// FM 106.1MHz
#define FM93_3MHZ						9330	// FM 93.3MHz
#define FM94_5MHZ						9450
#define FM98_6MHZ						9860
#define FM106_9MHZ						10690
#define FM98_1MHZ						9810
#define FM70_1MHZ           				7010
#define FM87_5MHZ						8750
#define FM89_5MHz           				8950
#define FM92_7MHz           				9270
#define FM96_1MHz           				9610
#define FM99_6MHz           				9960
#define FM103_1MHz         				10310
#define FM106_5MHz         				10650
#define FM108MHZ						10800
//ORIT
#define FM65_0MHZ						6500
#define FM67_0MHZ           				6700
#define FM71_0MHZ           				7100
#define FM74_0MHZ           				7400
//AM
#define AM900KHZ						900 
#define AM720KHZ             				720
#define AM999KHZ						999
#define AM1404KHZ           				1404
/*********************************************************
				File End
*********************************************************/

⌨️ 快捷键说明

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