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

📄 dtmfdemo.c

📁 运行环境:CCS2.1
💻 C
字号:
/*************************************************************
*   (C) COPYRIGHT TEXAS INSTRUMENTS, INC. 1996               *
**************************************************************
*   Program Name:     DTMF tone decoder                      *
*   File Name:        dtmfdemo.c                             *
*   File Description: initializes the EVM                    *
*                     performs DTMF decoder on data incoming *
*                     from the serial port                   *
*                                                            *
*   Author:   Gunter Schmer                                  *
*   Date:     03/24/97                                       *
*   Revision: 3.0                                            *
*   Latest working date: 03/24/97                            *
*************************************************************/

#include "init.h"
#include "mmregs.h"
#include "dtmf.h"


/* --------------- channel1 information --------------------------------*/

int  ch1ISRData[102];		/* ISR I/O buffer 			*/
int  ch1Data[102];		/* process buffer 			*/

/* decoder buffers */
int  ch1Digits[1000];		/* output buffer for digit results 	*/
int  ch1Taps[20];		/* filter states  			*/
int  ch1Energy[10];		/* energy template 			*/

/* encoder buffers */
int  ch1Oscis[16];		/* oscillator states			*/
int  ch1Phnbr[11]={2,2,2,2,2,2,2,2,2,2,-1};	/* phone number buffer			*/

/* used for interrupt servicing and signaling a full buffer */
int  *ch1ISRDataPtr = &ch1ISRData[0];	/* ptr to ISR I/O buffer 	*/
int  ch1ISRDataStat = 0;	/* status of ISR I/O buffer 		*/
				/*   0 = buffer not ready to process 	*/
				/*   1 = buffer ready to process 	*/

/* initialized DTMFENCOBJ for channel 1 */
DTMFENCOBJ	ch1EncObj = {	&ch1Data[0],
				&ch1Oscis[0],
				32767,
				5,
				5,
				&ch1Phnbr[0],
				5,
				5,
				1	};

DTMFENCOBJ 	*ch1EncObjPtr = &ch1EncObj;

/* initialized DTMFDECOBJ for channel 1 */
DTMFDECOBJ 	ch1DecObj = {	&ch1Data[0],
				&ch1Taps[0],
				&ch1Energy[0],
				&ch1Digits[0],
				0xFFFF,
				1,
				0	};

DTMFDECOBJ 	*ch1DecObjPtr = &ch1DecObj;
/*-------------------------------------*/
ioport unsigned port5;
int IO_LED = 0 ;
/* -------------- end of channel1 --------------------------------------*/



/* used for testing */
volatile unsigned int *testdataptr = (volatile unsigned int *) 0x8000;


/* prototypes */
void tasks(void);
void initArrays(void);

main()
{
  
	/*********** init HW and SW ************/
	
	//initWSGen();       /* initialize WS generator */
	c54_init();
	initArrays();      /* initialize arrays	*/
	//initSP1();         /* initialize SP1          */
 	//initAC01();        /* initialize AIC          */
	//initInts(0x0040);  /* allow only RINT1        */



	/*********** synch tasks() to RINT0 *********/
	for(;;)   {
		asm("	IDLE	1");	/* wait for interrupts             */
		tasks();		/* run tasks on completion of ISR  */
  	}
}



void tasks(void)
{
	int n;
	int temp;

	if(ch1ISRDataStat==1)  	{
		/* reset indata status bit */
		ch1ISRDataStat = 0;
		/* copy ch1ISRData to ch1Data */
		for(n=0;n<102;n++)	{
			temp = ch1Data[n];
			ch1Data[n] = ch1ISRData[n];
			ch1ISRData[n] = temp;
		}

		/* perform DTMF decode */
		dtmfDecode(ch1DecObjPtr);

		/* perform DTMF encode */
		dtmfEncode(ch1EncObjPtr);
	}
}


void initArrays(void)
{
	int n;

	for(n=0;n<102;n++)   {
		ch1ISRData[n] = 0;
		ch1Data[n] = 0;
	}

	for(n=0;n<1000;n++)
		ch1Digits[n] = 0;

	for(n=0;n<20;n++)
		ch1Taps[n] = 0;

	for(n=0;n<10;n++)
		ch1Energy[n] = 0;

	initoscis(ch1EncObjPtr);
}

⌨️ 快捷键说明

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