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

📄 lc72130.h

📁 lc72130.收音机软件 #include "saa6588.c" #include "ba1924.c"
💻 H
字号:
/* //file: lc72130.h
	Date: 2005.12.14  
	Author: Ipman Robbin
	Desp: pll控制LA1787 收音芯片
*/
#ifndef LC72130_H
#define LC72130_H

#define UP					1
#define DOWN				0			//选台方向

#define FM					0
#define AM					1//RA_BAND

#define IO_IN				0			//IO方向
#define IO_OUT				1

#define OPEN				0			//IO状态
#define LOW					1			//IO状态

//以下定义参考LC72130手册
//SPI address
#define LC72130_IN1			0x28		//模式1数据地址
#define LC72130_IN2			0x29		//模式2数据地址
#define LC72130_OUT			0x2A		//接收模式数据地址

//#define FM_GT_MEASURE		4			//此处定义中频测量时间,时间越大,搜索需要花费的时间越多

#define FM_GT_MEASURE		8

//#define FM_GT_MEASURE		64
//DOC Set
#define DOC_OPEN			0			//OPEN
#define DOC_UNLOCK_LOW		1			//Low when the unlock state is detected
#define DOC_END_UC			2			//
#define DOC_IO1_OPEN		5			//::Goes to the open state if the I/O pin is 
#define DCO_IO2_OPEN		6			//::specified to be an output port.
//锁相搜索宽度设置
#define BIT_UL				4
#define UL_OPEN				0
#define UL_DIRECTLY			1
#define UL_55US				2
#define UL_111US			3
//死区设置
#define DZA					0			//Controls the phase comparator dead zone.死区控制
#define DZB					1
#define DZC					2
#define DZD					3			//Dead zone widths: DZA < DZB < DZC < DZD
//中频计数周期
#define GT_4MS				0
#define GT_8MS				1
#define GT_32MS				2
#define GT_64MS				3			//确定中频计数测量时间.

//输入选择
#define FMIN				2			//FM 10-160M
#define AMIN1				1			//AM 2-40M
#define AMIN2				1			//AM 0.5-10M
//晶振频率
#define XS4_5M				0			//xtal=4.5M
#define XS7_2M				1			//xtal=7.2M
//中频计数
#define CTE_START			1			//CTE = 1: Counter start
#define CTE_RESET			0			//CTE = 0: Counter reset
//自动搜索布进频率参考,单位是K
#define STEP100000			0	//100k
#define STEP50000			1	//50k
#define STEP25000			3	//25k
#define STEP12500			4	//12.5k
#define STEP6250			5	//6.25k
#define STEP3125			6	//3.125k
#define STEP10000			8	//10K
#define STEP9000			9	//9K
#define STEP5000			10
#define STEP1000			11
#define STEP3000			12
#define STEP15000			13
#define STEP_INHIBIT_XS		14
#define STEP_INHIBIT		15
//DLC
#define DLC_NORMAL			0
#define DLC_FORCE_LOW		1


//以下定义为自定义默认参数,修改前需仔细阅读72130手册

#define ON					1
#define OFF					0

#define FM_IF_FREQ			1070
#define FM_IF_FREQ2			10710
#define AM_IF_FREQ			450
#if FM_GT_MEASURE==4
	#define FM_IF_CENTER	42800							// 10700*GTMS
#endif
#if FM_GT_MEASURE==8
	#define FM_IF_CENTER	85600							// 10700*GTMS
#endif
#if FM_GT_MEASURE==32
	#define FM_IF_CENTER	342400							// 10700*GTMS
#endif

#if FM_GT_MEASURE==64
	#define FM_IF_CENTER	684800							// 10700*GTMS
#endif
#define AM_GTMS				32			//本方案采用32ms
#ifdef LA1844
#define FM_ERROR			20//20
#define FM_ERROR2			30
#else
#define FM_ERROR			20
#endif
#define AM_ERROR			7

#if defined(LCD_393)
	#if FM_GT_MEASURE==4
		#define CTE_DELAY_LOOPS		700		//中频计数等待时间
		#define CTE_RESET_LOOPS		200		//中频复位等待时间
	#endif
	#if FM_GT_MEASURE==8
