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

📄 tonetimer.c

📁 DTMF收发芯片88L89完美驱动(Arm,SDT251环境)
💻 C
字号:
/* tone_Timer.c - 音频服务 应用层 定时器消息函数 */

/* Copyright 1994-2001 Wuhan Jinglun Electronic Co., Ltd. */

/* 
modification history
--------------------

*/

/* 
DESCRIPTION 根据定时器消息提供相应的服务。
*/

#include	"nucleus.h"
#include	"routon.h"
#include	"debug.h"

#include	<stdio.h>
#include	<string.h>

#include	"pcdisk.h"



#include	"codec.h"

#include	"intfTone.h"
#include	"..\inc\rtn_tone.h"

//1个队列
//extern NU_TIMER TONE_Timer_HFC_Start;
//extern NU_TIMER TONE_Timer_HFC_Stop;
extern NU_TIMER TONE_Timer_ARM_Start;
extern NU_TIMER TONE_Timer_ARM_Stop;

//extern NU_TIMER TONE_Timer_KEYS_Down;
//extern NU_TIMER TONE_Timer_DTMF_Down;

//2个设备
//extern TONE_APP_DEVICE_INFO_t gTONE_App_Device_Info_HFC;	
extern TONE_APP_DEVICE_INFO_t gTONE_App_Device_Info_ARM;

///////////////////////////////////////////////////////////////////////
//中断服务程序
///////////////////////////////////////////////////////////////////////

#if 0
/**********************************************************************
*                                                                      
*  FUNCTION		"tone_HISR_Timer_HFC_Start"          定时器.中断服务程序       
*
***********************************************************************/
void tone_HISR_Timer_HFC_Start(UNSIGNED id)
{
	RtnMSG	s_msg;

	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_HISR_Timer_HFC_Start");

	s_msg.msg_len = 3;
	s_msg.msg_code = MSG_TONE_TIMER_HFC_START;	
	status = NU_Send_To_Pipe(&rtn_pipe[TONE], &s_msg, s_msg.msg_len + 4, NU_NO_SUSPEND);  
	if (status < NU_SUCCESS) 
	{
		PRINTERRR("ERRR: NU_Send_To_Pipe: %d. ", status);  
		LogError("Error %s L %d\n",__FILE__,__LINE__);
	}

	//PRINTFLOW("TIMER: Enddd: tone_HISR_Timer_HFC_Start");
	return;
}

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_HISR_Timer_HFC_Stop"          定时器.中断服务程序       
*
***********************************************************************/
void tone_HISR_Timer_HFC_Stop(UNSIGNED id)
{
	RtnMSG	s_msg;

	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_HISR_Timer_HFC_Stop");

	s_msg.msg_len = 3;
	s_msg.msg_code = MSG_TONE_TIMER_HFC_STOP;	
	status = NU_Send_To_Pipe(&rtn_pipe[TONE], &s_msg, s_msg.msg_len + 4, NU_NO_SUSPEND);  
	if (status < NU_SUCCESS) 
	{
		PRINTERRR("ERRR: NU_Send_To_Pipe: %d. ", status);  
		LogError("Error %s L %d\n",__FILE__,__LINE__);
	}

	//PRINTFLOW("TIMER: Enddd: tone_HISR_Timer_HFC_Stop");
	return;
}

#endif

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_HISR_Timer_ARM_Start"          定时器.中断服务程序       
*
***********************************************************************/
void tone_HISR_Timer_ARM_Start(UNSIGNED id)
{
	RtnMSG	s_msg;

	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_HISR_Timer_ARM_Start");

	s_msg.msg_len = 3;
	s_msg.msg_code = MSG_TONE_TIMER_ARM_START;	
	status = NU_Send_To_Pipe(&rtn_pipe[TONE], &s_msg, s_msg.msg_len + 4, NU_NO_SUSPEND);  
	if (status < NU_SUCCESS) 
	{
		PRINTERRR("ERRR: NU_Send_To_Pipe: %d. ", status);  
		LogError("Error %s L %d\n",__FILE__,__LINE__);
	}

	//PRINTFLOW("TIMER: Enddd: tone_HISR_Timer_ARM_Start");
	return;
}

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_HISR_Timer_ARM_Stop"          定时器.中断服务程序       
*
***********************************************************************/
void tone_HISR_Timer_ARM_Stop(UNSIGNED id)
{
	RtnMSG	s_msg;

	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_HISR_Timer_ARM_Stop");

	s_msg.msg_len = 3;
	s_msg.msg_code = MSG_TONE_TIMER_ARM_STOP;	
	status = NU_Send_To_Pipe(&rtn_pipe[TONE], &s_msg, s_msg.msg_len + 4, NU_NO_SUSPEND);  
	if (status < NU_SUCCESS) 
	{
		PRINTERRR("ERRR: NU_Send_To_Pipe: %d. ", status);  
		LogError("Error %s L %d\n",__FILE__,__LINE__);
	}

	//PRINTFLOW("TIMER: Enddd: tone_HISR_Timer_ARM_Stop");
	return;
}

