資源簡(jiǎn)介
上次 硬盤MP3播放器 的原理圖及源代碼改進(jìn)版
經(jīng)過(guò)一段時(shí)間的使用,上次的硬盤MP3播放器增加了USB下載文件功能;
漢字LCD顯示功能;子文件夾功能等。并對(duì)軟件做了一些修改。并將
硬件電路圖畫出來(lái)了。由于做得倉(cāng)促,難免有不妥之處,請(qǐng)大家諒解,
歡迎指出錯(cuò)誤。謝謝。
現(xiàn)在情況如下:
支持FAT32,F(xiàn)AT16/12還未做。
支持USB下載文件功能,速度300KB/S左右(USB1.1)。
無(wú)錄音功能。
7.5*2個(gè)漢字LCD顯示功能,能顯示歌曲名,路徑名(滾動(dòng)顯示)
支持多個(gè)文件夾功能。
有前后選曲、暫停、軟件音量、高、中、低音控制,重低音音效等功能。
無(wú)軟關(guān)機(jī)功能,現(xiàn)在拔電源操作^_^。
軟件還在完善中,有一些bug。

代碼片段和文件信息
/************************************************************************************
??本程序僅供廣大電子愛(ài)好者制作MP3學(xué)習(xí)和參考使用,不得用于其它用途,否則后果自負(fù)
??
??file_system.c?file
??Created?by?Computer-lov.?Date:?2005.3.19
??Last?edited?date:?2005.5.31
??version?1.1
??Copyright?(c)?2005?Computer-lov
??All?rigths?reserved
*************************************************************************************/
#include?“file_system.h“
#include?“IDE.H“
#include?“hardware.h“
#include?“l(fā)cd.h“
#include?“mp3.h“
#include?“keyboard.h“
FILE?xdata?file;
unsigned?int?dir_length;?????//文件名長(zhǎng)度
unsigned?int?folder_length;??//文件夾名長(zhǎng)度
////////////////////////////////////??判斷是否為一個(gè)?MP3?文件???///////////////////////////////
unsigned?char?is_a_mp3_file(void)
{
?if((file.name[0]==0x00)||(file.name[0]==0xE5)||(file.name[0]==‘.‘))return?0;
?if(file.attribute==0x0F)return?0;??//此項(xiàng)目為長(zhǎng)文件名項(xiàng)目
?if(file.attribute?&?0x04)return?0;??//此文件為系統(tǒng)文件
?if(file.attribute?&?0x08)return?0;??//此項(xiàng)目為系統(tǒng)標(biāo)卷
?if(file.attribute?&?0x10)return?0;??//此項(xiàng)目為子目錄
?if((file.name[8]==‘M‘)&&(file.name[9]==‘P‘)&&(file.name[10]==‘3‘))return?1;
?else?return?0;
}
///////////////////////////////////////////////////////////////////////////////////////////////
unsigned?long?int?LAST_FAT_LBA;?
//最后一次讀取FAT時(shí)的邏輯塊地址,用來(lái)判斷本次讀取是否需要重新從硬盤中讀取,以加快速度
unsigned?int?disp_count=0;
unsigned?char?disp_time;
////////////////////////////////////////////////////////////////////////////////////////////////
unsigned?long?int?get_next_sector(void)??//根據(jù)當(dāng)前簇號(hào),獲取下一個(gè)扇區(qū)地址
{
?unsigned?long?int?LBA;
?unsigned??int?i;
?LBA=(file.next_cluster_number)/((dbr[driver_number].bytes_per_sectors)/4);??//計(jì)算扇區(qū)地址
?i=(file.next_cluster_number)*4-LBA*dbr[driver_number].bytes_per_sectors;?//計(jì)算偏移地址
?if(LAST_FAT_LBA!=LBA)??????????????????//如果數(shù)據(jù)不在FAT_buffer[]中,則需要重新讀取
??{
???LAST_FAT_LBA=LBA;
???LBA=LBA+FAT_start_sector[driver_number];
???read_IDE_FAT_sector(LBA);
??}
?((unsigned?char?*)&(file.next_cluster_number))[3]=FAT_buffer[i];
?i++;
?((unsigned?char?*)&(file.next_cluster_number))[2]=FAT_buffer[i];
?i++;
?((unsigned?char?*)&(file.next_cluster_number))[1]=FAT_buffer[i];
?i++;
?((unsigned?char?*)&(file.next_cluster_number))[0]=FAT_buffer[i];??//獲取下一簇號(hào)
?LBA=file.next_cluster_number-(dbr[driver_number].root_cluster_num);???????????????????????????????????//保存簇號(hào)
?LBA=LBA*(dbr[0].sectors_per_cluster)+DATA_start_sector[0];????????//轉(zhuǎn)換成扇區(qū)地址
//?IDE_LED=!IDE_LED;?????????????????????????????????????????????????//硬盤指示燈閃爍
?disp_time++;
?if(disp_time>3)
??{
???disp_time=0;?
???LCD_go_home();
???disp_count+=2;
???for(i=0;i<14;i++)write_LCD_data(((unsigned?char?*)dir_name)[(i+disp_count)%(dir_length+4)]);
??}??
?return?LBA;
}
////////////////////////////////////////////////////////////////////////////////////////////////
/////////////////////////////////////////////////??獲取文件夾的下一扇區(qū)地址??///////////////////
unsigned?long?int?get_dir_next_sector(void)
{
?unsigned?long?int?LBALBA2;
?unsigned?int?i;
?LBA=current_dir.curren
?屬性????????????大小?????日期????時(shí)間???名稱
-----------?---------??----------?-----??----
?????文件????????865??2006-03-02?23:11??MP3_OK\MP3.h
?????文件??????17650??2006-03-02?23:11??MP3_OK\file_system.c
?????文件??????14225??2006-03-02?23:11??MP3_OK\IDE.C
?????文件???????2767??2006-03-02?23:11??MP3_OK\Initial.c
?????文件???????1030??2006-03-02?23:11??MP3_OK\keyboard.c
?????文件???????4825??2006-03-02?23:11??MP3_OK\LCD.C
?????文件???????4930??2006-03-02?23:13??MP3_OK\main.c
?????文件???????7648??2006-03-02?23:11??MP3_OK\MP3.c
?????文件???????7809??2005-04-06?18:53??MP3_OK\MP32.c
?????文件??????25805??2006-03-02?23:11??MP3_OK\Usb.c
?????文件???????7872??2005-04-02?19:50??MP3_OK\AT89C51SND1C.h
?????文件???????1909??2006-03-02?23:11??MP3_OK\file_system.h
?????文件???????1197??2006-03-02?23:11??MP3_OK\hardware.h
?????文件???????5825??2006-03-02?23:11??MP3_OK\IDE.h
?????文件???????2259??2006-03-02?23:11??MP3_OK\Initial.h
?????文件????????635??2006-03-02?23:11??MP3_OK\Keyboard.h
?????文件????????845??2006-03-02?23:11??MP3_OK\LCD.H
?????文件???????2474??2005-06-17?19:07??MP3_OK\MASS_STORAGE.H
?????文件?????119327??2006-03-02?23:08??MP3_OK\UNICODE.H
?????文件???????6255??2005-06-17?19:06??MP3_OK\USB.H
?????文件???????2619??2005-05-31?18:09??MP3_OK\MP3.Uv2
?????文件????????161??2006-03-02?23:12??MP3_OK\MP3.plg
?????文件?????115079??2006-03-02?23:11??MP3_OK\MP3.M51
?????文件?????124125??2006-03-02?23:11??MP3_OK\MP3.hex
?????文件???????7794??2006-03-02?23:11??MP3_OK\main.LST
?????文件??????23821??2006-03-02?23:11??MP3_OK\main.OBJ
?????文件??????21704??2006-03-02?23:11??MP3_OK\IDE.LST
?????文件??????33689??2006-03-02?23:11??MP3_OK\IDE.OBJ
?????文件??????25563??2006-03-02?23:11??MP3_OK\file_system.LST
?????文件??????48589??2006-03-02?23:11??MP3_OK\file_system.OBJ
............此處省略17個(gè)文件信息
評(píng)論
共有 條評(píng)論