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

📄 main.c

📁 凌阳单片机的语音程序5
💻 C
字号:
/*****************************************************************************/
//主程序(MAIN.C):
/*****************************************************************************************
Program: SACM-A2000, SACM-S480,S720的播放实验

使用函数的调用:
System_Initial();用于Hardware、Keyboard scan的初始化,见 system.asm
System_ServiceLoop();           


Sunplus Function call:
int SP_GetCh();
Return values of SP_GetCh():                
{0x00,0x01,0x02,0x04,0x08,0x10,0x20,0x40,0x80}
// DATA:2003/05/14
// IDE: 1.8.0
        
*****************************************************************************************/
#include "hardware.h"


#define Disable             0
#define Enable              1

#define 	A2000			1					// SACM-A2000
#define		S480_720		2					// SACM-S480/S720

#define 	Max_Volume      15                    // 最大音量
#define 	Min_Volume		0					  // 最小音量

#define 	Max_Num_A2000 	3		              // 定义A2000播放的最大语音数
#define 	Max_Num_S480	2	               	  // 定义S480播放的最大语音数

#define		Manual			0
#define		Auto			1

unsigned int	Ret = 0;                           // 定义子程序返回值
unsigned int    SpeechType = 1;		               // 设置A2000
unsigned int 	Key = 0;			               // 定义存储器键值
int main() 
{              
	unsigned int Index_A2000 = 0;
	unsigned int Index_S480 = 0; 

    int Volume_A2000 = 8;
    int Volume_S480 = 8; 
   	int	State = 0;                
 	SpeechType = 0;		               
	System_Initial();							
	while(1)
	{                                                  // 主程序由C来实现
         Key = SP_GetCh();
         switch(Key) 
         {
            case 0x00:
            	break;
            case 0x01:
            	SACM_S480_Stop();
				SpeechType = SACM_A2000_Initial(Auto);	//Speech=1 or 2;		 
				Set_SpeechType(SpeechType);             //设置语音的类型					
                SACM_A2000_Play(Index_A2000,DAC1+DAC2,Ramp_UpDn_On);				 
	            Index_A2000++;
	            if(Index_A2000 == Max_Num_A2000) 
	            	Index_A2000 = 0;
	            F_ClearWatchdog();            //清看门狗        
            	break;
            case 0x02:
            	SACM_A2000_Stop();
				SpeechType = SACM_S480_Initial(Auto);			 
				Set_SpeechType(SpeechType);	//设置语音的类型					
                SACM_S480_Play(Index_S480,DAC1+DAC2,Ramp_UpDn_On);					 
	            Index_S480++;
	            if(Index_S480 == Max_Num_S480) 
	                Index_S480 = 0;
	               F_ClearWatchdog() ;            //清看门狗      
                break;
            case 0x04:
            	switch(SpeechType)
	            {
					case 1:
						SACM_A2000_Pause();
				        break;
				    case 2:
				        SACM_S480_Pause();
					    break;
				}
				F_ClearWatchdog() ;            //清看门狗      
				break;
            case 0x08:
            switch(SpeechType)
	            {
					case 1:
						SACM_A2000_Resume();
				        break;
				    case 2:
				        SACM_S480_Resume();
					    break;
				}
			    F_ClearWatchdog() ;            //清看门狗      
            	break;
            case 0x10:
            	switch(SpeechType)
	            {
					case A2000:
						Volume_A2000++;
						if(Volume_A2000 > Max_Volume)
                            Volume_A2000 = Max_Volume;
            			SACM_A2000_Volume(Volume_A2000);
				        break;
				    case S480_720:
				        Volume_S480++;
					    if(Volume_S480 > Max_Volume)
                            Volume_S480 = Max_Volume;
				        SACM_S480_Volume(Volume_S480);
					    break;
					    
				}
                break;
            case 0x20:
				switch(SpeechType)
				{
					case A2000:               //A2000类型的播放
						if(Volume_A2000 > Min_Volume) 
							Volume_A2000--;
						SACM_A2000_Volume(Volume_A2000);
				    	 break;
				    case S480_720://S480类型的播放
				        if(Volume_S480 > Min_Volume)
                            Volume_S480--;
				        SACM_S480_Volume(Volume_S480);
					    break;
				}
                break;
            case 0x40:      						// 播放下一首
            case 0x80:      						// 播放前一首
			default:
				break;
        }
   		Ret = System_ServiceLoop();    //调用键扫描服务循环函数
		switch(SpeechType)
		{   
			case A2000:
				SACM_A2000_ServiceLoop();// A2000的自动播放与停止	
				break;
			case S480_720:				
				SACM_S480_ServiceLoop();// S480的自动播放与停止
				break;
		}	
				
     }
     F_ClearWatchdog() ;            //清看门狗      
     return 0;
}
 

⌨️ 快捷键说明

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