///////////////////////////////////////////////////////////////////////
//函数
///////////////////////////////////////////////////////////////////////

#if 0
/**********************************************************************
*                                                                      
*  FUNCTION		"tone_Proc_Timer_HFC_Expire_Start"          定时器.中断服务程序       
*
***********************************************************************/
int tone_Proc_Timer_HFC_Expire_Start(TONE_APP_DEVICE_INFO_t * App_Device)
{
//    RtnMSG    msg;   

	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_Proc_Timer_HFC_Expire_Start");

	//PRINTINFO("tone_App_Data_Buf_Sub_Init: %8d\t iLoop_Period", App_Device->iLoop_Period);
	
	//
	//播放次数倒计时
	//
	App_Device->iLoop_Period--;
	
	//
	//如果播放循环结束,则定时器的使命完成
	//	
	if (App_Device->iLoop_Period==0)	//循环结束
	{	
		status = NU_Control_Timer(&TONE_Timer_HFC_Start, NU_DISABLE_TIMER);	
		status = NU_Control_Timer(&TONE_Timer_HFC_Stop,  NU_DISABLE_TIMER);	

		//???	为什么与ARM的处理不一致,注释掉后会不会有副作用
		//status = HFC_Codec_Close(App_Device->idChannel);

		return NU_SUCCESS;		
	}
	
	//
	//打开设备
	//	
	status = HFC_Codec_Open(App_Device->idChannel, 
							App_Device->idMode,		//
							App_Device->idOrient);//			
							
	//
	//写出数据
	//	
	status = HFC_Codec_Write(App_Device->idChannel,
					 (char *)App_Device->pBuf, 
							 App_Device->iBuf, 
							 App_Device->iLoop_Series);

	//PRINTFLOW("TIMER: Enddd: tone_Proc_Timer_HFC_Expire_Start");

	return NU_SUCCESS;
}

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_Proc_Timer_HFC_Expire_Stop"          定时器.中断服务程序       
*
***********************************************************************/
int tone_Proc_Timer_HFC_Expire_Stop(TONE_APP_DEVICE_INFO_t * App_Device)
{
	STATUS	status;
	//PRINTFLOW("TIMER: Begin: tone_Proc_Timer_HFC_Expire_Stop");
	
	//
	//关闭设备
	//	
 	status = HFC_Codec_Close(App_Device->idChannel);

	//PRINTFLOW("TIMER: Enddd: tone_Proc_Timer_HFC_Expire_Stop");
	return NU_SUCCESS;
}

#endif

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_Proc_Timer_ARM_Expire_Start"              
*
***********************************************************************/
int tone_Proc_Timer_ARM_Expire_Start(TONE_APP_DEVICE_INFO_t * App_Device)
{
	STATUS	status;

	//
	//播放次数倒计时
	//
	App_Device->iLoop_Period--;		//周期循环次数	

	//
	//如果播放循环结束,则定时器的使命完成
	//
	if (App_Device->iLoop_Period==0)	
	{
		status = NU_Control_Timer(&TONE_Timer_ARM_Start, NU_DISABLE_TIMER);
		status = NU_Control_Timer(&TONE_Timer_ARM_Stop,  NU_DISABLE_TIMER);

		//status = Codec_Close (CodecWrite, App_Device->idOrient, App_Device->idCodec);

		return 0;	
	}

	//
	//如果播放到听筒,则要做特殊处理
	//
	/*
	if (App_Device->idOrient == TONE_ORIENT_ID_PHONE)
	{
		//
		//启动145481应用激励			2002-05-08, modified, 控制有低层封装
		//
		//status = PhDr_Iocntl(0, CNTLID_GCI_B1_ENABLE, 0);
		PhDr_Open_codec_A_for_app();
	}
	*/
	//
	//打开设备
	//	
	gTONE_App_Device_Info_ARM.idCodec = Codec_Open(CodecWrite, App_Device->idOrient);	
	
	//
	//写出数据
	//	
	status = Codec_Write( (char *)App_Device->pBuf, 
					 		 App_Device->iBuf,			//连续循环次数
					 		 App_Device->iLoop_Series,
							 App_Device->idCodec );

	return NU_SUCCESS;
}

/**********************************************************************
*                                                                      
*  FUNCTION		"tone_Proc_Timer_ARM_Expire_Stop"         
*
***********************************************************************/
int tone_Proc_Timer_ARM_Expire_Stop(TONE_APP_DEVICE_INFO_t * App_Device)
{
	STATUS	status;

	//
	//关闭设备
	//	
	status = Codec_Close (CodecWrite, App_Device->idOrient, App_Device->idCodec);

	//
	//关闭145481应用激励			2002-05-08, modified, 控制有低层封装
	//
	//PhDr_Close_codec_A_for_app();
	
	return NU_SUCCESS;
}

⌨️ 快捷键说明

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