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

📄 msp4450g.c

📁 Sample code for use on smp 863x processor.
💻 C
📖 第 1 页 / 共 5 页
字号:
	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_InitScart1InI2sAndLoudSpeakerOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**Scart1 input to LoudSpeaker** \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=0x0016; //I2S 1 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] = 1 //Slaver	//regValue=0x0006; //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;	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=0x08; //LoudSpeaker 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  : 		regAdd=0x08;	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 	regAdd=0x00;	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;	}static inline RMstatus msp4450g_readDemod(struct RUA *pInstance, RMuint32 regAdd, RMuint32 *pData){	return read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDEMOD,regAdd,pData);	}static RMstatus msp4450g_i2s_InputPrescale(struct RUA *pC ,RMuint16 i2s_port,RMuint16 data){	RMuint32 temp;		msp4450g_readDsp(pC,i2s_port,&temp);		temp = temp & 0xFF;		data = data & 0xFF;		data = (data<<8)|temp;		//khuong add	data = data | 0x01 ; //asynchonous input mode for I2S3	//khuong end	printf("\n\t==0x0012,0x0011,0x%X==\n",data);//tractran	write_i2c_dsp_msp4450g(pC,10,0x80>>1,MSP4450G_SADDR_WRDSP,i2s_port,data);			return RM_OK;}static RMstatus msp4450g_i2s_Configure(struct RUA * pC,RMuint32 modus,RMuint32 config){	RMuint32 data16;	RMuint32 data16_temp;	assert(pC != NULL);		msp4450g_readDemod(pC, msp_dmreg_modus, &data16);			msp4450g_readDemod(pC, msp_dmreg_i2sconfig, &data16_temp);	printf("\n\t ===data16_temp = 0x%lX===\n",data16_temp);//tractran				data16 = data16 & 0xF000;	modus = modus & 0xFFF;	data16 = data16 | modus;			data16 = 0x30A9 ;//khuong add , good		printf("\n\t==0x0010,0x0030,0x%lX\n",data16);//tractran	printf("\n\t==0x0010,0x0040,0x%lX\n",config);//tractran		msp4450g_writeDemod(pC,msp_dmreg_modus,data16);			msp4450g_writeDemod(pC, msp_dmreg_i2sconfig,config);		return RM_OK;	}RMstatus msp4450g_InitScart3InI2sAndLoudSpeakerOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMstatus s=RM_OK;		MPRINT(("----------------------------------------------------------------------\n"));			if( RMFAILED(s = msp4450g_detect(pInstance)) )	{		MPRINT(("msp4450g_detect() RM_OK:%c, RM_NOT_FOUND:%c\n", (s == RM_OK)?'y':'n', (s == RM_NOT_FOUND)?'y':'n'));	}	else		MPRINT(("msp4450g_detect() detected\n"));		MPRINT(("reset\n"));	if( RMFAILED(s = msp4450g_reset(pInstance)) )		MPRINT(("msp4450g_reset() FAILED %d\n", s));		MPRINT(("Demod = DK123 Nicam/autodetect, fmdeviation = 100kHz, digio TRistate, I2sOUT active-master-32bit\n"));		MPRINT(("SCART DSP = SC3 IN, prescale = 0db\n"));	if( RMFAILED(s = msp4450g_scartdsp_SelectSource(pInstance, sc_dsp_src_sc3in)) )		MPRINT(("msp4450g_scartdsp_SelectSource(sc_dsp_src_sc3in) FAILED %d\n", s));		MPRINT(("MSPSCARTDSP_PRESCALE_0DB \n"));	if( RMFAILED(s = msp4450g_scartdsp_InputPrescale(pInstance, MSPSCARTDSP_PRESCALE_0DB)) )		MPRINT(("msp44505g_scartdsp_InputPrescale(0dB) FAILED %d\n", s));		//		// i2s in	MPRINT(("MSPI2SDSP_PRESCALE_0DB \n"));	if( RMFAILED(s = msp4450g_i2s_InputPrescale(pInstance,I2S_srcIN_PRESCALE,MSPSI2S_PRESCALE_0DB)) )		MPRINT(("msp4450g_i2s_InputPrescale_kh(0dB) FAILED %d\n", s));					MPRINT(("route SC1 in to i2s out \n"));	if (1) {		//msp4450g_i2s_Configure(pInstance, 0x00B,0);		msp4450g_i2s_Configure(pInstance, 0x01,0);	}		if( RMFAILED(s = msp4450g_matrix_SelectMode(pInstance, matrix_i2s, matrix_mode_stereo)) )		MPRINT(("msp4450g_matrix_SelectMode(matrix_sc1DA, matrix_mode_stereo) FAILED %d\n", s));			if( RMFAILED(s = msp4450g_matrix_SelectSource(pInstance, matrix_i2s ,matrix_src_SCARTin)))		MPRINT(("mspmsp4450g_matrix_SelectSource(matrix_i2s ,matrix_src_SCARTin) FAILED %d\n", s));				// route i2s in to loundspeaker out	// matrix_src_I2S3_c12 :0x07		MPRINT(("route i2s3-12 in to lounfspeaker \n"));	if( RMFAILED(s = msp4450g_matrix_SelectMode(pInstance, matrix_main, matrix_mode_stereo)) )		MPRINT(("msp4450g_matrix_SelectMode(matrix_main, matrix_mode_stereo) FAILED %d\n", s));			if( RMFAILED(s = msp4450g_matrix_SelectSource(pInstance, matrix_main , matrix_src_I2S3_c12))) 		MPRINT(("mspmsp4450g_matrix_SelectSource(matrix_main , matrix_src_I2S3_c12) FAILED %d\n", s))						//if( RMFAILED(s = msp4450g_loudspeaker_SetVolume(&mspConfig, MSPVOL_0DB)))		if( RMFAILED(s = msp4450g_loudspeaker_SetVolume(pInstance, MSPVOL_MID)))			MPRINT(("msp4450g_loundspeaker_SetVolume(MSPVOL_0DB) FAILED %d\n", s));				MPRINT(("SUBWOOFER  \n"));	return err;	}RMstatus msp4450g_InitScart3InI2sAndHeadPhoneOutSlaver(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**Scart3 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;	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_InitI2s3InAndHeadPhoneOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**I2S3 input to headphone** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);	//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);	//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 | 0x0700; //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_InitI2s3InAndLoudSpeakerOut(struct RUA *pInstance){	RMstatus err=RM_OK;	RMuint32 regValue=0x00;	RMuint32 regAdd=0x00;	//Scart1 input to I2s and headphone output 	printf("**I2s3 input to LoudSpeaker** \n");	msp4450g_detect(pInstance);	msp4450g_reset(pInstance);	/*** SCART Signal Path ***/	/* Step 1 : Select analog input for the SCART baseband processing	(SCART DSP Input Select) by means of the	ACB register.  0x13 Page 45 */	regAdd=0x0013;	read_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_RDDSP,regAdd,&regValue);	// high of digital output pin D_CTR_I/O_0 : (Note MODUS[3]=0)	regValue = regValue | 0x4000; //bit [14] = 1	regValue=regValue & (~(0x19<<5)); //Scart 1 to Dsp input	//regValue=regValue | (0x01<<5); // Scart4 to DSP input.	write_i2c_dsp_msp4450g(pInstance,10,0x80>>1,MSP4450G_SADDR_WRDSP,regAdd,regValue);	/* Step 2 :	Select the source for each analog SCART output	(SCART Output Select) by means of the ACB register. */		/*** Demodulator ***/	/* Step 1 : Set MODUS register to the preferred mode and	Sound IF input. */	/* Step 2 : Choose preferred prescale (FM and NICAM) values.*/	/* Step 3 : Write STANDARD SELECT register. */

⌨️ 快捷键说明

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