#ifdef LA1844
		#define CTE_DELAY_LOOPS		1200//1000//2000//800			//中频计数等待时间 11.11 Modify
		#define CTE_RESET_LOOPS_NORDS	1300//2400//1200	//TF Tunner OK
		#define CTE_RESET_LOOPS		1000//800//800//1600//800			//中频复位等待时间 11.11 Modify
#else
		#define CTE_DELAY_LOOPS		800			//中频计数等待时间 11.11 Modify
		#define CTE_RESET_LOOPS_NORDS	1200	//TF Tunner OK
		#define CTE_RESET_LOOPS		800			//中频复位等待时间 11.11 Modify
#endif
	#endif
	#if FM_GT_MEASURE==32
		#define CTE_DELAY_LOOPS			1200		//中频计数等待时间
		#define CTE_RESET_LOOPS_NORDS	1200	//TF Tunner OK
		#define CTE_RESET_LOOPS			600		//中频复位等待时间
	#endif
	#define AM_CTE_DELAY_LOOPS		1200
#ifdef CE6000
	#define AM_CTE_RESET_LOOPS		2000
#else
	#define AM_CTE_RESET_LOOPS		600
#endif

#else	//NOT 393
//#define CTE_DELAY_LOOPS		1200		//中频计数等待时间
//#define CTE_RESET_LOOPS		600		//中频复位等待时间
	#if FM_GT_MEASURE==4
		#define CTE_DELAY_LOOPS		700		//中频计数等待时间
		#define CTE_RESET_LOOPS		200		//中频复位等待时间
	#endif
	#if FM_GT_MEASURE==8
#ifdef TURBINE_AD
#ifdef LA1844
		#define CTE_DELAY_LOOPS		2000//800			//中频计数等待时间 11.11 Modify
		#define CTE_RESET_LOOPS_NORDS	2400//1200	//TF Tunner OK
		#define CTE_RESET_LOOPS		1600//800			//中频复位等待时间 11.11 Modify
#else
		#define CTE_DELAY_LOOPS		400		//中频计数等待时间
		#define CTE_RESET_LOOPS_NORDS	400	//TF Tunner OK
		#define CTE_RESET_LOOPS		1400
#endif
#else
			//#define CTE_RESET_LOOPS_NORDS	800		//Protec Tunner OK
		//中频复位等待时间 ORIT 泰丰高频头时间稍长
		#define CTE_DELAY_LOOPS		1200		//中频计数等待时间
		#define CTE_RESET_LOOPS_NORDS	1200	//TF Tunner OK
		#define CTE_RESET_LOOPS		1200		//Protec OK 11.11
#endif


	#endif
	#if FM_GT_MEASURE==32
		#define CTE_DELAY_LOOPS			1400		//中频计数等待时间
		#define CTE_RESET_LOOPS_NORDS	1200		//1200	//TF Tunner OK
		#define CTE_RESET_LOOPS			1000		//1000中频复位等待时间
	#endif
	//#define AM_CTE_DELAY_LOOPS			1200
	#define AM_CTE_RESET_LOOPS			2000
#endif
//ori 40
#define FM_IF_CNT_MAX	(FM_IF_CENTER+FM_ERROR*FM_GT_MEASURE)		//最大取值 +15Khz (10700+16)*GT_MEASURE Dec 42864  42890(test)
#define FM_IF_CNT_MIN	(FM_IF_CENTER-FM_ERROR*FM_GT_MEASURE)		// (10700-16)*GT_MEASURE	//最小取值 -15Khz  Dec  42736 42710(test)
#define FM_IF_CNT_MAX1844	(FM_IF_CENTER+FM_ERROR2*FM_GT_MEASURE)		//最大取值 +15Khz (10700+16)*GT_MEASURE Dec 42864  42890(test)
#define FM_IF_CNT_MIN1844	(FM_IF_CENTER-FM_ERROR2*FM_GT_MEASURE)		// (10700-16)*GT_MEASURE	//最小取值 -15Khz  Dec  42736 42710(test)


#define FM_IF_CNT_MAX_3 (((LONG)FM_IF_CNT_MAX>>24)&0xFF)
#define FM_IF_CNT_MAX_2 (((LONG)FM_IF_CNT_MAX>>16)&0xFF)
#define FM_IF_CNT_MAX_1 ((LONG)(FM_IF_CNT_MAX>>8)&0xFF)
#define FM_IF_CNT_MAX_0 ((LONG)(FM_IF_CNT_MAX)&0xFF)

