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

📄 msp4450g.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	//regValue=regValue & (~(0x19<<5)); //Scart1 input	regValue=regValue & (~(0x18<<5)); //Scart4 to DSP input xxxx00xx1	regValue=regValue | (0x01<<5);	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//SCART Input Prescale : 0db gain	regAdd=0x000d;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue=regValue | 0x1900; //Prescale Scart	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);			//Matrix Mode for LoudSpeaker output : (0x08)	//regAdd=0x09; //Headphone	regAdd=0x08; //LoudSpeaker	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue =regValue & 0xff00;	regValue =regValue | 0x0020; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//Matrix Source for SCART input :		//regAdd=0x09; //HeadPhone	regAdd=0x08;  //Loudspeaker	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x02ff; //SCART input	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Set Volume for loudSpeaker :	//regAdd=0x06; // Headphone	regAdd=0x00; //Loudspeaker/*	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue = regValue & 0x00ff;	regValue =regValue | 0x7300; 	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);*/		return err;}RMstatus msp4450g_InitMonoInHeadPhoneOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;		//MONO input to Headphone	printf("**Mono input to headphone** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);	//Source select	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue=regValue & (~(0x19<<5)); //Scart1 input	regValue=regValue | (0x08 <<5 ); //MONO input to DSP	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//FM/AM Input Prescale : 	regAdd=0x000e;//	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);//	regValue = regValue & 0x00ff;//	regValue=regValue | 0x2400; //100 kHz FM deviation	//FM Matrix mode:	regValue = 0x2403;	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//Matrix Mode for Headphone output : (0x09)	regAdd=0x09;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue =regValue & 0xff00;	regValue =regValue | 0x0020; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//Matrix Source for FM/AM mono signal input :	regAdd=0x09;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x00ff; 	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Set Volume for headphone :/*	regAdd=0x06;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue = regValue & 0x00ff;	regValue =regValue | 0x7300; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);*/	//msp4450g_headphone_SetVolume(pInstance,volume);	return err;}RMstatus msp4450g_applyStandardDetected(struct RUA *pInstance,RMuint32 modus){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	regAdd=0x007e;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDEMOD,regAdd,&regValue);	switch(regValue) {	case 0x0000:		printf("Could not find a sound standard !\n");		break;	case 0x0003:		printf("B/G-FM sound standard detected !\n");		break;	case 0x0008:		printf("B/G-NICAM sound standard detected !\n");		break;	case 0x000a:		printf("I sound standard detected !\n");		break;	case 0x0040:		printf("FM-radio sound standard detected !\n");		break;	case 0x0002:			case 0x0020:			case 0x0030:		{			//modus[14,13] detected 4.5 MHz carrier is interpreted			switch(modus & 0x6000) {			case 0x00:				printf("M-Korea standard detected !\n");				break;			case 0x01:				printf("M-BTSC standard detected !\n");				break;			case 0x10:				printf("M-Japan standard detected !\n");				break;			default:				printf("Chroma carrier  !\n");				break;			}						break;		}	case 0x0009:	case 0x0004:	case 0x000b:		{			//modus[12] detected 6.5 MHz carrier is interpreted 			switch(modus & 0x1000) {			case 0x0:				printf("L-(SECAM) standard detected !\n");				break;			case 0x1:				printf("D/K1, D/K2, D/K3, or D/K NICAM standard detected !\n");				break;			default:				break;			}						break;		}		default:		break;	}/*	regValue=regValue & (~(0x19<<5)); //Scart1 input	regValue=regValue | (0x08 <<5 ); //MONO input to DSP	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);*/		return err;}RMstatus msp4450g_InitMonoInLoudSpeakerOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	RMuint8 detected=0;		//MONO input to Headphone	printf("**Mono input to LoudSpeaker** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);		msp4450g_demod_init(pInstance,msp_45mhz_MBtsc, msp_65mhz_DK123Nicam, msp_digio_tristate, MSP4450G_I2SOUT_PIN_TRISTATE);	msp4450g_demod_selectStandard(pInstance, msp_standard_autodetect);	msp4450g_demod_InputFMamPrescale(pInstance, msp_fm100khz);	{		RMint32 loop;		RMuint32 standard;				printf("detecting standard... 5 seconds....");		for( loop = 0; loop < 20; loop++)		{			if( RMFAILED(msp4450g_demod_getDetectedStandard(pInstance, &standard)) )				printf("msp4450g_demod_getDetectedStandard() failed\n");						if( standard == 0 )			{				printf("no standard detected\n");				//break;			}			else if( standard <= 0x7FF )			{				printf("0x%lx detected\n", standard);				detected=1;				/*				regAdd=0x0000;								regValue=0x7300; //Volume								write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,0x12,regAdd,regValue);								*/				//read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,0x13,regAdd,&regValue);								break;							}			usleep(500);		}		/*		if( loop == 5 )		MPRINT(("no standard detected\n"));*/			}	//Source select	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue=regValue & (~(0x19<<5)); //Scart1 input	regValue=regValue | (0x08 <<5 ); //MONO input to DSP 	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//FM/AM Input Prescale and Matrix mode	if (!detected) {		regAdd=0x000e;		regValue = 0x2403;		write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);			}else{		//Matrix mode is set automaticaly. We only set Prescale :		regAdd=0x000e;		read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue = regValue & 0x00ff;		regValue=regValue | 0x2400; //100 kHz FM deviation		write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);					}			//Matrix Mode for LoudSpeaker output : (0x08) [7:0]	if (!detected) {		regAdd=0x08;		read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue =regValue & 0xff00;		regValue =regValue | 0x0030; //Mono		write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);					}else { // page 34 ... should be set to Stereo (transparent).		regAdd=0x08;		read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue =regValue & 0xff00;		regValue =regValue | 0x0020; //Stereo (transparent)		write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);					}		//Matrix Source for LoudSpeaker output (0x08) [15:8] :		regAdd=0x08;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x00ff; //FM/AM demodulated//	regValue =regValue | 0x04ff; //FM/AM demodulated	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Set Volume for headphone :/*	regAdd=0x00;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue = regValue & 0x00ff;	regValue =regValue | 0x4d00; 	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);*/	//msp4450g_headphone_SetVolume(pInstance,volume);	return err;}RMstatus msp4450g_InitScart1InI2sAndHeadPhoneOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**Scart1 input to headphone** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);	//Source select (Scart signal path)	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue=regValue & (~(0x19<<5)); //Scart1 input	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//SCART Input Prescale : 0db gain	regAdd=0x000d;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue=regValue | 0x1900; //Prescale Scart	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//I2S inputs prescale (set to 0 db after RESET) 	//msp4450g_reset(pInstance); 	regAdd=0x0011; //I2S 3 Prescale	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue=regValue | 0x1000; //0 db gain and mod synchronous input mode	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		regAdd=0x30;	//regValue=0x30a9;	//regValue=0x0024;	msp4450g_writeDemod(pInstance,regAdd,regValue);		regAdd=0x40;	regValue=0x04fd;	regValue=0x04f9;	//regValue=0x04f1;		//regValue=0x05fe;	regValue=0x00;	msp4450g_writeDemod(pInstance,regAdd,regValue);	//Output Channels : 2 output channel : I2S, Headphone	//Matrix Source for SCART  Input and output I2S :		regAdd=0x0b; // I2S Output	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x02ff; //SCART Input	//	regValue =regValue | 0x03ff; //Stereo A	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Matrix Mode for I2S output channel: (0x09)		regAdd=0x0b;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue =regValue & 0xff00;	regValue =regValue | 0x0020; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	//Matrix Source for I2S 3 input and Headphone output:	regAdd=0x09; //HeadPhone Output	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x07ff; //I2S 3 input channels 1 and 2	//regValue =regValue | 0x08ff; //I2S 3 input channels 3 and 4	//regValue =regValue | 0x09ff; //I2S 3 input channels 5 and 6	//regValue =regValue | 0x0aff; //I2S 3 input channels 7 and 8	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Matrix Mode for Headphone output : (0x09)		regAdd=0x09;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue =regValue & 0xff00;	regValue =regValue | 0x0020; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Set Volume for headphone :	regAdd=0x06;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);		regValue = regValue & 0x00ff;	regValue =regValue | 0x7300; //Stereo(transparent mode)	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//msp4450g_headphone_SetVolume(pInstance,volume);	return err;	}RMstatus msp4450g_InitScart1InI2sAndHeadPhoneOutSlaver(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**Scart1 input to headphone** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);		//Source select (Scart signal path)	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue=regValue & (~(0x19<<5)); //Scart1 input	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//SCART Input Prescale : 0db gain	regAdd=0x000d;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue=regValue | 0x1900; //Prescale Scart	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//I2S inputs prescale (set to 0 db after RESET) 	//msp4450g_reset(pInstance); 	regAdd=0x0011; //I2S 3 Prescale	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue=regValue | 0x1000; //0 db gain and mod synchronous input mode	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);			regAdd=0x30;	//regValue=0x30a9;	regValue=0x0024; //bit [5] = 0 	msp4450g_writeDemod(pInstance,regAdd,regValue);		//Output Channels : 2 output channel : I2S, Headphone	//Matrix Source for SCART  Input and output I2S :		regAdd=0x0b; // I2S Output	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	regValue = regValue & 0x00ff;	regValue =regValue | 0x02ff; //SCART Input	//	regValue =regValue | 0x03ff; //Stereo A	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);		//Matrix Mode for I2S output channel: (0x09)		regAdd=0x0b;

⌨️ 快捷键说明

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