|
EDA365欢迎您!
您需要 登录 才可以下载或查看,没有帐号?注册
x
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK STM32F103工程。下载即可使用。
( v f, [5 d8 |* y, e/*----------------------------------------------------------------------------/, e( _! z5 f s# l0 R6 K
/ FatFs - FAT file system module R0.09 (C)ChaN, 2011
6 M4 U+ x6 F' N7 b4 q3 N6 Y/-----------------------------------------------------------------------------/: V7 ~/ m w2 V
/ FatFs module is a generic FAT file system module for small embedded systems." I& P9 B- t' x: o: ~; h! ?
/ This is a free software that opened for education, research and commercial
+ B* c3 i. c; M: S$ G- o/ developments under license policy of following terms.
1 U: s+ {5 r/ `5 }! T/ l$ I/
- ~# d$ `& q. @. }3 V" g/ V/ Copyright (C) 2011, ChaN, all right reserved.
+ s: V, M4 B F% V/
- \4 ?( C3 Z! j/ * The FatFs module is a free software and there is NO WARRANTY.
6 X; \4 i, [5 U# b( {6 { n* X! H: R/ * No restriction on use. You can use, modify and redistribute it for6 h# S+ e+ t( ]0 ~+ j' P
/ personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.! m: x: f8 z" Z' J0 N8 L$ e
/ * Redistributions of source code must retain the above copyright notice.
6 o: H8 y# Z r/9 R9 t+ \* X1 \" z
/-----------------------------------------------------------------------------/3 h( [- O4 i1 B. }% E
7 s# }: M! M9 a5 a5 x
$ c9 e( T" c' Y1 T/*--------------File Info-------------------------------------------------------
- h* }+ O( c, a+ z3 w** 文 件 名: FATFS_Function.c
( M$ s# I" c4 x$ A/ F** 作 者:~风中的叶~ 整理+ a7 j( n, U5 M( M U4 {# ?
** 最后修改日期: 2012.01.18
$ G! ]. w8 J5 E$ s** 版 本: V1.0
6 z. n, O$ d- c' p+ {1 T8 A) Y** 描 述: FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出: V6 V) ]0 k \; g( t0 C* x7 P
**------------------------------------------------------------------------------1 Y r' X4 E4 q5 Z4 {( `' w0 |
** Created by: Dt.
( C( ?4 f7 a, U2 Y- \0 j** Created date: 0 K: a6 w8 ?' v. p
*******************************************************************************/ : O, q3 M1 p7 z
#include "TEST_FATFS.h" j1 `0 O0 x, m9 N
#include "string.h"
. K2 j N; v5 o0 {& Y7 @/ ~# z4 t! M& U0 ?1 l2 b4 T. x
#ifdef TEST_FATFS_EN I2 [8 h3 }, R6 k. K
; a# V4 X3 ^! `" B
. l8 U7 M6 F, P
' n( h3 S) |2 @( w4 \5 _
//检测磁盘是否插好/ t1 @4 H& L4 t4 q5 ~1 v
BOOL disk_detect_OK(void)
; c: I7 r4 f ?. E2 ~* N$ F{
, T- h3 X6 V0 Q! K4 [1 ~4 Z* G8 K, f1 y if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
4 P4 D9 Q9 o1 F8 r0 c {. J7 [ }/ m& `7 g2 m
printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
0 k; A* }9 c1 j+ j: c# W( r return FALSE;
0 x+ B2 s$ c* ~1 e }2 G/ m+ p# {3 \$ t( S' n- A
return TRUE;, ^% N. K) ~0 C7 \9 l
}
! s1 N2 X+ k; y( C9 z! [; i5 ^; |0 b1 _. e8 G
& s1 K$ S; z- q/ V
( _. H$ h% m) Y6 ]1 K//测试函数执行结果分析4 X5 H0 \3 s) R$ E
void die(FRESULT res)1 z8 J6 f& f3 N/ Y
{% ^- E9 z' W3 j3 {; H
switch(res)
. [5 D( D W6 ]0 h4 I( O r0 W& n {
9 l K+ r0 O' x# X, s1 H" d case FR_OK: //The function succeeded.
7 p2 r1 y- Z: @( w' v7 a; T4 U4 w {. x* N& b) n! T6 w8 g* R2 y
printf("\r\nThe function succeeded!\r\n");2 V" t8 ], G9 T
break;
: _+ n+ Z" K- ~1 S; H5 y }
5 |0 \$ \! s$ s" g8 u case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
( A, d+ p r# a/ Z {. J. H8 E; E a- r
printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");% ^7 V, i8 D3 T1 M9 ~; [8 I4 @* R
break;
$ n: O ~ E2 Q! C3 M$ W2 p }) Q2 A+ O2 ^; c8 i) q4 o
case FR_NO_FILE://Could not find the file.) d& }5 Z8 l& f P9 `6 J/ y4 ?
{) n) Y& J% E! Q0 r b* w/ A! G! b
printf("\r\nCould not find the file!\r\n");" _) ~$ ~" @- W9 w; X
break;
) A8 X/ t" n3 A6 t3 f3 J# m7 m }
. f8 c6 S1 G4 z case FR_NO_PATH://Could not find the path5 E; _! _0 t0 W2 `0 n
{
, \6 a) ~ R# t% e# W printf("\r\nCould not find the path!\r\n");2 U5 [& G$ L" U7 J% ]4 T$ B- {
break;% C8 z& v) O) C- g( d
}/ Y: ~$ @! v w! _1 i0 ?% `8 o
case FR_INVALID_NAME://The path name is invalid" N4 Y$ j# ?+ `+ \" n4 G
{
9 l p4 E5 h/ o# Q/ ^$ _ printf("\r\nThe path name is invalid!\r\n");
6 q# l: w- [7 A$ I9 s break;3 L; Y: y3 J) W8 n0 Q' `
}2 N& Q" ]2 Y L9 @" ]* G
case FR_INVALID_DRIVE://The drive number is invalid
: W" `; Z& @$ {9 ` r# ~$ y! t {
3 ]/ h4 T" c5 U9 _) a printf("\r\nThe drive number is invalid!\r\n");
4 Q# i) Z p) U! u0 o break;7 V% j# ^! W$ Z4 _; @. t
}* F6 m% k+ l- `5 {4 q$ N
case FR_DENIED://The directory cannot be created due to directory table or disk is full.
! [9 O2 C/ x* `1 u) g2 C& W% V {% ]& i: N" _7 G4 e
printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
( C r2 o) B. n. b7 E break;+ t6 |% `4 P4 u, @
}9 c1 z( Q" G: C6 x
case FR_EXIST://A file or directory that has same name is already existing# `( G9 K% ]& m! E. C
{2 @9 ?: K5 w3 v# z# e( a7 \" Z, H0 N9 `
printf("\r\nA file or directory that has same name is already existing!\r\n");. f( ?, n5 A# j- O5 a
break;
$ _( Q: D3 P! ?: O1 Y) j }7 w3 d3 b: {( Q3 n2 }4 [& Z
// case FR_RW_ERROR://The function failed due to a disk error or an internal error
/ I# S, ]- I! z1 w/*
% Y& e0 @7 j$ T case FR_RW_ERROR://The function failed due to a disk error or an internal error/ L: w7 p$ y( k# _- I& c
{
! ^' g/ M9 ~: k printp("\r\nThe function failed due to a disk error or an internal error!\r\n");' H4 L, C# l, @1 D; C u
break;
( P! ~" _. M. ?6 S) k& O }
; B5 K7 W8 _+ @*/. \! @6 T9 G" X# E$ y9 a
case FR_WRITE_PROTECTED://The medium is write protected) L6 l2 e2 R; X5 d
{/ Q' r1 B- [. S) U
printf("\r\nThe medium is write protected!\r\n");
C$ G- \+ R! R6 ?1 F break;6 L1 x0 }; v! h" X9 u
}4 B% m% J. I& f; K1 w+ G4 y' `# C
case FR_NOT_ENABLED://The logical drive has no work area
3 D! v% T. M% H5 _3 h {% B% ^, W( L! n0 p
printf("\r\nThe logical drive has no work area!\r\n");
# V; S( \$ i0 a9 |+ L+ f( E1 J# K break;
7 D( |5 o" ^- Y9 }5 y6 i } U* w C& s4 }0 V
case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
2 ~6 W- V+ K5 q5 S u {
5 ~# s7 i* R3 ^4 Q, h- n8 o1 Z printf("\r\nThere is no valid FAT partition on the disk!\r\n");
: d1 z" W# p8 u9 g break;7 G; Q2 B' {, | X$ h9 |$ F6 \
}6 K8 S; N" F% G5 X4 X
case FR_INVALID_OBJECT://The file object is invalid' ]$ ]# j0 n6 U0 V4 G' _: R4 {
{7 G5 O: `, E. t0 D4 c$ G7 y
printf("\r\nThe file object is invalid!\r\n");" Q" y' V. F% D8 Z* N9 M
break;4 Z" ~0 F1 s2 h6 Y# ?
}% v. A* Q- O5 s$ K7 {
& ]5 z' k7 @5 J: d
//The function aborted before start in format due to a reason as follows. 9 w- X& \- r4 w1 h( o- T) x
//The disk size is too small. ' E) V# }( U6 d0 [7 `" m, I
//Invalid parameter was given to any parameter. + u% A( e0 a( O; L' S. ~
//Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
% u8 c0 t+ E z' `( D5 I" F- K) g case FR_MKFS_ABORTED://
7 q* c% ^" g4 C" R, x' R {
' n6 q& @9 T2 L" x; I printf("\r\nThe function aborted before start in format!\r\n");
: ^' Y) O% N$ V8 v! K. s% H) @ break;
# j! H5 n- ?5 S4 Z2 K; Z% j# v; f# D } H* ]: q9 G7 W/ |* a- p5 ]
4 f# N4 R; v' Q8 d$ F( _7 K
default:
% C0 ~6 `! a4 i {+ G l: V/ f5 a' c
printf("\r\nerror!\r\n");
; r" f3 { @! B( R break;
2 L e5 K: h# f+ ^( K1 K } / h- Q" O$ I1 a# R2 J
}
% J6 f- R; Q2 I6 i4 x$ i! T return;' N8 f8 E9 ^ I8 \& {" D9 A0 c
}
0 U% B, j5 P5 Y, @& i$ ?. Kvoid Test_f_getfree(void)//获取卡的总容量及剩余容量
- _7 z* S1 l* z2 [+ d; X8 y{
1 ]! |( b3 x2 t# Y/ T FATFS fs;' S6 w' ]- l: w4 u& a/ G$ Y
FATFS *pfs;. k' p6 L' C& o+ _3 z9 W5 l
DWORD clust;
! l& @ n" G1 }7 g" p' ^1 L( B0 d FRESULT res; // FatFs function common result code
8 Z3 @. x, N7 Y7 q( |- C* k) Q+ z# {0 A( o# f
//检测磁盘是否插好7 R1 _9 r# _9 T! Y" A% l6 z3 Y
if( disk_detect_OK()==FALSE ) return;1 L7 D# e# W5 i* E
" ]8 \8 _3 J2 D pfs=&fs;//指向
) d$ b9 v* f" r" @6 z; ` // Register a work area for logical drive 0, c7 e- X" [ a( W2 l# J9 s# J
f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间, q# [! J8 x W' Z. u
; s+ U2 H. o. V: U3 H
// Get free clusters
- P+ [; x! N0 F/ W res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
% d( F( X( l, P7 ]1 V) N if ( res==FR_OK ) * a! c& G2 t. R1 Q7 o, a3 z: E/ u
{) @ c& h& E$ h: C& x9 z
// Get free space
; A3 |3 Q& N9 J4 M/ b* k printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",6 D' ?; v3 R% g& G6 {3 L0 v
(DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
c8 [8 V3 M# N' [5 T7 T clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10249 f+ b: q! | N7 z
}
7 {* Y9 m& ]8 E' y) ~ else die(res);//测试函数执行结果分析% Q" j: [" ~6 l7 y) i3 L3 _
1 w' V, M @$ J! }/ S4 i! s# v // Unregister a work area before discard it/ y {3 W, q; J" ~/ F( p
f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间- ^( K8 _# w# z* ^3 D6 t$ W
}7 V1 r4 Q# U( p! v
$ Y$ f3 ?. v) C/ A' o& ~9 v
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误+ q; m; m& W4 T2 l9 E& s
{
/ C3 Z$ d9 \2 J! I5 _( G& @ Z FATFS fs; // Work area (file system object) for logical drive& k' s# \, ]1 n2 |8 a
FIL fsrc; // file objects/ p7 `- I: Z& `7 w
BYTE buffer[512]; // file copy buffer
! Y/ L1 q9 ^5 v1 z) H# _) ? FRESULT res; // FatFs function common result code
1 |- E/ ]1 f: R, ]9 E- V/ u2 a UINT br; // File R count
7 S9 j8 S R: o0 A" V1 R8 ` u16 i;
" P- j4 E1 S1 V; K" A
1 [$ j. b0 [7 Q7 z+ g
2 G2 A2 T! O/ `8 G char path[20];
7 m' x3 _. m3 J; s! k! u; ?( Y4 |+ R* {4 r- Z- s
//检测磁盘是否插好( h/ o; b) y, b* R& e- V+ b
if( disk_detect_OK()==FALSE ) return;
+ ~/ _4 i( b4 ~4 K& U |( o
% x$ T, W: `4 j- e( g // Register a work area for logical drive 0/ ]! U/ t! P6 ~
f_mount(0, &fs);
' |- S( n: B3 C/ t* W" w
6 {6 }+ B+ b$ f" a: c) g! S printf("\r\nread file:>");
/ A Y; q" R. x( t4 T1 o USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
* v' o/ b* v% G( Q, _- L$ K9 t
* Q0 R: b3 q+ C1 \* H //Open source file* I$ n4 W& {8 D1 C0 L7 h
res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误) x7 a% I3 o2 R2 z+ @+ l$ a) ?
die(res);
* f3 M4 _5 K% P* [- T0 A% \. v" O; q
7 g! Z" f3 E Q8 H5 Q //buffer空间设大一点,会提高读的速度。3 K% U: K3 {) ]8 F& f
//如果文件实际大小512byte,) q9 H9 q, E+ R, E. s! ]
//设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
* Z- [ @4 Q. a8 J+ z //下面两行主要是去除1s误差。
; W; \0 \0 t1 b. X* O1 _6 `
- ~0 X( {, J7 r" Q, x for (;;)
8 S9 V6 S6 k5 ~2 {4 r w [" w {4 G$ Z' X1 ^; S( n; a
for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存) `% u3 J4 f A& L$ _ u
3 _2 u/ C9 h) }& E- ^% l; @$ x8 q res = f_read(&fsrc, buffer, sizeof(buffer), &br);
0 ?7 x/ m9 I+ k0 N if (res ||(br == 0)) break; // error or eof
, A% t. j& l K' B w
3 R2 w: S' d. q3 J3 v4 d! j0 C5 L printf("%s",buffer); ; @ a& g+ s5 o9 s
}
" F5 Z3 e$ _) S# `8 W
" x1 C+ @' g' c& R S; K 7 w! O% H0 y$ \; y' k
// Close all files: q' o; k9 d% F1 a& `# K* E1 y
f_close(&fsrc);
8 _6 h) Q# P; V {9 ] // Unregister a work area before discard it) K! k8 L D, O: w2 v/ B$ h
f_mount(0, NULL);
6 F2 }# z, B) \' D" d+ x2 @6 d}1 X) [# O0 }2 T& n9 i3 L
2 d: l Z3 z- Q$ X; \8 mvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
4 t0 \( h6 L0 k0 a. f& h{
4 D! o, p6 u. s1 g, `1 | FATFS fs; // Work area (file system object) for logical drive
( A2 d9 `) E" q. S FRESULT res; // FatFs function common result code
9 p5 O# b5 Z9 B D FIL Make_file;
3 O5 A9 c9 H6 i$ r# g char file_name[20];
% Y- `+ D3 Y# S; w" P, v, E2 A& l char Storage_buffer[] ="0";/ {4 Q7 @6 }# b; B4 s! M) \( _0 [
* v+ `, g0 Z* K1 Z/ U+ y \
UINT bw;% _! p. J( i ?& u! T
//检测磁盘是否插好
) r; E6 G* U4 g5 ~2 o7 R6 u- @/ k4 K if( disk_detect_OK()==FALSE ) return;
8 o6 Z7 D1 E3 M4 O! H0 y( F# q3 _$ r printf("\r\n inaert_ok:>");
9 U6 O% T3 I& P# c+ M' F* S // Register a work area for logical drive 0
, P1 d ^0 n9 `( T0 I/ `+ k+ r/ C N4 l f_mount(0, &fs);: B6 {& F3 u |6 K+ u/ V# z& K
' h2 v; Z0 J5 H0 j# _
printf("\r\n Make file Name:>");
* i; d( N6 L7 C: d4 l9 ]/ ? USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
+ z; Q6 \7 K7 R( u* b1 ~
9 ` L$ k0 N5 x; X0 J! }6 |' S res = f_open(&Make_file, file_name, FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 1 Y4 H+ l& z- I1 z3 u; o& ? P n
printf("\r\n open_ok:>");% V s* B- |( l1 c1 ?
die(res);& d# X+ D# W4 u" ~# [% S/ w* j9 |
res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后
( F; F% ]+ k7 x0 r/ T8 j printf("\r\n seek_ok:>");
, Y% Z: i8 k) t+ P+ u) D7 |& O( Y die(res);% ]9 o) y5 i& Y/ R
res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1
3 c1 O/ u F% B printf("\r\n write_ok:>");/ F [+ t! H' N8 t
die(res);+ B6 C5 f9 i& N/ o
res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后
% {; Y2 F/ C2 g9 h8 a- B f_close(&Make_file);//关闭文件+ a& t, J7 _0 H! R
printf("\r\n close_ok:>");
F4 r8 a2 x/ [5 ~2 D9 U; h0 q Y+ s7 T9 O/ @
printf("\r\n写文件测试OK!\r\n");- d& E Z- n: B& ] \
# ]5 Y ^/ ?+ s" B. g$ `' Q
// Unregister a work area before discard it
( E( I7 ^3 Y# F" e6 r f_mount(0, NULL);
5 _; M# i7 } b4 C" o1 X}9 l2 {, [2 n. C# p
& m. y, |; C: v4 [$ M
//The f_read function reads data from a file., l: U0 I1 N9 G8 X- H7 A' j" a
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
8 s# _" ~) \ A' C7 r! g5 }//把Stack_Size EQU 0x00000400 改为 Stack_Size EQU 0x00000800就正常了
3 u. j8 v% Z! A0 J! }//所以以后要特别注意这个问题。
0 s0 X( i. K+ G3 h; K5 ?+ O. \. j
" N& P! T: r5 yu8 StrToData(u8 * data, u8 len)5 B5 T, }: }3 O, s3 Q- ?: x0 N
{+ x$ t* h1 e7 @0 V/ c
u8 ltemp;
- M" D4 ^0 O# M( Q. x" b { if(len == 1)) V1 L* Y+ @# d: f7 H
{, E. f/ M: [# o( F
ltemp = data[0]-0x30;
& I: E" i9 e5 R5 X; ]5 ^. r9 N: p; @% d2 \3 V+ N& L
}
( k( ]0 d* s! ~7 q+ @3 j else if(len == 2)$ u ~1 o5 B9 p
{
p9 D" a3 N+ D3 {: i ltemp = (data[0]-0x30)*10 + (data[1]-0x30);3 a. C2 m6 V. h+ `" n* n
: P. l2 t" |; P, E
}6 z8 z; R4 x, u0 m
//else if(len == 3)
" e& n7 U* f3 r- ~. N* R //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
; z8 ~3 {5 K& A$ z& t* `* c3 r2 |( t- ]) Q7 A# U Y4 S0 P P
return ltemp;
) Q T( c$ n5 j9 Q Y
0 E9 R" U# N' L; G; l% H}
! B8 y% g$ k v2 S8 w- H% S6 m n7 N+ g' |) Q2 x
; Y H( a+ ^9 f2 `! u
#endif
2 j! X+ k# g4 e y: s7 b) R ?
/ b" C% ~6 r5 J
) v+ Y' y- \ v/*
0 ? I5 k( v6 Z& \' A+ Rint main(void)
/ `9 V& r2 i. c/ b0 Z3 G{
% R. w V$ i. G+ w+ ^" G$ B///////////////////////////////////////////////////////////! X; u. \+ H) i) `
UART1GPIO_config();//串口IO口配置' F. K3 A- N* B, [! I- N
USART1_config();//串口初始化波特率为19200
?9 g; W1 S( c v//UART1NVIC_config();//配置中断7 L% q$ @7 [8 O7 z+ A$ G1 v/ A) ^/ _
///////////////////////////////////////////////////////////# Z1 X0 j) t3 Y9 Z6 I
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
4 j: Y9 d8 ?8 x//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它8 ]4 d G1 z9 g& n$ c
Test_f_getfree();//获取SD卡的容量和剩余容量( L' D5 D' Q) J% U
Test_f_read();//SD卡读文件测试
/ h. [1 H; ^( G: o# d0 M+ D2 ?Test_f_write();//SD卡写文件测试
( ]/ m# C! s2 d/ U. N( @' Y1 P/////////////////////////////////////////////////////////// , E! b# }6 J/ \" a- i6 g
while (1)
% p& ~2 W; r+ B- ` {- P8 N: V/ w! n) A* L+ O
//printf("好的");; g1 r* o; ~# F, T4 \3 I) C
}
5 V6 C0 g8 j( i) t( `}*/
9 |. n3 J9 W3 \$ T/ g////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; W1 Y$ e J/ m$ C$ jFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0% O. `' k, r$ A+ @
{
8 y }& W) I% [: r% V7 ^ FATFS fs; // Work area (file system object) for logical drive$ A8 T! I$ S. f! C" L
FRESULT res; // FatFs function common result code0 @' ]* F3 p( p9 l
6 g" P# D8 V5 z% g( d7 n7 n
//检测磁盘是否插好9 F# W0 x4 N0 Q4 S0 l
//if(disk_detect_OK()==FALSE ) return ;9 H* o1 h" k6 Q' D# N
//printf("\r\n inaert_ok:>");
; p* V% r7 r ]5 G3 l6 A9 e' v // Register a work area for logical drive 07 m$ a q0 w% y( U, k
f_mount(drv, &fs);
, A4 ], U" h) S" z res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
7 d3 J1 z7 h' T. g //die(res);
% ~% n$ H- t% c- i. X. K Z f_mount(0, NULL);
4 N* z! q& t* p$ u- c( { return res;
# W0 A+ |' l, M( u8 D& v}+ U/ B. S, {, _: Q3 b. K0 A
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0 \4 }$ N% u; ^FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录
; M# ]1 ~- _! n& F- M; y{) ^: Z0 S8 j7 o4 j: {
FATFS fs; // Work area (file system object) for logical drive
" @3 h. h2 Y) ~ FRESULT res; // FatFs function common result code; |# t/ m) T' p, B, r" B/ |) }
! D R" P" D6 I8 K* g6 u
//检测磁盘是否插好
$ o) L9 T5 C5 f) i //if(disk_detect_OK()==FALSE ) return ;/ `0 r N6 B {/ Z. c. a
//printf("\r\n inaert_ok:>");
0 f1 d5 N* f) q1 j3 t+ T# M7 X9 q // Register a work area for logical drive 0
# c8 n; R2 e+ ]2 U5 B# M# S f_mount(0, &fs);! g9 ?6 U4 D. P6 ^7 k: `) X. Z
res=f_mkdir(path);//创建一个新目录
! D" h+ Z" m; e //die(res);
+ V" N7 U4 f: Z3 G2 p f_mount(0, NULL);
2 B8 x4 R7 d% G: `+ [* W* k9 S return res;& H; O6 g# C% q) _, }
}
- w* C$ j5 p% i# l& d( P# }' N////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5 T1 v, n3 @ y+ ^# d5 y
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");
3 l( z3 h2 I( C& v& q( L{
9 y1 @% P# h, c6 d; O1 r/ k; g FATFS fs; // Work area (file system object) for logical drive" c1 [' C3 I* a( `/ v
//DIR dir;' F) ]/ T) I( Y: O2 ~$ f% A( z
FRESULT res; // FatFs function common result code
+ Q+ \0 [ c, ?1 @4 m3 N4 |
) c1 _; T# ]7 c0 c7 j" l/ \- p+ s/ q //检测磁盘是否插好
* t5 ]" R/ D( c //if(disk_detect_OK()==FALSE ) return ;7 I* j5 j8 I7 ~- B$ I R" `
//printf("\r\n inaert_ok:>");4 R3 C3 T1 l* S
// Register a work area for logical drive 0
/ J3 Q8 g9 Y( u! F f_mount(0, &fs);1 j0 H6 g/ f$ ]# p2 h; q: r: G3 H
//f_opendir (&dir,path);- N! f z3 K9 ~
res=f_unlink(path);//删除一个目录
8 R$ K1 ]- r8 v" c! F //die(res);: r' J* |. e, e* M& d$ G
f_mount(0, NULL);
* W9 G2 W2 A6 ]$ T- q# k return res;4 ~; p- w- _; J J; d
}
0 o3 Q" i% B( m+ B" A4 k2 ]////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
: \( s9 \' l9 N. P- ^FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]
6 ~, ?( Q9 H! T: C{
$ A4 {; o8 u3 z' f FATFS fs; // Work area (file system object) for logical drive
1 X8 {) i) j( @8 ]3 f& g8 j( T DIR dir;
2 T& m, r% J- r$ D9 S# u FILINFO finf;
: |( t( \# ?$ C2 Y7 O FRESULT res; // FatFs function common result code9 m( _) m: b A. m' z
" r* H' Z- L. ]1 g4 e( a1 [: x //检测磁盘是否插好9 J! G2 s- N7 G' d O
//if(disk_detect_OK()==FALSE ) return ;
2 @6 p3 q* W; g! u. s$ B //printf("\r\n inaert_ok:>");' m {8 l$ h N/ T/ B) r
// Register a work area for logical drive 0
! Y# P; g% i4 }8 j) N/ }) H; a/ J f_mount(0, &fs);
6 E# ~3 \! _8 |0 { f_opendir (&dir,path);
) ~: j0 y9 w; b" s& |2 E9 A* ?; n
" k9 b) E9 S1 v4 {" ^ while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件 5 ~" Q# d2 |* T8 w8 z! ?; D
{strcpy(*(filename++),finf.fname);
4 z9 k5 }' D6 P, l: D //printf("%s",finf.fname);- N- _! u+ N2 E3 O
}
1 v6 v J% p7 v; X6 u* ~ //die(res);
6 u- I. E# X; g4 _ f_mount(0, NULL);1 t5 V4 q) Z6 T, n# F
return res;- x" h8 Y( O# @: h0 |
}
; S6 ~8 a9 x, j8 j8 @+ O/ E////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
. d( a3 ?7 l X; KFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名3 W) X+ `8 b6 I7 b. R" h# E9 e
{+ T3 i# ]0 m3 Z) b- N- @( v
FATFS fs; // Work area (file system object) for logical drive: T! U& w6 u# D
FIL file;
& r+ Z) M2 ^. f n8 V FRESULT res; // FatFs function common result code, ^! f- {1 d- |0 y3 E9 Z$ c; z
% s) n1 m$ @1 h //检测磁盘是否插好4 M) X* y) L% U7 F- {, n
//if(disk_detect_OK()==FALSE ) return ;
# `* L) W+ s. { //printf("\r\n inaert_ok:>"); _# H1 @; C, o: O
// Register a work area for logical drive 0
/ [& u7 y( H6 x6 q4 o f_mount(0, &fs);
+ x( O; z: l% R6 J6 P res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。: T2 Q* T1 Q' B$ S J+ _0 G" W6 v
//FA_CREATE_ALWAYS //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
6 O8 Y/ T- q, [ //FA_OPEN_ALWAYS //如果文件存在,则打开;否则,创建一个新文件。" {/ _$ L6 p+ v# q+ S
//die(res);
+ E7 k D7 w) r f_close(&file);//关闭文件7 [" b" \" _: |' i! m
f_mount(0, NULL);
7 X. A- Z0 R# h) K" _! s return res;* z- o& _9 N" x
}, @4 h G+ l: O) H6 X) _: W! n
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8 i0 {9 D4 @. q5 n# _: b
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir"); - h6 a7 u8 U) R+ ]6 H6 E8 Q9 B
{
+ c$ u- @+ A2 M6 z. } FATFS fs; // Work area (file system object) for logical drive$ ~6 @5 `7 d6 X5 m4 O1 c# t6 b
//DIR dir;
8 e( ?" P; [5 r+ D: e$ Q FRESULT res; // FatFs function common result code# s7 P, F+ O% h, q) t; S; J- f
1 n0 [0 J; D Y+ O" P! Y //检测磁盘是否插好
& t% T5 X y s( a //if(disk_detect_OK()==FALSE ) return ;7 L$ ?1 E( w* C) r* L$ m7 i! b
//printf("\r\n inaert_ok:>");- T/ x$ h( a1 R0 `
// Register a work area for logical drive 0
) h1 ]! A: t. U4 W3 v2 T8 D9 ?7 E f_mount(0, &fs);
) c& o9 _" N8 I+ B$ e. q Q //f_opendir (&dir,path);
+ t: u' M: L _. D$ b, S5 r' `0 t7 O res=f_unlink(path);//删除一个文件
* F, G3 X( F* J+ ] //die(res);
" u7 Z8 |, v% O1 x8 ` f_mount(0, NULL);
. \) R" e: ^+ K; s" E2 [ return res;( R5 p$ ^6 w0 T1 V, Q
}6 h* y2 w! T& r9 y. M
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
/ _$ B0 x2 y8 f! |) ]6 V3 B4 TFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数1 q" z1 A8 f/ k$ y
{ //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
- B0 J# O* M/ c' X, g FATFS fs; // Work area (file system object) for logical drive
7 R4 u) j F" E" T0 I6 B FIL file; // file objects
- Z; ~$ u( m3 a. |$ q FRESULT res; // FatFs function common result code% f8 A2 r$ K$ p5 ]- x
UINT br; // File R count 文件读回的字节计数
( n0 s6 u' [( j" b: v8 g- b- e //u16 i;, |2 Y- y* V& n0 R$ {; Q
//检测磁盘是否插好8 S/ D7 q) F8 B, r) u% \ m% {
//if( disk_detect_OK()==FALSE ) return;
) X- n$ H, S5 Z0 v. ?# v" w; | // Register a work area for logical drive 01 k0 B) {* l- S- G2 c9 X! l+ v
//for(i=0;i<sizeof(buff);i++) buff[i]='\0';: f# I4 m. M E! V! [: \. j- n- Y
f_mount(0, &fs);& _4 B& @5 f# T. ^9 N& p* I
//Open source file8 r; c+ ]$ Q% }5 Y
res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
9 W' C: L7 U+ n0 h } //die(res);
& W8 ]* T7 i1 e res = f_lseek(&file,ofs); //指针移到文件ofs个字节处% g* H- r: S1 `* F5 B; G1 y
//buffer空间设大一点,会提高读的速度。
! ^* t2 Y' a3 l6 `+ |/ H( `- z2 D! q J //如果文件实际大小512byte,0 ~$ [. f# l8 r4 ^6 ?
//设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。- |$ ~* O- k1 S+ r
//for (;;)
. Y; V, \" _- R5 w- p {
' u( C& a- t# C3 I- A6 ]. |6 ` //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
* O8 k/ W& N2 O$ F6 E
9 _& o5 R3 R- V1 g, v1 o2 G& y! U! h res = f_read(&file, buff, strl, &br);- t( U. D. o9 Z/ e8 g( S
//if (res ||(br == 0)) break; // error or eof如果错误或者到文件末尾则退出" W( T3 g% v6 @8 L- O* G
. j" W3 F' z1 I# u& `0 M //printf("%s",buff);
2 N! n2 q) p9 p9 O! z& g } / Z0 o' X- B5 }7 m% K) k: }7 `
// Close all files
6 {( J, d d* x) H# A f_close(&file);' ]2 I3 p- G; [& y5 |) Q3 ]: ]- B
// Unregister a work area before discard it
* ?4 e+ `0 a6 R3 Q5 Y/ p; p3 k/ P; g f_mount(0, NULL);$ u" [* w& x; S4 V" c" A# H" o
return res;2 }2 u" g( s6 [5 ~
}; w/ C' x: j+ Z) O7 v7 B- b) V8 T
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////( d( K$ Z. j; r! e* v1 R0 j* E
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数, h" {4 ~. ^5 f8 b% }! _# z
{ //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));
+ @7 Q9 P0 b( a& E" F L1 u FATFS fs; // Work area (file system object) for logical drive# X3 Q% Y) J8 X4 ~; Q! |. o. s
FRESULT res; // FatFs function common result code* H* Q. W" U! p. j
FIL file;
, x$ ]3 g4 T1 k$ M! }) J UINT bw; //文件写入的字节计数/ C7 R9 ]& j- v; D
//检测磁盘是否插好% H3 K# b# v5 {0 E) [* i
//if( disk_detect_OK()==FALSE ) return;
& h8 |6 z+ s6 u# ~ v c // Register a work area for logical drive 0
) ^ {+ |1 N/ O. w" q' H! G! ? f_mount(0, &fs);
0 L; h" r& ~ z! G9 K& {: F res = f_open(&file, path, FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
) O4 V! }8 W+ ~, p/ B! ?$ f //die(res);3 i8 ~ {6 ~9 A( M9 `% E. ?7 o6 Z: z1 [
res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 G- r/ b+ U E \
//die(res);$ a' g+ W6 j' d9 s) W H$ b
res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符. a8 B+ x, q' X, M, A6 `
//die(res);
3 T3 J. h v( \; v //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入
1 H z" D$ Y* n; k/ \9 `2 \ H( S f_close(&file);//关闭文件
; W3 `$ x5 P m P9 N // Unregister a work area before discard it
0 ]4 |) d+ w2 T" ?/ B+ m: V f_mount(0, NULL);
% ?0 ^& ?7 U7 w) a) X return res;
3 L2 O9 N) D+ ]' {! Z9 C}
' z# ], W3 o2 _////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
' k( W( f) N2 IFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M" a- ?4 ^- W" ^1 z4 m8 [
{
@0 F' I9 v9 c8 } FATFS fs;1 @* X+ ~3 `, Z
FATFS *pfs;
0 t8 c4 ^0 N6 I B1 ~- _, K FRESULT res; // FatFs function common result code- z0 E7 j$ P, h: M$ @. G# X
//检测磁盘是否插好- m' [( P- n4 N+ F
//if( disk_detect_OK()==FALSE ) return;
* O3 W& _: A9 ]+ \+ v; X) `3 y // Register a work area for logical drive 0: _4 y; z1 F: ?. J1 O: e! t
pfs=&fs;//指向
! b* z% ~5 h/ H7 E# i4 K) [9 k f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
2 g# B" c5 U0 q) |% A+ t3 @ // Get free clusters
# z1 u' ]! `% J* Y( T h! z res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
; ~- }" O# d" g8 a' g3 `9 a //die(res);) t# y1 h' ^5 L7 y+ p8 ~
if ( res==FR_OK )
1 {. E& n3 [' p9 v9 t4 x7 G {+ u2 `4 ~2 T$ F; t/ v7 F
// Get free space6 S3 g8 q8 [( L5 m0 t& W
//printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",+ z' ~1 W3 g* [6 p0 r; D
//(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
5 w4 ^& ?" H: F* W5 g2 P3 K //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
5 X6 U1 D6 D0 Z0 G# u3 \' Z4 ~ *freem=((*freem)*pfs->csize)/2/1024;0 t5 K4 e- b1 E
}. D" n4 e% h8 A/ u
//else die(res);//测试函数执行结果分析
& U6 @$ V. n" H/ o' G! S // Unregister a work area before discard it
2 [9 v! D. j8 s$ N0 H f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
5 C- R B. k% Z' X0 q; z( P return res;0 J1 Z% H2 P) ?. `- |2 E
}" m. q9 c; Y) d" T- Y! n
4 g& N+ u; d/ r0 v5 Z
7 r7 N8 R4 g( W1 G9 [4 y2 k, m& c5 [* X$ M2 q" R
/ Feb 26,'06 R0.00 Prototype.& h% q( W/ d) Z6 c* q
/
3 T# e( c% b1 B/ Apr 29,'06 R0.01 First stable version.
1 [: [. J$ ?, o# ?/: S% L2 R' T! O4 s" e# L, }+ Y
/ Jun 01,'06 R0.02 Added FAT12 support.& S1 ?( e+ c" d) O, Q2 F4 @, b3 P
/ Removed unbuffered mode.: t' j& \ d: A" b7 G. x6 S8 D" I
/ Fixed a problem on small (<32M) partition.
* _3 p2 L! a$ x! W4 F$ E! a/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).1 M# i! z# a, f6 \5 \
/2 ]% y1 C! U- g0 {9 d
/ Sep 22,'06 R0.03 Added f_rename().
h0 h( f) j" ^! S/ Changed option _FS_MINIMUM to _FS_MINIMIZE.' v% t* o8 b/ D# [ ]5 k
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
) I/ M4 j9 q! _1 l/ Fixed f_mkdir() creates incorrect directory on FAT32.$ D1 N4 C+ J. y x/ |
/$ w* e6 C8 ~) l) `
/ Feb 04,'07 R0.04 Supported multiple drive system.# U1 G: j+ ^2 f3 A9 B' U( o
/ Changed some interfaces for multiple drive system.2 g) H0 i; X6 S8 `
/ Changed f_mountdrv() to f_mount().
6 j- N/ }$ i& X- ~' }/ Added f_mkfs().
; G5 _4 t2 J" G" ~( n' u: q+ @5 T; J/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.
. S1 T# i9 L! Q- D* g/ Added a capability of extending file size to f_lseek().& f; J" Y% y5 n$ u& E1 n, N5 M* l
/ Added minimization level 3.+ U' @7 ], M) Q3 h% b8 i
/ Fixed an endian sensitive code in f_mkfs().
3 H% K6 \5 a# q7 u/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
" V4 q- ?# I0 t5 k u y) f3 k/ Added FSInfo support.
2 {) @/ j/ \4 M8 q) w/ Fixed DBCS name can result FR_INVALID_NAME.; g% ~( ^: ^. n9 Y& {7 m# [
/ Fixed short seek (<= csize) collapses the file object.
/ r2 y% Z, X+ t* M) r$ T& G4 N3 Y# Q/
6 k. ]7 L# ~- `# Z/ Aug 25,'07 R0.05 Changed arguments of f_read(), f_write() and f_mkfs().
" b: C/ l4 N: g/ Fixed f_mkfs() on FAT32 creates incorrect FSInfo.; F, r- M7 I9 Y- w. R
/ Fixed f_mkdir() on FAT32 creates incorrect directory. \$ l( E3 \! n5 b' ^
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
% p4 W# P# K. d/ n, L7 l5 W/ Fixed off by one error at FAT sub-type determination." c* c& ?7 g( {: s+ V9 i
/ Fixed btr in f_read() can be mistruncated.
0 K% Z7 e+ h' _2 q, F/ Fixed cached sector is not flushed when create and close without write.
' D. @5 W9 i9 \- M# K7 W/
9 R; f }) C# w/ Apr 01,'08 R0.06 Added fputc(), fputs(), fprintf() and fgets().* S6 r& j, D5 g# y& _; r5 W
/ Improved performance of f_lseek() on moving to the same or following cluster., k0 Q, e: v8 F4 O
/! v2 r& o- N; w8 H
/ Apr 01,'09 R0.07 Merged Tiny-FatFs as a configuration option. (_FS_TINY)5 I7 t/ r% r, o% ^
/ Added long file name feature.
, h9 f/ q1 E! j" o/ Added multiple code page feature.
: U/ e; ~9 d1 C) z, u/ Added re-entrancy for multitask operation.
% Z% T" v" G! f0 L/ O/ Added auto cluster size selection to f_mkfs().
$ m e2 Q; e8 g7 {7 X/ u5 C) y/ S/ Added rewind option to f_readdir().
3 t. E% r5 P7 ]% d+ l# d( {/ Changed result code of critical errors. f7 ^" ]& Z* A5 P
/ Renamed string functions to avoid name collision.
, ~: d+ e; ]) r/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.7 D" P) l2 t& P/ f2 ]% v. c
/ Added multiple sector size feature.
# c+ f p1 @' _. {. P) q; f' g$ n/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.9 U& W8 q1 A, v T" ^+ h( @: }1 x" R
/ Fixed wrong cache control in f_lseek().! ?, [' S: c+ \& d* s
/ Added relative path feature.( p% w4 m8 M; U$ c; A
/ Added f_chdir() and f_chdrive().
b9 ?) h$ K8 [7 N/ Added proper case conversion to extended char.
7 k ]1 W2 U' U7 \9 |/ M3 |. Q" v/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
# O$ d+ w$ E8 p6 }/ Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.( s9 B& G9 `+ h" h' M
/ Fixed name matching error on the 13 char boundary.4 s6 ]3 P0 `+ M0 ]# ^1 W8 _9 ?! M
/ Added a configuration option, _LFN_UNICODE.
6 A, b) o7 S. h: h) L" n6 a/ Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
8 v. V: o% ~' f, y/ R/' [5 m; \+ p; r6 q
/ May 15,'10 R0.08 Added a memory configuration option. (_USE_LFN = 3)8 }) o% G5 S1 n% t; \ O4 k8 K4 \) p
/ Added file lock feature. (_FS_SHARE)) J+ M3 f* m. b& L2 h0 c# H
/ Added fast seek feature. (_USE_FASTSEEK)9 Z9 B$ ?! A' J6 `+ m* U
/ Changed some types on the API, XCHAR->TCHAR.
9 @' p( X) ` X" e8 N/ Changed fname member in the FILINFO structure on Unicode cfg.
* ]0 u6 R& s2 C, n1 O0 B% e2 A- f/ String functions support UTF-8 encoding files on Unicode cfg.
3 i7 m2 T+ B2 h* |7 I7 Y4 C7 {/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
+ b5 t1 X/ F/ Z/ |0 g! V: ^/ Added sector erase feature. (_USE_ERASE)9 T$ Y$ O# m' W
/ Moved file lock semaphore table from fs object to the bss.& m- a( Z0 N+ ?& i
/ Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.4 e* v, Y& S3 G6 T5 Z5 T+ k- z' _
/ Fixed f_mkfs() creates wrong FAT32 volume.0 k, v: T, {" Z# x. w
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
3 J2 J: L9 T+ S3 R* r/ f_lseek() reports required table size on creating CLMP.! t+ M8 }6 W6 _
/ Extended format syntax of f_printf function.
$ T+ z) V/ n; F ~* _( ~" b- j/ Ignores duplicated directory separators in given path names.
1 h7 Q) k$ l) ]( z/4 N! _8 i1 o/ z8 {2 C" S- z/ |
/ Sep 06,'11 R0.09 f_mkfs() supports multiple partition to finish the multiple partition feature.9 v" p6 [. \' Y+ S
/ Added f_fdisk(). (_MULTI_PARTITION = 2)
1 K7 J9 q; F) e. p/ V5 z& x; A/---------------------------------------------------------------------------*/
2 o5 u j( {# o$ F4 S
0 i" F, t' r9 c |
|