#define FM_IF_CNT_MIN_3 (((LONG)FM_IF_CNT_MIN>>24)&0xFF)
#define FM_IF_CNT_MIN_2 (((LONG)FM_IF_CNT_MIN>>16)&0xFF)
#define FM_IF_CNT_MIN_1 ((LONG)(FM_IF_CNT_MIN>>8)&0xFF)
#define FM_IF_CNT_MIN_0 ((LONG)(FM_IF_CNT_MIN)&0xFF)

#define FM_IF_CNT_MAX_6000	(FM_IF_CENTER+FM_ERROR*FM_GT_MEASURE)		//最大取值 +15Khz (10700+16)*GT_MEASURE Dec 42864  42890(test)
#define FM_IF_CNT_MIN_6000	(FM_IF_CENTER-FM_ERROR*FM_GT_MEASURE)		// (10700-16)*GT_MEASURE	//最小取值 -15Khz  Dec  42736 42710(test)

#define FM_IF_CNT_MAX_ORIT	(FM_IF_CENTER+7*FM_GT_MEASURE)		//最大取值 +15Khz (10700+16)*GT_MEASURE Dec 42864  42890(test)
#define FM_IF_CNT_MIN_ORIT	(FM_IF_CENTER-7*FM_GT_MEASURE)		// (10700-16)*GT_MEASURE	//最小取值 -15Khz  Dec  42736 42710(test)

#define AM_IF_CENTER	(450*AM_GTMS)
#ifdef CE6000
#define AM_IF_CNT_MAX	(AM_IF_CENTER+4*AM_GTMS)		//(450+3)*AM_GTMS		// AM  +2Khz 3616
#define AM_IF_CNT_MIN	(AM_IF_CENTER-4*AM_GTMS)		//(450-3)*AM_GTMS		// AM  -2Khz 3584
#else
#define AM_IF_CNT_MAX	(AM_IF_CENTER+2*AM_GTMS)		//(450+3)*AM_GTMS		// AM  +2Khz 3616
#define AM_IF_CNT_MIN	(AM_IF_CENTER-2*AM_GTMS)		//(450-3)*AM_GTMS		// AM  -2Khz 3584
#endif

#define AM_IF_CNT_MAX_DOWN	(AM_IF_CENTER+48)		//(450+3)*AM_GTMS		// AM  +2Khz 3616
#define AM_IF_CNT_MIN_DOWN	(AM_IF_CENTER-48)		//(450-3)*AM_GTMS		// AM  -2Khz 3584

#ifdef _MB653_
#define IO_ST			0x80
#endif

