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

📄 m.c

📁 TMS320c6000系列DSP做图像处理的应用举例,图象的灰度变换.
💻 C
字号:
#include "m.h"
#include "mtv.h"
#include "dtv.h"

cregister unsigned int IER,IFR,CSR,ICR,ISTP;

#define RBR					0xa0300000
#define THR					0xa0300000
#define IIER				0xa0300004
#define IIR					0xa0300008
#define FCR					0xa0300008
#define LCR					0xa030000c
#define MCR					0xa0300010
#define LSR					0xa0300014
#define MSR					0xa0300018
#define SCR					0xa030001c
#define DLL					0xa0300000
#define DLM					0xa0300004

#define DMATARGETADDRESS 0x80040000
#define SCREENWIDTH 720
#define SCREENHEIGHT 576
#define BUFFERHEIGHT 620
#define SCREENWIDTHWORD 180
#define BUFFERWIDTH 768
#define BUFFERWIDTHWORD 192

#define GRAYRANGEX 30
#define GRAYRANGEY 144

extern unsigned int nPositionX,nPositionY;
extern unsigned char *pScreenBuffer;
extern unsigned int *pW,uW;
extern int nI,nJ;

void IMGProcess();

int main()
{
	CSR=0x100;			/* Disable all interrupts            	*/
	IER=1;				/* Disable all interrupts except NMI 	*/
	ICR=0xffff;			/* Clear all pending interrupts      	*/
	initSYS();
	
	*(unsigned volatile int *)EMIF_GCR = 0x3300;    	/* EMIF global control      		*/
	*(unsigned volatile int *)EMIF_SDCTRL = 0x5648f000; 

	*(unsigned volatile int *)EMIF_SDRP = 0x61a;    	/* EMIF SDRM refresh period 		*/
	*(unsigned volatile int *)EMIF_SDEXT= 0x54529;  	/* EMIF SDRM extension      		*/
	*(unsigned volatile int *)EMIF_CE0 = 0x30;      	/* EMIF CE0 control         		*/
	*(unsigned volatile int *)EMIF_CE1 = CE1_32;    	/* EMIF CE1 control, 32bit  		*/
	*(unsigned volatile int *)EMIF_CE2 = CE2_32_max;            
	*(unsigned volatile int *)EMIF_CE3 = CE3_32;		/* EMIF CE3 control			*/
	Init_DTVFPGA(0);

	*(unsigned volatile int *)MTV_WDMA_ADD = 0x0000ffff;
	*(unsigned volatile int *)MTV_WDMA_PARAM = 0x0000ff00;
	*(unsigned volatile int *)MTV_RDMA_ADD = 0x0000ffff;
	*(unsigned volatile int *)MTV_RDMA_PARAM = 0x00001808;
	*(unsigned volatile int *)DTV_WDMA_ADD = 0x0005ffff;
	*(unsigned volatile int *)DTV_WDMA_PARAM = 0x00001808;
	*(unsigned volatile int *)DTV_RDMA_ADD = 0x0000fff0;
	*(unsigned volatile int *)DTV_RDMA_PARAM = 0x00001808;

	nPositionX=16; nPositionY=200;
	pScreenBuffer=(unsigned char*)DMATARGETADDRESS;

	initInterrupt();	//中断初始化,开INT7中断
	for(;;)
	{
	}
}

void IMGProcess()
{
	for ( nI=0;nI<GRAYRANGEY;nI++ )
	{
		pW=(unsigned int*)DMATARGETADDRESS+(nI+nPositionY)*BUFFERWIDTHWORD+nPositionX;
		for ( nJ=0;nJ<GRAYRANGEX;nJ++,pW++)
		{
			uW=(*pW);
			if ( (uW>>24)>0x80 )	{ uW&=0x0ffffff; uW|=0x0fe000000; }
			else	{ uW&=0x0ffffff; uW|=0x1000000; }
			if ( ((uW>>16)&0x0ff)>0x80 )	{ uW&=0x0ff00ffff; uW|=0x0fe0000; }
			else	{ uW&=0x0ff00ffff; uW|=0x10000; }
			if ( ((uW>>8)&0x0ff)>0x80 )	{ uW&=0x0ffff00ff; uW|=0x0fe00;	}
			else	{ uW&=0x0ffff00ff; uW|=0x100; }
			if ( (uW&0x0ff)>0x80 )	{ uW&=0x0ffffff00; uW|=0x0fe; }
			else	{ uW&=0x0ffffff00; uW|=1; }
			(*pW)=uW;
		}
	}
}

⌨️ 快捷键说明

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