📄 main.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.
//=======================================================================
//============================================================
// 工程名称: two.spj
// 功能描述: A2000/S480/s240格式混合播放
// 文件来源:《实验仪实验指导书》,"实验三十一 SACM_A2000与S480/S720混合播放" 第114页
// IDE环境: SUNPLUS u'nSPTM IDE 1.8.4
//
// 涉及的库:
// 组成文件:
// main.c isr.asm hardware.asm sacmv25.lib
//===============================================
//============================================================
// 文件名称:main.c
// 实现功能: A2000/S480/s240格式混合播放
//============================================================
#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 1 // 定义A2000播放的最大语音数
#define Max_Num_S480 1 // 定义S480播放的最大语音数
#define Manual 0
#define Auto 1
unsigned int Ret = 0; // 定义子程序返回值
unsigned int SpeechType = 1; // 设置A2000
unsigned int Key = 0; // 定义存储器键值
//=============================================================
// 函数名称: main()
// 功能描述: A2000/S480/s240格式混合播放
// 语法格式: main()
//入口参数: 无
// 出口参数: 无
// 注意事项: 仅为用户模型
//=============================================================
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:
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 0x01:
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 0x02:
switch(SpeechType)
{
case 1:
SACM_A2000_Pause();
break;
case 2:
SACM_S480_Pause();
break;
}
F_ClearWatchdog() ; //清看门狗
break;
case 0x03:
switch(SpeechType)
{
case 1:
SACM_A2000_Resume();
break;
case 2:
SACM_S480_Resume();
break;
}
F_ClearWatchdog() ; //清看门狗
break;
case 0x04:
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 0x05:
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 0x06: // 播放下一首
//case 0x07: // 播放前一首
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 + -