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

📄 main.c

📁 羚羊单片机代码,经过我的改进实现去停顿功能!!效果很不错!
💻 C
字号:
//========================================================
//	The information contained herein is the exclusive property of
//	Sunnnorth Technology Co. And shall not be distributed, reproduced,
//	or disclosed in whole in part without prior written permission.
//	(C) COPYRIGHT 2003 SUNNORTH TECHNOLOGY CO.
//	ALL RIGHTS RESERVED
//	The entire notice above must be reproduced on all authorized copies.
//========================================================

//========================================================
//	工程名称:	ex1_A2000_Auto
//	功能描述:	《实验指导书》语音部分第一个实验
//				通过自动、手动两种方式播放两段语音资源
//	涉及的库:	CMacro1016.lib
//				sacmv26e.lib
//	组成文件:	main.c
//				hardware.asm,isr.asm
//				hardware.inc,a2000.inc
//				a2000.h,hardware.h
//	硬件连接:	DAC音频跳线短接
//	维护记录:	2005-09-12	v1.0
//
//========================================================

//========================================================
//	文件名称:	main.c
//	功能描述:	通过自动方式播放两段语音资源
//	维护记录:	2005-09-12	v1.0
//========================================================


#include "a2000.h"


#define	P_IOA_Data				(volatile unsigned int *)0x7000
#define	P_IOA_Buffer			(volatile unsigned int *)0x7001
#define P_IOA_Dir				(volatile unsigned int *)0x7002
#define P_IOA_Attrib			(volatile unsigned int *)0x7003
#define P_IOA_Latch				(volatile unsigned int *)0x7004
#define P_IOB_Data				(volatile unsigned int *)0x7005
#define P_IOB_Buffer			(volatile unsigned int *)0x7006
#define P_IOB_Dir				(volatile unsigned int *)0x7007
#define P_IOB_Attrib			(volatile unsigned int *)0x7008

#define P_INT_Ctrl				(volatile unsigned int *)0x7010
#define P_INT_Clear				(volatile unsigned int *)0x7011
#define P_Watchdog_Clear		(volatile unsigned int *)0x7012
#define P_SystemClock			(volatile unsigned int *)0x7013

#define C_IRQ3_KEY				(volatile unsigned int *)0x0080
#define C_IRQ3_EXT1				(volatile unsigned int *)0x0100
#define C_IRQ3_EXT2				(volatile unsigned int *)0x0200

#define P_Watchdog_Clear		(volatile unsigned int *)0x7012

void PlaySnd_Auto(unsigned int uiSndIndex,unsigned int uiDAC_Channel);
int i=0,			Volume_Index = 7;
//========================================================
//	语法格式:	int main(void)
//	实现功能:	调用语音播放函数,通过自动方式播放两段语音资源
//	参数:		无
//	返回值:	无
//========================================================

int main(void)
{
	
//	int off;							//关闭中断
//	int i;
										//设置IOA口为带下拉电阻的输入
	*P_IOA_Dir = 0x0000;
	
	*P_IOA_Attrib = 0x0000;
	
	*P_IOA_Data = 0x0000;

//	*P_INT_Ctrl = C_IRQ3_KEY;
	
		
	SACM_A2000_Initial(1);
	
	for(i=0;i<2;i++)
	{
		
		PlaySnd_Auto(i,1);				//调用播放程序,播放第0段语音,采用DAC1播放
		
		
										//播放序号的列表在Resource.asm文件的最后的表中定义
		*P_Watchdog_Clear = 0x0001;
	}

}

//=====================================================================		//
//	语法格式:	void PlaySnd_Auto(unsigned int uiSndIndex,unsigned int 		//
																			//
																			//
//	实现功能:	通过自动方式播放语音资源									//
//	参数:		1.uiSndIndex:语音资源序号 2.uiDAC_Channel:语音播放通道	//
//	返回值:	无															//
//====================================================================		//


void PlaySnd_Auto(unsigned int uiSndIndex,unsigned int uiDAC_Channel)
{
	int a,temp;
	
								//初始化语音播放,自动方式
	
	
	SACM_A2000_Play(uiSndIndex,uiDAC_Channel,3);	//播放语音
	
	do{
	
	
	do{
	
	
	temp=*P_IOA_Data;
	
	if((SACM_A2000_Status() & 0x0001)!= 0)		//判断当前是否在播放?返回最低位为1则表示当前在播放
	{
		
		SACM_A2000_ServiceLoop();					//服务程序
		
		*P_Watchdog_Clear = 0x0001;			
	
	}
	
	else  	{SACM_A2000_Stop();	break;}
	
	
	}while(*P_IOA_Data==temp);
	

	
	
	
	
	if((SACM_A2000_Status() & 0x0001) != 0)		//判断当前是否在播放?返回最低位为1则表示当前在播放
	{
		
			
		SACM_A2000_ServiceLoop();					//服务程序
		
		
		if((*P_IOA_Data & 0x0001) == 0x0001)
		{	
			//	while((*P_IOA_Data & 0x0001)!= 0x0000)
					
				*P_Watchdog_Clear = 0x0001;
				
				Volume_Index++;
				
				if(Volume_Index>15)	Volume_Index=15;
				
				SACM_A2000_Volume(Volume_Index);
			
		}
		
		
	
	else if((*P_IOA_Data & 0x0002) == 0x0002)
		{
			//	while((*P_IOA_Data & 0x0002)!= 0x0000)
					
				*P_Watchdog_Clear = 0x0001;	
				Volume_Index--;
				if(Volume_Index<=0)	Volume_Index=0;
				SACM_A2000_Volume(Volume_Index);
				
		}
		
		
		else if((*P_IOA_Data & 0x0004) == 0x0004)
			
			SACM_A2000_Stop();
		
		else if((*P_IOA_Data & 0x0008) == 0x0008)
			
			SACM_A2000_Pause();
		
		else if((*P_IOA_Data & 0x0010) == 0x0010)
			
			SACM_A2000_Resume();
		
		
		else if((*P_IOA_Data & 0x0020) == 0x0020)
		{
				
				//while((*P_IOA_Data & 0x0020)!= 0x0000)
				
				
				*P_Watchdog_Clear = 0x0001;	
				
				uiSndIndex++;
				
				if(uiSndIndex>=3) uiSndIndex=0;
				
				SACM_A2000_Play(uiSndIndex,uiDAC_Channel,3);
				
				SACM_A2000_Stop();
				
				SACM_A2000_ServiceLoop();
				
				*P_Watchdog_Clear = 0x0001;
			
		}
		
		else if((*P_IOA_Data & 0x0040) == 0x0040)
		{
				
				
			//	while((*P_IOA_Data & 0x0040)!= 0x0000)
					
				*P_Watchdog_Clear = 0x0001;	
				uiSndIndex--;
				
				if(uiSndIndex<0) uiSndIndex=2;
				
				SACM_A2000_Play(uiSndIndex,uiDAC_Channel,3);
				
				SACM_A2000_Stop();
				
				SACM_A2000_ServiceLoop();
				
				*P_Watchdog_Clear = 0x0001;
			
		}
	
		
	
		*P_Watchdog_Clear = 0x0001;
	
			
	}
}while((SACM_A2000_Status() & 0x0001) != 0);
	
	




SACM_A2000_Stop();								//停止



}

⌨️ 快捷键说明

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