📄 dosread1.c
字号:
//###################################################################################
// File: dosread1.c
//
// Einen CF lesen dessen gesamter Speicher mit einer einzigen
// Datei belegt ist.
//
//#########################################################################
// Last change: 22.03.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++;
}
//###################################################################################
/* Hauptprogramm */
int main(void)
//###################################################################################
{
unsigned char result;
//DDRx
//1 is output
//0 is input
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-Test1");
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;
// Eine Datei bis zum Ende lesen
result=fopen("1.txt",F_READ);
if(result==F_OK)
{
do
{
if(fread(buf,64)!=64) result=F_ERROR;
}while(result==F_OK );
fclose();
}
GREEN_ON();
RED_OFF();
cli(); // Disable interrupts
LCDPos(1,1);
ShowHexLong(FilePosition);
LCDPos(1,20);
ShowHexLong(FileCurrentCluster);
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 + -