📄 dosmkdir1.c
字号:
//###################################################################################
// File: dosmkdir1.c
//
// Erster Test Verzeichnisse auf einem CF erstellen.
//
//#########################################################################
// 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;
//###################################################################################
// 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++;
}
//###################################################################################
unsigned char WriteTestFile(char *name)
//###################################################################################
{
unsigned char result;
unsigned long bytecount;
bytecount=0;
result=fopen(name,F_WRITE);
if(result==F_OK)
{
do
{
if(fwrite("Hello World. Hello World. Hello World. Hello World.\n",52)!=52) result=F_ERROR;
if(result!=F_ERROR) bytecount+=(unsigned long)52;
}while(bytecount < (unsigned long)250000 && result==F_OK );
fclose();
}
return result;
}
//###################################################################################
/* 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-MKDIR-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();
mkdir("test1");
chdir("test1");
mkdir("test2");
chdir("test2");
mkdir("test3");
WriteTestFile("hello.txt"); //write hello.txt in /test1/test2 !!!
GREEN_ON();
RED_OFF();
cli(); // Disable interrupts
for(;;) // loop forever
{
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -