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

📄 main.c

📁 spce061单片机的一些程序!C语言和汇编语言都有
💻 C
字号:
//======================================================================================
//
//        The information contained herein is the exclusive property of
//      Sunplus Technology Co. And shall not be distributed, reproduced,
//      or disclosed in whole in part without prior written permission.
//
//            (C) COPYRIGHT 2001   SUNPLUS TECHNOLOGY CO.
//                           ALL RIGHTS RESERVED
//
//    The entire notice above must be reproduced on all authorized copies.
//
//========================================================================================
//  工程名称: a2000.spj
//  功能描述:  SACM-A2000按键控制
//				
//  文件来源: 《SPCE061单片机原理及应用技术》第七章 凌阳音频压缩算法,第301页
//  IDE环境:  	SUNPLUS u'nSPTM  IDE 1.8.0(or later)
//
//  涉及的库:	CMacro.lib/sacmv25.lib
//
//  组成文件:	main.c
//    	 		ISR.asm/hardware.asm/key.asm
//	            hardware.inc
//     	
//  日期:       2002-6-12
//===========================================================================================
#include "hardware.h"
#define Disable			0
#define Enable			1

#define MaxSpeechNum	1							// 最大播放语音数目
#define MaxVolume		15							// 最大音量

#define Manual			0
#define Auto			1


int	Ret = 0;										// 子程序返回值
	
extern unsigned long	RES_A32_SA, RES_A32_EA;	
long Addr;
	

main()
	{
		int Key = 0;									// 初始化键值
		int SpeechIndex = 0;							// 初始化语音目录索引号
		int VolumeIndex = 7;							//初始化音量
		Ret = System_Initial();
		Ret = SACM_A2000_Initial(Auto);	
		SACM_A2000_Play(SpeechIndex,DAC1+DAC2,Ramp_UpDn_On);		//播放	
		while(1)
	{		
		Key = SP_GetCh();
		switch(Key)
{	
		case 0x00:
		  break;
		case 0x01:
		  SACM_A2000_Play(SpeechIndex,DAC1+DAC2, Ramp_UpDn_On);   // 播放
		  break;
		case 0x02:
		  SACM_A2000_Stop();				    		//停止放音
		  break;
		case 0x04:
		  SACM_A2000_Pause();				    		//暂停放音
		  break;
	    case 0x08:
		  SACM_A2000_Resume();							// 暂停后的恢复
		  break;
		case 0x10:						
		  VolumeIndex++;				
		  if(VolumeIndex > MaxVolume)
		  VolumeIndex = MaxVolume;
		  SACM_A2000_Volume(VolumeIndex);	     		//音量增加		
		  break;		
		case 0x20:	
		  if(VolumeIndex == 0)
		  VolumeIndex = 0;
		else
		  VolumeIndex--;	
		  SACM_A2000_Volume(VolumeIndex);	     		//音量减
		  break;			
		case 0x40:	
		  SpeechIndex++;								// 播放下一首
		  if(SpeechIndex == MaxSpeechNum) 
		  SpeechIndex = 0;
		  SACM_A2000_Play(SpeechIndex,DAC1+DAC2, Ramp_UpDn_On);
		  break;		
		case 0x80:	
		  if(SpeechIndex == 0) 							//播放前一首
		  SpeechIndex = MaxSpeechNum;
		  SpeechIndex--;
		  SACM_A2000_Play(SpeechIndex,DAC1+DAC2, Ramp_UpDn_On);			
		  break;			
		default:
		 break;
	 }
		System_ServiceLoop();			     			//调用系统初始化
		SACM_A2000_ServiceLoop();						// 获取A2000资料并填入译码队列等待播放
}		
}		

⌨️ 快捷键说明

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