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

📄 #dsk_app.c#

📁 详细的OFDM设计过程
💻 C#
📖 第 1 页 / 共 3 页
字号:
	    		DSK6713_LED_off(1);	      		DSK6713_LED_off(0);			}				break;		case 2: 			DSK6713_LED_toggle(0);			if(nextFrame<(BUFFSIZE-FRAMELEN)){				copyData(&databuf[startindex[0]+48], framebuffer, FRAMELEN);				extractFrame(framebuffer, frameNumber, FRAMELEN);				nextFrame = nextFrame+FRAMELEN;				frameNumber++;				state_r = 2;			} else {  // Fucking bastards! The frame overlaps the buffer borders..				copyData(&databuf[startindex[0]+48], framebuffer, (BUFFSIZE-startindex[0]-48));				nextFrame = FRAMELEN-(BUFFSIZE-nextFrame);					state_r = 3;			}			break;				case 3: 		// Buffer begins with a half frame..			DSK6713_LED_toggle(0);			copyData(databuf, &framebuffer[FRAMELEN-nextFrame], (nextFrame-1));			extractFrame(framebuffer, frameNumber, FRAMELEN);			frameNumber++;			state_r = 2;			break;		case 4:			DSK6713_LED_toggle(0);			// All frames are recieved.. Kill all..			break;	}		state_r=1;	framesync(databuf, startindex, length);	//	energydetect(databuf, startindex, length);//	slask = startindex[0] - loopIndex;		if(startindex[0] != 0)	{		if((RefIndex+10)==startindex[0]) 		   	DSK6713_LED_toggle(1);			//if(((loopIndex-10)<startindex[0]) && ((loopIndex+40)>startindex[0]))    	if((loopIndex+17)==startindex[0])     		DSK6713_LED_toggle(0);/*    DSK6713_LED_on(1);	while(1){		DSK6713_LED_toggle(0);//		 createTrig(ProcessBuffer, BUFFSIZE);              /* Copy receive PING buffer to transmit PING buffer *///	     copyData2x2(ProcessBuffer, gBufferXmtPong, BUFFSIZE);		//	}	*/		RefIndex = startindex[0];	} else {	      DSK6713_LED_off(1);	      DSK6713_LED_off(0);	}			// Call next syncronization funktion//	sync(float *in , const float *training_seq)			// Decode the frame here:	// Call downsample	// Call demodulation	// Call deinterleaving	// Call deconvolution		   		}void extractFrame(short *framebuffer, short frameNumber, short length){	state_r = 1;}/* *  copy2Data() - Copy one buffer with length elements to another. *  And remove every second value.  */void copy2Data(short *inbuf, short *outbuf, short length){	// length is length of outbuffer, == 1/2 inbuf    short i = 0;        for (i = 0; i < length; i++) {                              outbuf[i]  = inbuf[i*2];    }}/* *  copyData2x2() - Copy one buffer with length elements to another. *  And remove every second value.  */void copyData2x2(short *inbuf, short *outbuf, short length){	// length is length of inbuffer, == 1/2 outbuf    short i = 0;        for (i = 0; i < length; i++) {                              outbuf[i*2]  = inbuf[i];    }}void createTrig(short *databuf, const short length){	short i, k=0;		// Length of sine wave table *	const short sin_size = 48; //  72	// Pre-generated sine wave data, 16-bit signed samples *	short sinetable[ ] = {    	0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,    	0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x76ef,    	0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,    	0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,    	0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,    	0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c	};  	/*	short sinetable[ ] = {		0, 		5328, 	10714, 	15982, 	20926, 	25317, 	28906, 	31441, 		32681, 	32412, 	30479, 	26805, 	21422, 	14496, 	6346, 	-2546, 		-11545, -19888, -26739, -31270, -32762, -30732, -25057, -16084, 		-4688, 	7733, 	19377, 	28262, 	32571, 	31054, 	23444, 	10743, 		-4705, 	-19503, -29864, -32600, -26223, -11813, 6756, 	23554, 		32371, 	29125, 	14059, 	-7402, 	-26064, -32705, -22915, -579	};*//*	short sinetable[ ] = {	0,		2207,	4404,	6580,8,	8727,7,	10835,	12892,	14891,	16822,	18676,	20445,	22121,	23696,	25163,	26515,	27746,	28851,	29824,	30661,	31358,	31912,	32321,	32582,	32695,	32659,	32473,	32140,	31660,	31035,	30269,	29366,	28328,	27160,	25870,	24461,	22940,	21315,	19593,	17781,	15888,	13923,	11894,	9811,3,	7683,6,	5520,9,	3332,9,	1129,8,	-1078,5  };*//*	short sinetable[ ] = {		0,	3701,	7460,	11222,	14924,	18495,	21857,	24925,		27612,	29828,	31481,	32485,	32760,	32237,	30865,	28614,		25478,	21486,	16703,	11233,	5222,	-1138,	-7616,	-13944,		-19826,	-24949,	-29001,	-31688,	-32758,	-32026,	-29398,	-24897,		-18676,	-11038,	-2431,	6564,	15258,	22902,	28751,	32136,		32554,	29747,	23777,	15077,	4456,	-6939,	-17721,	-26420,		-31684,	-32509,	-28463,	-19847,	-7777,	5894,	18799,	28440,		32688,	30302,	21350,	7416,	-8547,	-22744,	-31409,	-31852,		-23414,	-7985,	10178,	25468,	32625,	28651,	14279,	0			};*/	//	int j;	loopIndex += 10;	if(loopIndex>400)		loopIndex=100;	for(i=0; i<BUFFSIZE; i++)		databuf[i]=0;	for(i=loopIndex; i<(loopIndex+sin_size); i++)		{			databuf[i]=sinetable[k];			k++;		}}void energydetect(const short *databuf, short *startindex, const short length){	short i,k;	int sum;	startindex[0] = 0;	for(i=0; i<length-10; i+=5)	{		sum = 0;		for(k=0; k<10; k++)			sum += databuf[k+i]*databuf[k+i];		if(sum>treshold){					// Find a good detection threshold. 			startindex[0]=i;				break;		}	}}void framesync(short *databuf, short *startindex, short length){	// The databuf might contain a trigger signal, the same as the defined sinetable here. 	/* Length of sine wave table */	const short sin_size = 48;   // 72	/* Pre-generated sine wave data, 16-bit signed samples */	const short sinetable[ ] = {    	0x0000, 0x10b4, 0x2120, 0x30fb, 0x3fff, 0x4dea, 0x5a81, 0x658b,    	0x6ed8, 0x763f, 0x7ba1, 0x7ee5, 0x7ffd, 0x7ee5, 0x7ba1, 0x76ef,    	0x6ed8, 0x658b, 0x5a81, 0x4dea, 0x3fff, 0x30fb, 0x2120, 0x10b4,     	0x0000, 0xef4c, 0xdee0, 0xcf06, 0xc002, 0xb216, 0xa57f, 0x9a75,    	0x9128, 0x89c1, 0x845f, 0x811b, 0x8002, 0x811b, 0x845f, 0x89c1,    	0x9128, 0x9a76, 0xa57f, 0xb216, 0xc002, 0xcf06, 0xdee0, 0xef4c 	};/*	short sinetable[ ] = {	0,		2207,	4404,	6580,8,	8727,7,	10835,	12892,	14891,	16822,	18676,	20445,	22121,	23696,	25163,	26515,	27746,	28851,	29824,	30661,	31358,	31912,	32321,	32582,	32695,	32659,	32473,	32140,	31660,	31035,	30269,	29366,	28328,	27160,	25870,	24461,	22940,	21315,	19593,	17781,	15888,	13923,	11894,	9811,3,	7683,6,	5520,9,	3332,9,	1129,8,	-1078,5  };*//*	short sinetable[ ] = {		0, 		5328, 	10714, 	15982, 	20926, 	25317, 	28906, 	31441, 		32681, 	32412, 	30479, 	26805, 	21422, 	14496, 	6346, 	-2546, 		-11545, -19888, -26739, -31270, -32762, -30732, -25057, -16084, 		-4688, 	7733, 	19377, 	28262, 	32571, 	31054, 	23444, 	10743, 		-4705, 	-19503, -29864, -32600, -26223, -11813, 6756, 	23554, 		32371, 	29125, 	14059, 	-7402, 	-26064, -32705, -22915, -579	};*//*	short sinetable[ ] = {		0,	3701,	7460,	11222,	14924,	18495,	21857,	24925,		27612,	29828,	31481,	32485,	32760,	32237,	30865,	28614,		25478,	21486,	16703,	11233,	5222,	-1138,	-7616,	-13944,		-19826,	-24949,	-29001,	-31688,	-32758,	-32026,	-29398,	-24897,		-18676,	-11038,	-2431,	6564,	15258,	22902,	28751,	32136,		32554,	29747,	23777,	15077,	4456,	-6939,	-17721,	-26420,		-31684,	-32509,	-28463,	-19847,	-7777,	5894,	18799,	28440,		32688,	30302,	21350,	7416,	-8547,	-22744,	-31409,	-31852,		-23414,	-7985,	10178,	25468,	32625,	28651,	14279,	0			};*/		int res[2];		correlation(sinetable, databuf, sin_size, length, res);		startindex[0] = res[1];		if(res[0] < 1000000)		// is the correlation over minimum treshold. 		startindex[0] = 0;}void correlation(const short *reference, const short *input, const short len_ref, const short len_inp, int *res){	short i,k;	int sum;	res[0]=0;	for (i = 0; i < (len_inp - len_ref); i++){		sum = 0;//		slask=0;		for (k = i; k < (len_ref+i); k++){			sum = sum + (((input[k]/0x10) * (reference[k-i]/0x10)));			if(sum<-10000)				break;		}		if(res[0]<(sum))			// Find and store the point with largest correlation. 		{			res[0] = (sum);			res[1] = i;		}	}}/* *  blinkLED() - Periodic thread (PRD) that toggles LED #0 every 500ms if  *               DIP switch #0 is depressed.  The thread is configured *               in the DSP/BIOS configuration tool under Scheduling --> *               PRD --> PRD_blinkLed.  The period is set there at 500 *               ticks, with each tick corresponding to 1ms in real *               time. */void blinkLED(void){    /* Toggle LED #0 if DIP switch #0 is off (depressed) */    if (!DSK6713_DIP_get(0))        DSK6713_LED_toggle(0);}/* *  load() - PRD that simulates a 20-25% dummy load on a 225MHz 6713 if *           DIP switch #1 is depressed.  The thread is configured in *           the DSP/BIOS configuration tool under Scheduling --> PRD *           PRD_load.  The period is set there at 10 ticks, which each tick *           corresponding to 1ms in real time. */void load(void){    volatile Uint32 i;      if (!DSK6713_DIP_get(1))        for (i = 0; i < 30000; i++);}

⌨️ 快捷键说明

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