#ifdef _MB633_
#define IO_ST			0x80
#endif
#define IO_USB			0x40
/*
typedef struct {
	//UINT16 l16;
	unsigned char h08_2;
	unsigned char h08_1;
	unsigned char h08_0;
}u24;//定义一个24位新变量类型
*/
typedef union _IN1
{
	unsigned char byte[3];
	struct _in1
    {
		UINT16 FRQ		:16; //16位电台频率数值
		unsigned char SNS		:1;	 //SNS:DVS 输入频率范围选择			01
		unsigned char DVS       :1;
		unsigned char CTE		:1;	 //CTE 中频计数控制  1:START 0:REST	1
		unsigned char XS		:1;	 //XS: 0=4.5M   1=7.2M				0
		unsigned char XSREF		:4;	 //4位参考频率选择					0011
    }B;
}IN1;
#ifdef _MB653_
typedef union _IN2
{
	//u24 value;
	unsigned char byte[3];
	struct _in2
    {
		unsigned char IOC1		:1;	//控制管脚IO1的方向,0=输入,1=输出 0
		unsigned char IOC2		:1;	//控制管脚IO2的方向,0=输入,1=输出 0
		unsigned char IO1		:1;	//IO1  本方案没用					0
		unsigned char IO2		:1;	//IO2  本方案没用					0 (0)
		unsigned char SNC		:1;	//FM噪音控制  B01					1
		unsigned char FMB		:1;	//FM-B+		  B02					1
		unsigned char STRQ		:1; //ST/RQ 5V=搜索 0V=接收  B03		0
		unsigned char LOC		:1; //FM-LO/DX AGC	B04					1 (B)
		unsigned char AMB		:1;	//AM-B+								0
		unsigned char DOC		:3;	//设置输出数据端DO脚的辅助功能设置	1
									//010时将指示中频测量的完成状况		0
									//									0 (2)
		unsigned char UL		:2;	//锁相环控制电压输出驱动模式设01时	0
									//为直接输出模式(一般采用此种模式)1 UL_55US
		unsigned char DZ		:2;	//锁相环死区控制,不是很重要。		0
									//									0 (2)
		unsigned char GT		:2;	//中频测量时间设置最大64MS最小4MS当GT=00时,
						//前两中等待时间3-4MS后两中等待时间为7-8MS,
						//中频信号必须在等待时间结束之前输入!!
		unsigned char TBC		:1;	//设置为1时使B01口输出8HZ的基准脉冲,此时B01口将不能作为通用输出口。
		unsigned char DLC		:1;	//电荷泵输出,正常状态为0,设置为1时拉低电位。
		unsigned char IFS		:1;	//中频计数器控制,一般设置为1,主要设置中频场强(1:40毫伏0:70毫伏)
		unsigned char TEST		:3; //测试模式一般全部设置为0
    }B;
}IN2;
#elif defined(_MB633_)||defined(_MB655_)
typedef union _IN2
{
	//u24 value;
	unsigned char byte[3];
	struct _in2
    {
		unsigned char IOC1		:1;	//控制管脚IO1的方向,0=输入,1=输出 0
		unsigned char IOC2		:1;	//控制管脚IO2的方向,0=输入,1=输出 0
		unsigned char LOC		:1;	//IO1  本方案没用					0//电路修改,IO1用来控制FM LOC//sheldon 07-07-06
		unsigned char IO2		:1;	//IO2  本方案没用					0 (0)
		unsigned char SNC		:1;	//FM噪音控制  B01					1
		unsigned char FMB		:1;	//FM-B+		  B02					1
		unsigned char STRQ		:1; //ST/RQ 5V=搜索 0V=接收  B03		0
		unsigned char AMB		:1; //FM-LO/DX AGC	B04					1 (B)//电路修改//sheldon 07-07-06
		unsigned char B05		:1;	//AM-B+								0
		unsigned char DOC		:3;	//设置输出数据端DO脚的辅助功能设置	1
									//010时将指示中频测量的完成状况		0
									//									0 (2)
		unsigned char UL		:2;	//锁相环控制电压输出驱动模式设01时	0
									//为直接输出模式(一般采用此种模式)1 UL_55US
		unsigned char DZ		:2;	//锁相环死区控制,不是很重要。		0
									//									0 (2)
		unsigned char GT		:2;	//中频测量时间设置最大64MS最小4MS当GT=00时,
						//前两中等待时间3-4MS后两中等待时间为7-8MS,
						//中频信号必须在等待时间结束之前输入!!
		unsigned char TBC		:1;	//设置为1时使B01口输出8HZ的基准脉冲,此时B01口将不能作为通用输出口。
		unsigned char DLC		:1;	//电荷泵输出,正常状态为0,设置为1时拉低电位。
		unsigned char IFS		:1;	//中频计数器控制,一般设置为1,主要设置中频场强(1:40毫伏0:70毫伏)
		unsigned char TEST		:3; //测试模式一般全部设置为0
    }B;
}IN2;
#endif
void radio_init_AM(void);
void radio_init_FM(void);
void radio_set_band(char band); //设置波段 FM/AM
UINT16 val2Freq(char band,UINT16 freq);
UINT16 radio_freq_to_pll_val(char band,UINT16 value,unsigned char step);
signed char pll_is_station(char band,UINT16 freq);
void radio_save_last_station(BYTE subBand,UINT16 freq);
void pll_set_station(char band,UINT16 freq);
void pll_reset_CTE(char band,UINT16 freq);
void radio_set_loc(BYTE mode);
void setST(char mode);
BYTE isStereo(void);
void radio_close(void);
void radio_sel_st(void);
#endif

⌨️ 快捷键说明

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