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

📄 msp34x5g_test.c

📁 sigma_designs的tuner驱动
💻 C
📖 第 1 页 / 共 3 页
字号:
/********************************************************************** * test.c * msp34x5g api test program * * Copyright (C) 2004 Sigma Designs, Inc. * * $Log: msp34x5g_test.c,v $ * Revision 1.2  2006/01/22 00:32:26  bertrand * Ported contents of set_tron from dcc_2_branch to HEAD * * Revision 1.1.1.1.2.4  2005/06/23 11:23:15  michon * fixbuild * * Revision 1.1.1.1.2.2  2005/03/15 07:38:49  bertrand * Code does not depend on an existing set_rua_test directory (or symbolic * link thereof) at the parent of set_dtv anymore * * Revision 1.1.1.1.2.1  2005/03/15 06:35:16  bertrand * Added missing standard header * * Revision 1.1.1.1  2005/03/10 00:06:00  bertrand * Initial import of the DTV specific code into the ndc repository * * Revision 1.5  2005/01/12 00:37:02  jpong * 760e2 correct configuration.  The audio path is completely changed. * * Revision 1.4  2005/01/12 00:05:41  jpong * version number * * Revision 1.3  2005/01/12 00:05:03  jpong * short patch for 760e2 * * Revision 1.2  2004/12/04 02:39:32  jpong * uart gpio functionality added to helper * * Revision 1.1.1.1  2004/11/10 03:02:41  jpong * i2c devices * * Revision 1.16  2004/10/29 04:21:40  jpong * dk modes, fm prescale IMPORTANT change * * Revision 1.15  2004/09/23 21:26:38  jpong * 781e1 32bit default * * Revision 1.14  2004/09/03 01:30:23  jpong * added D_CTR_IO_X functionality (GPIO) * * Revision 1.13  2004/07/21 01:38:30  jpong * more minor msg changes * * Revision 1.11  2004/07/16 00:04:32  jpong * gpio set for the 760e1 board SEL_DIG pin * * Revision 1.10  2004/07/15 02:23:00  jpong * changed names due to scart1 (out)  and scart dsp (in) * * Revision 1.8  2004/07/08 00:57:42  jpong * sap poll example, bug fixes * * Revision 1.7  2004/07/07 02:56:41  jpong * put in interactive mode for new demod init * still need sample to poll/interrupt for SAP * * Revision 1.6  2004/07/02 00:13:16  jpong * read Demod (modus) always returns zero * so you have to set everything in the beginning * read Dsp (anything) seems to be ok though. * * implemented specific board configurations, not tested * still need to implement interactive mode for the updated api in the test program * * **********************************************************************/#include <stdio.h>#include <stdlib.h>#include <string.h>#define ALLOW_OS_CODE 1#include "rmdef/rmdef.h"#include "llad/include/gbus.h"#include "emhwlib_hal/include/emhwlib_registers.h"#include "emhwlib_hal/i2c/include/i2c_hal.h"##include "../helper/helper.h"#include "msp34x5g.h"#define APP_VERSION 	"msp0.55"RMvoid show_commands(void);RMvoid show_cmdline(char* appname);RMvoid show_commands(void){	MPRINT(("r - read\n"));	MPRINT(("w - write\n"));	MPRINT(("c - send default config\n"));	MPRINT(("s - set slave address\n"));	MPRINT(("\n"));	MPRINT(("C - Control, (d)etect, (r)eset\n"));	MPRINT(("D - Demodulator, (i)nit - IMPORTANT and I2s OUT, (p) prescale IMPORTANT, (s)elect standard, s(t)atus\n"));	MPRINT(("X - SCART1 DSP source\n"));	MPRINT(("K - SCART1 OUT, (v)olume, (s)elect source\n"));	MPRINT(("M - Matrix selection\n"));	MPRINT(("S - SAP Detection and selection\n"));	MPRINT(("\n"));		MPRINT(("\n"));	MPRINT(("q - quit\n"));}RMvoid show_cmdline(char* appname){	printf("%s [i] [c board-id] [a i2c-address]\n", appname);	printf("Example: %s i c 0x724e1\n\n", appname);	printf("h - This message\n");	printf("i - interactive mode\n");	printf("\n");	printf("c - board configuration\n");	MPRINT(("-----------------------------------\n"));	MPRINT(("Usage for c (board Configuration): c [board number]\n"));	MPRINT(("Supported boards: 24 - 724e1 or 724e4\n"));	printf(("                  60,61 - 760e1\n"));	printf("                  62,63 - 760e3\n");	printf("                  840 - 840e1\n");	printf(("                  80,81 - 781e1\n\n"));	printf("a - i2c address\n\n");}// main//----------------------------------------------------------------------------int main(int argc, char* argv[]){	int argi = 1;	struct llad* 	pLLAD;	RMvoid* 	pGBus;		MSP34X5G_CONFIG	mspConfig;	RMstatus	s;	RMascii		aBuffer[255];		//RMuint8		uSubAddress;	//RMuint8		uData;		RMuint16	Data16;		RMuint32	uBuffer1;	RMuint32	uBuffer2;	RMuint32	uBuffer3;		printf("\n");	printf("Sigma Designs ");       	printf(APP_VERSION);		printf(" (c) 2003\n");	printf("----------------------------------------------\n");	if( argc <= 1 )	{		show_cmdline(argv[0]);		return 0;	}		if( (s = mum_init( 0, &pLLAD, &pGBus)) != RM_OK )	{		MPRINT(("main !mum_init FAILED %d\ncheck your 86xx driver\n", s));		exit(s);	}	memset(&mspConfig, 0, sizeof(MSP34X5G_CONFIG));		mspConfig.i2cConfig.pGBus = pGBus;	mspConfig.i2cConfig.PioClock = 0;	mspConfig.i2cConfig.PioData = 1;	mspConfig.i2cConfig.DelayUs = 10;	mspConfig.i2cConfig.RegBase = REG_BASE_system_block;	mspConfig.i2cConfig.WrAddr = MSP34X5G_I2C_ADDR & 0xFE;	mspConfig.i2cConfig.RdAddr = MSP34X5G_I2C_ADDR | 1;	// Cmd line Parsing	// if( argc > 1)	{		RMuint32 mode = 0;		RMint8 interactive = 0;				RMuint8 a0;				while( argi < argc )		{			switch( argv[argi][0] )			{_label_instructions:			default:			case 'h':				show_cmdline(argv[0]);				argi = argi + 1;				goto main_exit;				break;			case 'i':				interactive = 1;				argi = argi + 1;				break;							case 'a': // Address				if( argc <= argi + 1)					goto _label_instructions;				a0 = strtol(argv[argi+1], NULL, 16) & 0xFF;				mspConfig.i2cConfig.WrAddr = a0 & 0xFE;				mspConfig.i2cConfig.RdAddr = a0 | 1;				MPRINT(("msp34x5g assigned i2c rd=0x%x wr=0x%x\n", mspConfig.i2cConfig.RdAddr, mspConfig.i2cConfig.WrAddr));								argi = argi + 2;				break;							case 'c': 				if( argc <= argi + 1)					goto _label_instructions;				mode = strtol(argv[argi+1], NULL, 10);				argi = argi + 2;				break;			} // end switch					} //end while		switch( mode )		{		case 24:			MPRINT(("configuration %ld selected for board 724e1/e4, btsc tuner in, sc1out\n", mode));			MPRINT(("---------------------------------------------------------------------------\n"));			MPRINT(("on board %lx, msp34x5g defaults to i2c address 0x%x and 0x%x\n",				mode, mspConfig.i2cConfig.WrAddr, mspConfig.i2cConfig.RdAddr));					if( RMFAILED(s = msp34x5g_detect(&mspConfig)) )			{				MPRINT(("msp34x5g_detect() RM_OK:%c, RM_NOT_FOUND:%c\n", (s == RM_OK)?'y':'n', (s == RM_NOT_FOUND)?'y':'n'));			}			else				MPRINT(("msp34x5g_detect() detected\n"));			MPRINT(("reset\n"));			if( RMFAILED(s = msp34x5g_reset(&mspConfig)) )				MPRINT(("msp34x5g_reset() FAILED %d\n", s));			MPRINT(("Demod = BTSC Stereo, fm prescale = 100khz deviation, digio TRistate, I2sOUT Tristate\n"));			if( RMFAILED(s = msp34x5g_demod_init(&mspConfig, msp_45mhz_MBtsc, msp_65mhz_LSecam, msp_digio_tristate, MSP34X5G_I2SOUT_PIN_TRISTATE)) ) // FM Prescale here				MPRINT(("msp34x5g_demod_init(btsc/LSecam, io-z, i2s-z) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_selectStandard(&mspConfig, msp_standard_btscstereo)) )				MPRINT(("msp34x5g_demod_selectStandard(msp_standard_btscstereo) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_InputFMamPrescale(&mspConfig, msp_fm100khz)) )				MPRINT(("msp34x5g_demod_InputFMamPrescale(fm 100 khz deviation) FAILED %d\n", s));						MPRINT(("SCART1DA Stereo A\n"));			if( RMFAILED(s = msp34x5g_matrix_SelectSource(&mspConfig, matrix_sc1DA, matrix_src_stereoA)) )				MPRINT(("mspmsp34x5g_matrix_SelectSource(matrix_sc1DA, matrix_src_stereoA) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_matrix_SelectMode(&mspConfig, matrix_sc1DA, matrix_mode_stereo)) )				MPRINT(("msp34x5g_matrix_SelectMode(matrix_sc1DA, matrix_mode_stereo) FAILED %d\n", s));							MPRINT(("sc1out vol 0db\n"));			if( RMFAILED(s = msp34x5g_scart1out_SelectSource(&mspConfig, sc1out_src_sc1DA)) )				MPRINT(("msp34x5g_scart1out_SelectSource(sc1out_src_sc1DA) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_scart1out_SetVolume(&mspConfig, MSPVOL_0DB)) )				MPRINT(("msp34x5g_scart1out_SetVolume(MSPVOL_0DB) FAILED %d\n", s));			break;								case 60:		case 61:			MPRINT(("configuration %ld selected for board 760e1, I2s out\n", mode));			MPRINT(("60 = tuner IF in\n"));			MPRINT(("61 = SCART1\n"));			MPRINT(("----------------------------------------------------------------------\n"));			MPRINT(("on board %lx, msp34x5g defaults to i2c address 0x%x and 0x%x\n",				mode, mspConfig.i2cConfig.WrAddr, mspConfig.i2cConfig.RdAddr));						if( RMFAILED(s = msp34x5g_detect(&mspConfig)) )			{				MPRINT(("msp34x5g_detect() RM_OK:%c, RM_NOT_FOUND:%c\n", (s == RM_OK)?'y':'n', (s == RM_NOT_FOUND)?'y':'n'));			}			else				MPRINT(("msp34x5g_detect() detected\n"));			MPRINT(("reset\n"));			if( RMFAILED(s = msp34x5g_reset(&mspConfig)) )				MPRINT(("msp34x5g_reset() FAILED %d\n", s));						MPRINT(("Demod = BTSC Stereo, fm prescale = 100khz deviation, digio TRistate, I2sOUT active-master-32bit\n"));			if( RMFAILED(s = msp34x5g_demod_init(&mspConfig, msp_45mhz_MBtsc, msp_65mhz_LSecam, msp_digio_tristate, MSP34X5G_I2SOUT_PIN_ACTIVE | MSP34X5G_I2SOUT_MODE_MASTER | MSP34X5G_I2SOUT_BIT_32)) ) // FM Prescale here				MPRINT(("msp34x5g_demod_init(4.5mhz=btsc, 6.5mhz=lsecam, io-z, i2s-ACTIVE) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_selectStandard(&mspConfig, msp_standard_btscstereo)) )				MPRINT(("msp34x5g_demod_selectStandard(msp_standard_btscstereo) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_InputFMamPrescale(&mspConfig, msp_fm100khz)) )				MPRINT(("msp34x5g_demod_InputFMamPrescale(fm 100 khz deviation) FAILED %d\n", s));											MPRINT(("SCART DSP = SC1 IN, prescale = 0db\n"));			if( RMFAILED(s = msp34x5g_scartdsp_SelectSource(&mspConfig, sc_dsp_src_sc1in)) )				MPRINT(("msp34x5g_scartdsp_SelectSource(sc_dsp_src_sc1in) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_scartdsp_InputPrescale(&mspConfig, MSPSCARTDSP_PRESCALE_0DB)) )				MPRINT(("msp34x55g_scartdsp_InputPrescale(0dB) FAILED %d\n", s));							if( mode == 60 )			{				MPRINT(("I2S Matrix = Stereo or A\n"));				if( RMFAILED(s = msp34x5g_matrix_SelectSource(&mspConfig, matrix_i2s, matrix_src_stereoA)) )					MPRINT(("mspmsp34x5g_matrix_SelectSource(matrix_i2s, matrix_src_stereoA) FAILED %d\n", s));			}			else 			{				MPRINT(("I2S Matrix = SCARTin\n"));				if( RMFAILED(s = msp34x5g_matrix_SelectSource(&mspConfig, matrix_i2s, matrix_src_SCARTin)) )					MPRINT(("mspmsp34x5g_matrix_SelectSource(matrix_i2s, matrix_src_SCARTin) FAILED %d\n", s));			}			if( RMFAILED(s = msp34x5g_matrix_SelectMode(&mspConfig, matrix_i2s, matrix_mode_stereo)) )				MPRINT(("msp34x5g_matrix_SelectMode(matrix_i2s, matrix_mode_stereo) FAILED %d\n", s));							{				GPIO_CONFIG gC;								memset(&gC, 0, sizeof(gC));				gC.pGBus = pGBus;				gC.nGpioCfg = GpioCfg_Gpio;				MPRINT(("Setting GPIO8 to 0 for SEL_DIG pin on the 760e1 board\n"));				mum_gpioSetDir(&gC, 8, 1);				mum_gpioSet(&gC, 8, 0);			}			break;					case 62:		case 63:		case 840:			MPRINT(("configuration %ld selected for board 760e2, SC1 out\n", mode));			MPRINT(("62, 840 = tuner IF in\n"));			printf("63 = SCART IN\n");			MPRINT(("----------------------------------------------------------------------\n"));			MPRINT(("on board %lx, msp34x5g defaults to i2c address 0x%x and 0x%x\n",				mode, mspConfig.i2cConfig.WrAddr, mspConfig.i2cConfig.RdAddr));						if( RMFAILED(s = msp34x5g_detect(&mspConfig)) )			{				MPRINT(("msp34x5g_detect() RM_OK:%c, RM_NOT_FOUND:%c\n", (s == RM_OK)?'y':'n', (s == RM_NOT_FOUND)?'y':'n'));			}			else				MPRINT(("msp34x5g_detect() detected\n"));			MPRINT(("reset\n"));			if( RMFAILED(s = msp34x5g_reset(&mspConfig)) )				MPRINT(("msp34x5g_reset() FAILED %d\n", s));									MPRINT(("Demod = DK123 Nicam/autodetect, fmdeviation = 100kHz, digio TRistate, I2sOUT active-master-32bit\n"));			if( RMFAILED(s = msp34x5g_demod_init(&mspConfig, msp_45mhz_MBtsc, msp_65mhz_DK123Nicam, msp_digio_tristate, MSP34X5G_I2SOUT_PIN_TRISTATE)) ) // FM Prescale here				MPRINT(("msp34x5g_demod_init(btsc/dk123nicam, io-z, i2s-z) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_selectStandard(&mspConfig, msp_standard_autodetect)) )				MPRINT(("msp34x5g_demod_selectStandard(msp_standard_autodetect) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_demod_InputFMamPrescale(&mspConfig, msp_fm100khz)) )				MPRINT(("msp34x5g_demod_InputFMamPrescale(fm 100 khz deviation) FAILED %d\n", s));							{				RMint32 loop;				RMuint16 standard;							MPRINT(("detecting standard... 5 seconds...."));				for( loop = 0; loop < 5; loop++)				{					if( RMFAILED(s = msp34x5g_demod_getDetectedStandard(&mspConfig, &standard)) )						MPRINT(("msp34x5g_demod_getDetectedStandard() failed\n"));											if( standard == 0 )					{						MPRINT(("no standard detected\n"));						break;					}					else if( standard <= 0x7FF )					{						MPRINT(("0x%x detected\n", standard));						break;					}					mum_sleep(1);				}				if( loop == 5 )					MPRINT(("no standard detected\n"));			}							// the 760e2 is either IF in or SCART1 in.			MPRINT(("SCART DSP = SC1 IN, prescale = 0db\n"));			if( RMFAILED(s = msp34x5g_scartdsp_SelectSource(&mspConfig, sc_dsp_src_sc1in)) )				MPRINT(("msp34x5g_scartdsp_SelectSource(sc_dsp_src_sc1in) FAILED %d\n", s));			if( RMFAILED(s = msp34x5g_scartdsp_InputPrescale(&mspConfig, MSPSCARTDSP_PRESCALE_0DB)) )				MPRINT(("msp34x55g_scartdsp_InputPrescale(0dB) FAILED %d\n", s));					// the output is SC1 OUT.  			if( RMFAILED(s = msp34x5g_matrix_SelectMode(&mspConfig, matrix_sc1DA, matrix_mode_stereo)) )				MPRINT(("msp34x5g_matrix_SelectMode(matrix_sc1DA, matrix_mode_stereo) FAILED %d\n", s));			switch ( mode )			{			case 62:			case 840:				// route IF to SC1.				MPRINT(("SCART1DA Stereo A\n"));				if( RMFAILED(s = msp34x5g_matrix_SelectSource(&mspConfig, matrix_sc1DA, matrix_src_stereoA)) )					MPRINT(("mspmsp34x5g_matrix_SelectSource(matrix_sc1DA, matrix_src_stereoA) FAILED %d\n", s));				break;			default:				// route SC1 in to SC1 out through the DSP , there is another path...

⌨️ 快捷键说明

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