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

📄 main.c.bak

📁 基于AT89C51SND1C的MP3源代码
💻 BAK
字号:
#include <stdio.h>
#include <string.h>
#include "..\Inc\AT8xC51SND1.h"
#include "..\Inc\GLOBAL.h"
#include "..\Inc\CHIPSOURCE.h"
#include "..\Inc\COMMON.h"
#include "..\Inc\IDEIO.h"
#include "..\Inc\FAT.h"
#include "..\Inc\MP3DECODER.h"
#include "..\Inc\LCD.h"
//#include "..\Inc\USB.h"
//#include "mp3player.c"

#define DEFAULT_PARTITION			0


code Uchar Title[]="虫宝宝MP3 播放器";

void main(void)
{
	xdata WORD i,j=0;
	xdata BYTE function=0,m,n;
	xdata char filename[50];
	xdata Uint32 temp;

	P5=0;
	EA=1;
	
	//初始化
	InitPLL();
	InitUART();
	InitKEY();
//	InitTimer0();
	for(i=0;i<30000;i++);
	LCDInit();
	LCDPrint(0,Title);

	printf("IDE Init...");
	IDEInit(MainBuffer[0].DATA);
	printf("ok\n");

//	printf("%bd Drivers found!\n",IDE.Devices);
//	printf("Device 0 Total Sectors: %lu\n",IDE.IDEDevice[0].TotalSectors);
//	printf("Device 1 Total Sectors: %lu\n",IDE.IDEDevice[1].TotalSectors);

	IDESetCurrentDevice(IDE_DEVICE_MASTER);

//	InitUSB();

	FATInit();
	FATSetStorageMedia(FAT_MEDIA_TYPE_HDD);
	FATGetPartitions();
	printf("Total Partitions:%bd\n",StorageMedia.TotalPartitions);
	FATMountPartition(DEFAULT_PARTITION);
	if (FATErrorCode==0)
		printf("Mount Partition %bd OK\n",DEFAULT_PARTITION);
	else
	{
		printf("Mount Partition %bd Error\n");
		while(1);
	}

	m=0;

	while(1)
	{
		FATGetFileName(filename,&FAT.DirEntryPoint);
		printf("%s\n",filename);
		if (strcmp(filename,"mp3")==0||strcmp(filename,"MP3")==0) break;
		FATNextEntry(&FAT.DirEntryPoint);
	}
	FATChangeDirectory(&FAT.DirEntryPoint);
	printf("change to %s\n",filename);
	i=0;
	InitMP3Decoder();
	while(1)
	{
		FATGetFileName(filename,&FAT.DirEntryPoint);
		printf("%s\n",filename);
		m=strrpos(filename,'.');
		if (toupper(filename[m+1])=='M'&&toupper(filename[m+2])=='P'&&toupper(filename[m+3])=='3')
		{
			LCDClearLine(1);
			LCDPrint(0x10,filename);
			printf("Playing %s\n",filename);
			MP3.File=FATOpenFile(&FAT.DirEntryPoint);
			LoadMP3Data(MP3.File);
			printf("file loaded\n");
			while(MP3.Playing);
			FATCloseFile(MP3.File);
			printf("Next file\n");
		}
		FATNextEntry(&FAT.DirEntryPoint);
	}
}

⌨️ 快捷键说明

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