📄 main.c
字号:
/******************************************************************************
efsl Demo-Application for Philips LPC2138 ARM7TDMI-S
Copyright (c) 2005
Martin Thomas, Kaiserslautern, Germany <mthomas@rhrk.uni-kl.de>
Ported to keil by M.ceyhan mail:mukadder_c@yahoo.com
*****************************************************************************/
#include <string.h>
#include "main.h"
#include "LPC213x.h"
#include "lpc_config.h"
#include "efs.h"
#include "ls.h"
#include "mkfs.h"
#include "lpc2000_dbg_printf.h"
#define rprintf lpc2000_debug_printf
#define BAUD 115200
//#define BIT(x) ((unsigned long)1<<x)
// 1st LED on Keil MCB2130
#define LED1PIN 16
#define LED1BIT BIT(LED1PIN)
#define LEDDIR IODIR1
#define LEDSET IOSET1
#define LEDCLR IOCLR1
static char LogFileName[] = "logdatA.txt";
EmbeddedFileSystem efs;
EmbeddedFile filer, filew;
DirList list;
unsigned short e;
unsigned char buf[513];
int main(void)
{
unsigned char res;
if ( ( res = efs_init( &efs, 0 ) ) != 0 )
{
rprintf("failed with %i\n",res);
}
else
{
ls_openDir( &list, &(efs.myFs) , "/");
while ( ls_getNext( &list ) == 0 )
{
list.currentEntry.FileName[LIST_MAXLENFILENAME-1] = '\0';
rprintf( "%s ( %li bytes )\n" ,
list.currentEntry.FileName,
list.currentEntry.FileSize ) ;
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 )
{
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
//uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
if ( file_fopen( &filew, &efs.myFs , LogFileName , 'a' ) == 0 ) {
rprintf("File %s open for append. Appending...", LogFileName);
strcpy((char*)buf, "Martin hat's angehaengt\r\n");
if ( file_write( &filew, strlen((char*)buf), buf ) == strlen((char*)buf) ) {
rprintf("ok\n");
}
else {
rprintf("fail\n");
}
file_fclose( &filew );
}
if ( file_fopen( &filer, &efs.myFs , LogFileName , 'r' ) == 0 ) {
rprintf("File %s open. Content:\n", LogFileName);
while ( ( e = file_read( &filer, 512, buf ) ) != 0 ) {
buf[e]='\0';
//uart1Puts((char*)buf);
}
rprintf("\n");
file_fclose( &filer );
}
fs_umount( &efs.myFs ) ;
}
while(1);
}
////////////////////////////////////////////////////////////////////////
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -