📄 dosread2.c
字号:
//###################################################################################
// File: dostest.c
//
// Liest mehrere Dateien auf dem CF bis zum Ende.
//
//#########################################################################
// Last change: 09.05.2004
//#########################################################################
// holger.klabunde@t-online.de
// http://home.t-online.de/home/holger.klabunde/homepage.htm
//#########################################################################
// Processor: ATMega32
//#########################################################################
// Compiler: AVR-GCC 3.2
//#########################################################################
#include <io.h>
#include <interrupt.h>
#include <sig-avr.h>
#include <stdarg.h>
#include <string.h>
#include <stdlib.h>
#include "mydefs.h"
#include "protos.h"
#include "../lcd.h"
#include "../dos.h"
//"volatile" f黵 alle Variablen die in Interrupt's ge鋘dert werden
unsigned int volatile countclock;
unsigned char buf[64];
//###################################################################################
// timeout not used !
// interrupt every 47.4ms @ 11.0592MHz
// interrupt every 32.77ms @ 16.0000MHz
SIGNAL(SIG_OVERFLOW1) // signal handler for timer1 overflow interrupt
//###################################################################################
{
countclock++;
}
void ReadFile(char *name)
{
unsigned char result;
// Eine Datei bis zum Ende lesen
result=fopen(name,F_READ);
if(result==F_OK)
{
do
{
if(fread(buf,64)!=64) result=F_ERROR;
}while(result==F_OK );
fclose();
}
}
//###################################################################################
/* Hauptprogramm */
int main(void)
//###################################################################################
{
DDRC=0xFF; // set io-pins on PortC
PORTC=0; //LCD-Datenbus
DDRD=0xF2; // set io-pins on PortD
PORTD=0x02; //LCD-Steuersignale siehe lcd.h
DDRA=0; //Alles Eing鋘ge
PORTA=0xFF; //Eing鋘ge mit Pullups setzen
#ifdef COMPACTFLASH_CARD
DDRB=0xFF; //Alles Ausg鋘ge
PORTB=0xFF;
#endif
#ifdef MMC_CARD_SPI
// DDRB=0b10111111;
DDRB=0xBF; //PB7=SCK,PB6=MISO,PB5=MOSI,PB4=MMC_CS,PB3..0 not used
PORTB=0x10;
#endif
SFIOR&=!(1<<PUD); //Pullups Enable
// SFIOR=0; //Pullups Enable
LCDInit();
//Timer1
TCCR1A=0;
TCCR1B=0x02; //Timer1 Start Takt = F/8 => 47.4ms at 11.059MHz
TIMSK=(1<<TOIE1); // enable timer1 int
sei(); //enable interrupts
LCDCls();
LCDWrite("FAT DOS-Read-Test2");
LCDPos(2,1);
LCDWrite("by Holgi");
Delay1ms(1000);
LCDCls();
if(GetDriveInformation()!=F_OK) // get drive parameters
{
LCDCls();
LCDWrite("Flash meldet sich nicht !");
while(1);
}
RED_ON();
GREEN_OFF();
countclock=0;
LCDPos(1,1);
LCDWrite("0.txt");
ReadFile("0.txt");
chdir("dir1");
LCDPos(1,1);
LCDWrite("1.txt");
ReadFile("1.txt");
chdir("dir3");
LCDPos(1,1);
LCDWrite("3.txt");
ReadFile("3.txt");
chdir("..");
chdir("..");
chdir("dir2");
LCDPos(1,1);
LCDWrite("2.txt");
ReadFile("2.txt");
chdir("dir4");
LCDPos(1,1);
LCDWrite("4.txt");
ReadFile("4.txt");
chdir("..");
chdir("..");
GREEN_ON();
RED_OFF();
cli(); // Disable interrupts
LCDPos(2,1);
ShowHex((unsigned char)(countclock>>8));
ShowHex((unsigned char)(countclock));
for(;;) // loop forever
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -