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

📄 main.c

📁 利用 SPCE061A 单片机、SPR 模组、液晶1602 制作音乐盒播放器
💻 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.
//========================================================

//========================================================
//	工程名称:	MusicBox.spj
//	功能描述:	实现音乐盒毕业设计礼包的功能
//	涉及的库:	CMacro1016.lib、SACMv26e.lib
//	组成文件:	main.c
//
//
//	硬件连接:	IOA0----Key1
//				IOA1----Key2
//				IOA2----Key3
//				Key-----5V
//				IOA8-IOA15----D0-D7(1602液晶)
//				IOB0----SCK(SPR模组)
//				IOB1----SDA(SPR模组)
//				IOB13----RS
//				IOB14----R/W
//				IOB15----EP
//
//	维护记录:	2005-12-14	v1.0  edit by liuxue(liuxue@sunnorth.com.cn)
//				20xx-xx-xx  v1.x  modify by xxxxxx(xxxxxx@sunnorth.com.cn)
//				
//========================================================

//========================================================
//	文件名称:	main.c
//	功能描述:	实现音乐盒的功能
//	维护记录:	2005-12-14	v1.0
//========================================================

#include "spce061a.h"
#include "a2000.h"
#include "key.h"
#include "spr4096_user.h"
#include "speech.h"
#include "lcd1602_user.h"

unsigned int g_uiIndex = 0;							// 曲目索引
unsigned int g_uiData[5] = {'1','2','3','4','5'};	// LCD1602的字模显示
void Stop_Dis(void);								// 在停止的时候的显示函数

//========================================================
//	语法格式:	int main(void)
//	实现功能:	MusicBox.spj工程主函数
//	参数:		无
//	返回值:	无
//========================================================

int main(void)
{
	unsigned int uiKey;		// 判断键值
	unsigned int uiStatus;	// 音乐播放盒现在的状态	0,处于暂停/停止状态;1,处于播放状态
	unsigned int uiInt;
	uiStatus = 0;			// 初始化,停止状态

	Key_Init();				// 初始化键盘
	LCD1602_Initial();		// 初始化液晶1602
	SP_SIOInitial();		// 初始化SIO
	
	while(1)
	{
		Stop_Dis();						// 停止时显示
		uiKey = Key_Get();				// 获得键值
		switch(uiKey)
		{
			case KEY_1:
				uiInt = *P_INT_Ctrl;	// 打开8Hz中断,在中断中调用均衡器效果函数
				uiInt |= C_IRQ6_TMB1;
				*P_INT_Ctrl = uiInt;
				uiStatus = 1;			// 开始播放音乐
				break;
			case KEY_2:
				g_uiIndex++;			// 下一曲
				if(g_uiIndex == 5)		// 5首曲目,序号重0到4
				{
					g_uiIndex = 0;
				}
				break;
			case KEY_3:
				g_uiIndex--;			// 上一曲
				if(g_uiIndex == 0xffff)	// 无符号数,0下来是0xffff
				{
					g_uiIndex = 4;
				}
				break;
			case KEY_1_THREE:
				break;
			case KEY_2_THREE:
				break;
			case KEY_3_THREE:
				SACM_A2000_Stop();		// 停止播放
				g_uiIndex = 0;			// 重新初始化
				uiStatus = 0;			// 重新初始化
				break;
			default:
				break;
		}
		if(uiStatus == 1)
		{
			PlaySnd_A2000();
		}
		else
		{
			SACM_A2000_Stop();
		}
		*P_Watchdog_Clear = 0x0001;
	}
	
	while(1)
	{
		*P_Watchdog_Clear = 0x0001;
	}
}

void Stop_Dis(void)
{
	Write_Command(0x0080);				// 显示菜单
	Write_Data('P');					// PRESS KEY1 START
	Write_Data('R');
	Write_Data('E');
	Write_Data('S');
	Write_Data('S');
	Write_Data(' ');
	Write_Data('K');
	Write_Data('E');
	Write_Data('Y');
	Write_Data('1');
	Write_Data(' ');
	Write_Data('S');
	Write_Data('T');
	Write_Data('A');
	Write_Data('R');
	Write_Data('T');
	
	Write_Command(0x00c0);				// 在下一行显示
	Write_Data('K');					// K2 N K3 L
	Write_Data('2');
	Write_Data(' ');
	Write_Data('N');
	Write_Data(' ');
	Write_Data('K');
	Write_Data('3');
	Write_Data(' ');
	Write_Data('L');
	Write_Data(' ');
	Write_Data('N');
	Write_Data('O');
	Write_Data('.');
	Write_Data(g_uiData[g_uiIndex]);	// 显示曲目
	Write_Data('/');
	Write_Data('5');
}

⌨️ 快捷键说明

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