📄 main.c
字号:
/****************************************************************************
file name: main.c
****************************************************************************/
//***************************************************************************
//#include <stdio.h>
//#include <stdarg.h>
#include "option.h"
#include "44b.h"
#include "def.h"
#include "44blib.h"
#include "debug.h"
#include "drivers.h"
#include "ide_include.h"
#include "fat_include.h"
volatile char which_int=0;
void ShowFATDetails(void)
{
s3c44b0x_Printf("\r\nCurrent Disc FAT details\r\n------------------------\r\nRoot Dir First Cluster = ");
s3c44b0x_Printf("0x%x",FAT32.RootDir_First_Cluster);
s3c44b0x_Printf("\r\nFAT Begin LBA = ");
s3c44b0x_Printf("0x%x",FAT32.fat_begin_lba);
s3c44b0x_Printf("\r\nCluster Begin LBA = ");
s3c44b0x_Printf("0x%x",FAT32.cluster_begin_lba);
s3c44b0x_Printf("\r\nSectors Per Cluster = ");
s3c44b0x_Printf("%d",FAT32.SectorsPerCluster);
s3c44b0x_Printf("\r\n\r\nFormula for conversion from Cluster num to LBA is;");
s3c44b0x_Printf("\r\nLBA = (cluster_begin_lba + ((Cluster_Number-2)*SectorsPerCluster)))\r\n");
s3c44b0x_Printf("\r\nMax LBA address on this drive is 0x%lx",IDE_Internal.maxLBA-1);
}
//-----------------------------------------------------------------------------
// Read an MP3 from the disc taking startcluster as start point
//-----------------------------------------------------------------------------
void MP3_Read(UI32 StartCluster)
{
// Vars Used
UI8 SectLast = 0;
UI32 CurrentSec = 0;
int i = 0;
int firstuse=1;
s3c44b0x_Printf("\r\nThe Content of the file is:");
do
{
SectLast = FATBuffer_SectorReaderBUFFERED(StartCluster, CurrentSec++,firstuse);
firstuse = 0;
if (!SectLast) // Dont play the last clustor !
{
for(i=0; i <= 511; i++)
{
s3c44b0x_putchar( IDE_SectorByte(i) ); // Retrieve byte from sector buffer
} // End of for
} // end of if
} // end of while
while (!SectLast); // Follow Clusters
s3c44b0x_Printf("\r\nEnd of File");
}
/****************************************************************************
【功能说明】系统主函数
****************************************************************************/
void Main(void)
{
int i;
rSYSCFG=SYSCFG_8KB; //使用8K字节的指令缓存
rNCACHBE0=(((unsigned int)(Non_Cache_End>>12))<<16)|(Non_Cache_Start>>12);
//在上面的数据区域不使用高速缓存
Port_Init(); //IO端口功能、方向设定
ChangePllValue(56,2,1); //修改系统主频为8倍频
Uart_Init(0,115200); //异步串行口初始化,设置波特率为115200
Uart_Select(0); //选择当前串口通道为COM0
// Display Startup Message
s3c44b0x_Printf("\r\nStarting Up 44b0x+IDE \r\n");
s3c44b0x_Printf( " ---------上海勤研电子 \n\r");
//calibrate time
s3c44b0x_Printf("Starting Calibrate Second timer...\r\n");
for(i=0;i<10;i++)
{
s3c44b0x_Printf(" %d second \r\n",i);
delay_ms(1000);
}
// IDE Hard Disc Master Initialisation
s3c44b0x_Printf("\r\n<-----Hard Disc Initialisation Begin----->");
IDE_Reset(); // Reset IDE device
IDE_InitDrive(); // Send initialise commands to drive
// Load FAT Parameters
FAT32_LoadFAT();
ShowFATDetails();
ListDirectory(0x02);
#ifdef DEBUG_LV1_ON
i = FAT32_fopenDIR("C:\\KERNEL\\MM");
DEBUG_OUT("\r\n OPEN file....StartCluster is 0x%4x",i);
ListDirectory(i);
#else
ListDirectory(FAT32_fopenDIR("C:\\KERNEL\\MM"));
#endif
MP3_Read(FAT32_fopen("C:\\KERNEL\\MM\\Makefile"));
s3c44b0x_SysHalt();
}
//***************************************************************************
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -