📄 main.c
字号:
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
// FAT32 File IO Library for AVR
// V0.1c
// Rob Riglar
// Copyright 2003,2004
//
// Email: rob@robriglar.com
//
// Compiled with Imagecraft C Compiler for the AVR series
//-----------------------------------------------------------------------------
//
// This file is part of FAT32 File IO Library.
//
// FAT32 File IO Library is free software; you can redistribute it and/or modify
// it under the terms of the GNU General Public License as published by
// the Free Software Foundation; either version 2 of the License, or
// (at your option) any later version.
//
// FAT32 File IO Library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
// GNU General Public License for more details.
//
// You should have received a copy of the GNU General Public License
// along with FAT32 File IO Library; if not, write to the Free Software
// Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
//-----------------------------------------------------------------------------
//-----------------------------------------------------------------------------
#include <iom128.h>
#include <stdio.h>
#include <stdlib.h>
#include <macros.h>
#include <string.h>
#include "drivers\drivers.c"
#define debug 0
// IDE Includes
#include "ide\IDE_BoardSetup.h"
#include "ide\IDE_Base.h"
#include "ide\IDE_Base.c"
#include "ide\IDE_Access.h"
#include "ide\IDE_Access.c"
// FAT32 Includes
#include "FAT\FAT32_Definitions.h"
#include "FAT\FAT32_Base.h"
#include "FAT\FAT32_Base.c"
#include "FAT\FAT32_Access.h"
#include "FAT\FAT32_Access.c"
// File & Dir IO FAT32 Includes
#include "File-Dir-IO\FileString.h"
#include "File-Dir-IO\FileString.c"
#include "File-Dir-IO\fatmisc.h"
#include "File-Dir-IO\fatmisc.c"
#include "File-Dir-IO\DirSearchBrowse.h"
#include "File-Dir-IO\DirSearchBrowse.c"
// High level FAT32 functions
#include "filelib\filelib.h"
#include "filelib\filelib.c"
#include "general.c"
//-----------------------------------------------------------------------------
// Main
//-----------------------------------------------------------------------------
void main(void)
{
UI32 tempclus;
byte keyinput;
int y=2;
int i;
// Init UART1
InitUART(15); // 15 = 57K @ 14MHz
// Display Startup Message
DisplayTag();
// Make RAM inactive
SET_RAM_CS;
SET_RAM_ALE;
// IDE Hard Disc Master Initialisation
IDE_Reset(); // Reset IDE device
delay_ms(500); // Wait
IDE_InitDrive(); // Send initialise commands to drive
// Load FAT Parameters
FAT32_LoadFAT();
while (1) // Main Menu
{
printf("\r\nATA Hard Drive Controller Menu\r\n");
printf("1. Browse Root Dir\r\n");
printf("2. Open File named\r\n");
printf("3. Get byte of file incremental\r\n");
printf("4. Display FAT details\r\n");
printf("5. Dump current sector\r\n");
printf("6. Browse a named dir\r\n");
keyinput = ReceiveByte();
if (keyinput=='1') ListDirectory(2);
if (keyinput=='2')
{
tempclus = fopen("C:\\Kosheen - Kokopelli\\Kosheen - wasting My Time.mp3");
printf("\r\nReading file C:\\Kosheen - Kokopelli\\Kosheen - Wasting My Time.mp3");
printf("\r\nFile Cluster is 0x%lx", tempclus );
printf(" 0x%X ", fgetc());
}
if (keyinput=='3') printf(" 0x%X ", fgetc());
if (keyinput=='4') ShowFATDetails();
if (keyinput=='5')
{
for (i=0; i<512;i++)
{
printf("0x%X ", IDE_SectorByte(i));
}
}
if (keyinput=='6')
{
tempclus = fopenDIR("C:\\Kosheen - Kokopelli");
printf("\r\nDir cluster is 0x%lx", tempclus );
if (tempclus) ListDirectory(tempclus);
}
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -