EDA365电子工程师网

标题: [资料] 自己移植的SD卡的FATFS文件系统,FATFS R0.09 (MDK STM32f103) [打印本页]

作者: Gegu    时间: 2016-4-28 10:03
标题: [资料] 自己移植的SD卡的FATFS文件系统,FATFS R0.09 (MDK STM32f103)
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK  STM32F103工程。下载即可使用。
  O7 y$ |" Y8 Z& G; }5 i) H" M- p/*----------------------------------------------------------------------------/4 \& d: P3 l. Y7 p" d9 E/ N' N
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011% r2 f: ]4 q' i- R7 G- k, L0 Q9 l  m* `
/-----------------------------------------------------------------------------// |. Y7 `7 R. f- h1 G
/ FatFs module is a generic FAT file system module for small embedded systems.
9 L5 F+ u" w$ N! X/ This is a free software that opened for education, research and commercial- [& J# s- |  K$ ^% s0 p+ M3 I
/ developments under license policy of following terms.1 u2 ~0 \  q4 |1 h% \# g
/
- {5 @  h. A+ v/  Copyright (C) 2011, ChaN, all right reserved.# A- ~6 n8 X/ M8 V5 F2 s
/; Y- S) P; G: L1 L, b* `
/ * The FatFs module is a free software and there is NO WARRANTY.# s" i( D* i7 l) P' }
/ * No restriction on use. You can use, modify and redistribute it for7 h8 a% G' q* N3 R3 S; [/ B9 z* ^
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
+ P$ r8 r! K5 A* f/ * Redistributions of source code must retain the above copyright notice.
. c, e) _& G1 ^( r/
& O* L+ x5 s1 _+ W/-----------------------------------------------------------------------------/
; a* j) T# h0 q- w9 C7 m: ]  P3 S; u
6 E# U( J; U: {5 Z
/*--------------File Info-------------------------------------------------------
0 a9 P4 Z! y" a7 i6 p0 s** 文   件   名:  FATFS_Function.c$ d0 R9 [/ l4 y( k
** 作        者:~风中的叶~    整理
# C7 ^1 f$ x% z) E' b$ w** 最后修改日期:  2012.01.18$ \7 X. d: ?) Q, f( y! l
** 版        本:  V1.04 p' }/ b  I1 [4 ~6 u" e
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出' O, V8 B# |4 S2 g+ C- Q
**------------------------------------------------------------------------------
6 Z, A, K+ W' k3 A/ P7 ^2 y** Created   by:  Dt.' p. H% S& M; m) k/ j0 w- Z
** Created date:  
8 _1 C) I) U- [/ v*******************************************************************************/
" {. N+ T( [7 N  L#include "TEST_FATFS.h"
6 Z& j. a1 h- s; o#include "string.h"
  N5 _. t1 {% l# f5 y3 ~4 E7 H/ R+ J+ M, U* h, [7 u/ ~
#ifdef TEST_FATFS_EN# V% J8 Y: x2 M5 T7 r

7 y+ ?2 l& Z5 g3 Z; s
  H+ z7 }/ n9 Q" r8 ]: |3 E3 V0 x) }6 @+ z
//检测磁盘是否插好
: z$ j5 ^; G7 X. x. s- l4 s" K/ CBOOL disk_detect_OK(void)
  y. [# }* D) g9 U5 l{
7 U. @, a5 C% _- H    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
! u& v! o0 e0 q: u3 q& g        {
% W  c$ R; {( U) k& B. f1 a            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");) [9 `1 `5 J# R1 I' u  d) j
                return FALSE;
! Z4 a" E, }! }# r6 |        }
: x) v$ P3 z. m0 p0 r        return TRUE;+ s7 k7 `( M+ d0 C  M; }; Y, z
}& _, X  N$ H4 @; d0 e
7 F/ [  t+ o/ z  J9 d3 W7 f4 u

- n. l) ^- T7 V# d* \, R
* c" W% Y( q3 S  }//测试函数执行结果分析
4 C1 J+ s2 V' ~1 X( ]  M2 Cvoid die(FRESULT res)8 F) A3 f% V1 X8 X& G/ `
{
  d  S5 X- E. y8 {/ h    switch(res)
- o1 }5 f2 Q  R7 f6 l3 a        {# u  R. F- H# v% O2 c; o" A- c1 }$ ~
            case FR_OK:        //The function succeeded.
+ c4 F5 d1 |( u4 o5 p* \# U                {1 J/ ?0 \* |; V  t
                    printf("\r\nThe function succeeded!\r\n");/ f0 [4 Z, w9 U9 H% r. d
                        break;/ u0 W; v! m4 w- K" X' N' V2 f
                }
9 M# ]6 Q4 N& P( }, Y' N* s; n                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason0 C3 L% ]; j2 n2 X. j
                {5 p4 o5 ?% _' M' T& [  B5 @
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
$ T7 @" P4 f) x. `- p                        break;
) p8 t; I! ?. m; Z. @) f; U- Y                }
0 T  K) u$ m/ v" o* H                case FR_NO_FILE://Could not find the file.
; p5 M. h' B' L' I' h5 s& x                {- d/ D/ I  n* [! t9 K. [, q2 n
                    printf("\r\nCould not find the file!\r\n");: b8 ]7 ]- q  Q' r
                        break;
4 M" `- a3 p4 w                }
) `4 s+ A/ m" }4 C* N# |0 P: F                case FR_NO_PATH://Could not find the path! y% ~& }) @0 x4 D0 ]7 V3 O
                {
/ |: V, `( K" m, U                    printf("\r\nCould not find the path!\r\n");
5 `" M6 x6 N9 X' Y                        break;6 }  q, L0 J' ]; o
                }% A( T$ y8 E( @- Z
                case FR_INVALID_NAME://The path name is invalid: C( f* k& [1 u" }
                {
1 K( ~, O  {& ]/ Q! u! `1 u                    printf("\r\nThe path name is invalid!\r\n");
+ D4 n& N  x7 v9 x( u" Z                        break;$ }6 O/ O- _! U
                }! f& @& ]' ?' w5 A3 x' T. B4 |
                case FR_INVALID_DRIVE://The drive number is invalid. c; o" e: r6 x7 b& y' S/ n/ w
                {
6 I. D  d1 T  g# a                    printf("\r\nThe drive number is invalid!\r\n");0 ^- y% [6 P# l: B% ^3 b2 B
                        break;& m7 l$ C0 r$ \1 G7 B" P
                }4 J2 Y5 w) m" q3 i$ }4 U6 y( H! @- Q
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. 3 x. S+ l* W- n" y# K- i0 p
                {( ^6 D0 R; g" z! c6 o
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
+ ~, L! }* m  D3 l0 F0 ?" T                        break;
) ?5 X% J& T8 y. `, ~                }% G8 P  p4 }( i# c  s* Q
                case FR_EXIST://A file or directory that has same name is already existing$ S, O! {& @) ~# b) n( x
                {6 L- p1 I9 c+ G( |6 C6 h
                    printf("\r\nA file or directory that has same name is already existing!\r\n");5 [8 V/ r& Q: B! z, \! z3 p
                        break;* A. ^; j' h5 l3 ^9 H: F  u
                }# ]1 [9 t6 d4 n: u- [/ ^
//                case FR_RW_ERROR://The function failed due to a disk error or an internal error0 C6 k- f* H( c1 Z, i
/*9 i/ h( q4 ]& r5 {0 _6 x9 @( ?
                case FR_RW_ERROR://The function failed due to a disk error or an internal error- o5 Y. S3 L& M' X1 ~* c; c/ H
                {
; R6 r# g$ a7 v" t                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
+ h- s" {8 D1 Z7 @  i                        break;
% c9 `7 ^" m6 F: T5 A                }
0 }, I* V6 S9 z6 O. d*/4 Y. e+ x+ S8 ]$ S* M
                case FR_WRITE_PROTECTED://The medium is write protected
/ N8 c5 |6 ^/ b2 l1 }0 p3 ^- p                {
& G: O8 s) t; W9 k  t                    printf("\r\nThe medium is write protected!\r\n");
  K& _1 \/ U8 e8 B& ]                        break;
2 v. E# s1 b: y0 N) B( q" p                }
8 S; B% h, D9 j0 Y* C                case FR_NOT_ENABLED://The logical drive has no work area, W/ V/ r6 p( x; w/ ^) ~
                {% t+ h- R0 P( {$ p
                    printf("\r\nThe logical drive has no work area!\r\n");
: Z& f; H" E5 Y) a$ Y                        break;$ ?1 I' O# G5 i% E* r' r( e
                }1 l0 p. ?3 b; c  f
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
" Q$ T; D+ [% t, a6 ?                {7 R( }. a( j' W3 `/ ^% A* j
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");& r% J6 w$ ]9 g, [6 Z0 K
                        break;2 a. G6 l: E* O  Q
                }2 T( x) H! g+ Y/ f7 Z
                case FR_INVALID_OBJECT://The file object is invalid" v1 y' @, q; q
                {! D8 w& }" y$ \, j
                    printf("\r\nThe file object is invalid!\r\n");
& E, D) |2 U+ q$ N                        break;
. q& j' ~$ u7 e8 l% q                }+ H' F0 s$ H) A. P+ Y
' D) _8 c: v' a$ q
            //The function aborted before start in format due to a reason as follows. 8 P0 x5 ^) R1 ^0 J$ B% T  N
        //The disk size is too small.
, c% q1 A  {' L% D! i. U0 z        //Invalid parameter was given to any parameter.
% a$ u3 b  b$ U% ?+ q$ q        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
, p- ~7 O- |- ^: s6 M) E6 M  G& H                case FR_MKFS_ABORTED://
- j* U1 T/ s* {$ F( f7 E  E2 v8 l                {. ^6 K+ e* [( @2 p
                    printf("\r\nThe function aborted before start in format!\r\n");, ^/ [9 z7 V9 X( s* s. H3 ]
                        break;& t4 w/ v1 H# {1 `; ?, H
                }5 [1 g( B9 A% P
                1 s8 }' N5 a3 y
                default:! A  q; y& |( u& V: I1 C5 v5 ^
                {
# m0 l. P8 M# L6 T* ?                    printf("\r\nerror!\r\n");
, ^# o0 c& z* C! P( |4 t                        break;. V9 l) a& \  Q* U
                }        
; o0 c+ d4 \+ k" a! n) c        }
& ~0 {5 ^$ o( `" q6 R        return;( S2 H2 S  {3 H5 B* z, S2 f6 }( g, ]$ J1 m
}! ]% k$ a, ?- R2 v' y
void Test_f_getfree(void)//获取卡的总容量及剩余容量7 }! m  A  B" [/ [6 }5 p0 g
{
! }5 \- q& i4 h: v    FATFS fs;
2 f6 F# t6 k/ M        FATFS *pfs;
  Y& q$ ^' K0 H& f: |    DWORD clust;
4 ]4 x! v3 k' O7 ~5 h        FRESULT res;         // FatFs function common result code
$ {1 x. K  d  g& p* r# ~! f8 B' \0 q0 ~# p& v3 s. J( B: }6 v  _) g
        //检测磁盘是否插好: P9 j* a: r& N/ x0 g, M
        if( disk_detect_OK()==FALSE ) return;6 ^: w7 Z' H6 ~5 `" D4 z% X

1 Z, a/ h! z0 r# A  B        pfs=&fs;//指向0 \* Y9 H. P1 Z( N5 |
        // Register a work area for logical drive 0
( w& H% {- }4 M6 N2 Z    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
5 Z  N( D( b- V7 l4 e' J, Z' I- B6 ?. ~" \9 ]  J* i1 ~& P7 |5 y
    // Get free clusters5 t9 S5 n& \' s& `- c! H
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/", Z5 J0 P# o5 z0 N" w" |- }3 c
    if ( res==FR_OK ) 1 `( \) i9 P& Q) C
    {
% x/ \' ~6 _, D. C- x  l6 @: i) I            // Get free space
3 `: P; p4 z" d. u' U        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
- J9 n5 S0 G, ~4 `# l  ]. e                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024+ f* G& F1 `  {7 c; K, t
                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024( l' w0 H( G1 \
        }
2 t1 h5 U) o/ u8 C( ]        else die(res);//测试函数执行结果分析- m+ S4 c% u/ P3 u" Q8 O4 Q+ G& b  n4 n
        1 B# `: q5 {) |. K  W+ _, ?7 |
        // Unregister a work area before discard it
# g- X' G3 ~8 g3 m( y* z    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
0 y0 x; ]0 b5 }. G4 ]% _+ h}
& K% b7 @9 A& Z) o  |
: I4 T& [1 u+ W3 mvoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误& n5 `& Q4 q4 {/ B! V8 u' `* F7 |
{& f* r/ C% M  T8 ^
    FATFS fs;            // Work area (file system object) for logical drive
2 B# B; m& W/ z/ r    FIL fsrc;            // file objects" C7 ?; e9 y7 f) G, C7 E+ J6 G0 r% ~
    BYTE buffer[512];     // file copy buffer$ g2 H+ y2 Y, e' }
    FRESULT res;         // FatFs function common result code- R# u" \) ]: d. Z
    UINT br;             // File R count
2 h: B# y' U# y; X! H5 z# H; g        u16 i;
: {4 b7 a4 V/ o$ L- X' k( q        1 n& u0 Y7 b0 p: z' W3 ]0 d
: r8 i4 I- n7 A& u2 H) p8 [
        char path[20];7 W6 m+ E$ K6 Y# P) k3 T

" D; M) r4 S' u. L0 h        //检测磁盘是否插好6 ?0 D3 s7 {; j6 s+ \( D: r: {
        if( disk_detect_OK()==FALSE ) return;7 [0 [) J" e! _5 c; D7 e

+ j/ R5 M4 G- U5 ]    // Register a work area for logical drive 0
, \- M  c. Y* l" K& Y' W/ D    f_mount(0, &fs);
/ K) W9 L/ P, p0 D( q. r
" u, w( w  \' {9 a- J2 V2 Z$ M5 ?        printf("\r\nread file:>");
* T/ W4 h3 z8 k; x4 r        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
8 E3 W+ g3 F: x$ H; F
$ U3 x/ U/ r. C- L        //Open source file8 O0 r+ D0 H! x" f
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
1 m. T" ^/ Z2 E) f4 G9 {) p% F        die(res);+ R% q; I6 U; C' R
        
" A9 P( o$ }& K5 k% Z4 u3 N        //buffer空间设大一点,会提高读的速度。3 Y: t6 x+ ^5 D* p1 _* X( l9 ]
        //如果文件实际大小512byte,0 C8 F4 C. e7 S* r" t
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
) d( ?- e) k( m: u9 h        //下面两行主要是去除1s误差。6 ]4 ]! |8 `3 l, P! o( l3 Z

4 B. [! [  K0 q$ h% w8 Q) B        for (;;)
3 m# B9 d! n: j, Q5 R" x        {3 S( j$ o9 \& {- `
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存
+ L3 ?$ @- f( |
' Z; j& q; i" H, Y2 C                res = f_read(&fsrc, buffer, sizeof(buffer), &br);8 j) L8 r! L3 e5 Q" Y$ Y" Z9 r
        if (res ||(br == 0)) break;   // error or eof        : o+ i' x  D& G) w3 q5 n
                2 L3 Z$ l' R' w' q# G3 U9 z  y
                printf("%s",buffer);        3 S# r1 v/ K' }9 s
    }9 W7 _( I- ?$ h1 ?" u( |

9 D: p( P. ~0 a( e                            ) M' R0 k& f* X; S
    // Close all files
7 G! _, D. }, q8 |3 r1 k    f_close(&fsrc);& R1 Y0 I. F* B) G% O6 q- I6 r; o! O
    // Unregister a work area before discard it& L, |' {% ?- j+ c7 U# K
    f_mount(0, NULL);
7 E5 Y4 I4 R. b# I2 _}
5 E& i. w, E& g4 X2 m% g4 ?+ V+ A1 @% t1 j1 g
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件- R0 v% E  V5 z
{
, }0 r/ \$ @$ ^: r0 ^/ Q2 w0 x    FATFS fs;            // Work area (file system object) for logical drive* w: \$ ]  K9 s- Q+ D0 W
    FRESULT res;         // FatFs function common result code
6 m& H5 L' ^. \/ H+ e        FIL Make_file;
9 f' ^8 t9 R) ]5 v    char file_name[20];9 n# e9 n- J& i) z  G7 l/ T+ B; n
    char Storage_buffer[] ="0";  p7 t5 h3 O6 }! b/ i, j9 g
        : R+ E% j6 M/ S6 r; n
        UINT bw;
3 y9 M8 u5 g' Y* r0 u8 M        //检测磁盘是否插好
/ ?6 O' {5 t8 r! s% [        if( disk_detect_OK()==FALSE ) return;
  ]4 \$ I: c9 e' J2 c+ s9 r         printf("\r\n inaert_ok:>");
( L+ ~% H3 J$ \1 I  W, D* Z" U    // Register a work area for logical drive 04 W3 \* Z- z4 g* D% V
    f_mount(0, &fs);
" Z' O2 R7 K9 j9 b9 S/ k' b$ [* L! |: M" H: ^8 M) }  {
        printf("\r\n Make file Name:>");
) ~/ n0 D9 u$ X9 S0 \6 ^3 n* N        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
: s( W4 ]$ `5 G* ^" n9 Z* c$ D/ j- u4 z9 s* b
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
( k. e" j) K. X2 ~9 |& L0 _         printf("\r\n open_ok:>");
+ T: x2 V3 l- x  g; k: r9 Z         die(res);" e7 i% \# F7 E) ?0 ]- h
    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
8 ^! }; ]; g7 X  ^( S# ?      printf("\r\n seek_ok:>");
6 y8 c( `# v# U" l' g6 A$ p* X8 }3 l         die(res);6 P/ t& v: e) c! u
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  1 }3 |9 O5 @1 p8 f9 }
     printf("\r\n write_ok:>");2 C; q! L, H" i$ y  F" u
         die(res);+ [: c0 J! P/ a8 l/ _
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  7 x& G, g6 `- {% T" n
        f_close(&Make_file);//关闭文件. ^" G3 r6 F2 c( q, e7 @/ Y9 O
        printf("\r\n close_ok:>");, ^' @) z9 A& \3 J9 ?+ ]

2 T8 C9 X) K# E4 ^4 o: t% |# ?- R        printf("\r\n写文件测试OK!\r\n");0 k* v6 w' ^: E; Y
1 j- T7 t8 j' l: F1 F8 c
        // Unregister a work area before discard it1 d9 `8 M8 Z  r" e7 L
    f_mount(0, NULL);
9 E+ `) i1 K% s' K! J# Y1 F! [}0 M9 q2 {: v/ e) s
9 z/ j! q% M- c' x0 V; [/ ?! o
//The f_read function reads data from a file.
6 v( k9 S+ O* l! v, d# k- [//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样6 W. I) U6 |% O1 C* a, P0 b
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了* \+ I. a% W- b  C& m
//所以以后要特别注意这个问题。" v* L5 L" R" j) l  M- r( @% \

- P0 W, p1 ?0 x5 }! \6 V- eu8 StrToData(u8 * data, u8 len)6 c8 w, F( N7 H  |
{+ d. z* z" i" n1 T
        u8 ltemp;1 S$ t' E) x" b+ w5 ?) g
        if(len == 1)
3 \- m* J% w8 W7 q6 L        {
4 ~( H' h" r7 c, f; q+ {                ltemp = data[0]-0x30;4 ?6 l: D, T0 j1 S

+ K! j' S- P: E; ^8 A6 t+ v+ R- k& F# ]        }
% ~5 c. p: f5 f* n, |1 S; i! L; K& V: J        else if(len == 2)
* c7 J8 a- Q9 h  }: H        {  `8 A3 A. t2 [/ T. {) ~
                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);: y+ F1 |: f# o+ k6 w7 _. E1 v4 g
6 a+ n- D! q0 w" P; ]
         }
1 E: R* U( a0 J$ b' \  p        //else if(len == 3); w  j; @# Q" P: y$ F1 W; z
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
+ {& S- Y$ a) A/ Q4 ]  Y' o* w6 a
        return ltemp;
4 W4 m4 t% ?3 r# t/ b5 o+ \, N        + x  w* }6 O) K2 e
}
1 |. C- \- h( z2 o3 O: \
# j' j4 y3 H2 B7 z9 F4 _1 Z. O' D# S4 ~2 u& q! f0 [0 j$ s
#endif
2 P% Z, ?* y" n6 ]& \
5 u% Q) _$ }# r7 L) g3 `
  _4 r/ r) [1 D, \/*
# A9 {+ x* ]9 Q9 v5 Zint main(void)
1 P. z, u! R7 |{3 a( Y2 V6 ]4 F" ]8 l
///////////////////////////////////////////////////////////* y& o3 d( E$ p- L( j1 c
UART1GPIO_config();//串口IO口配置3 H3 E: o2 J- g" @$ ]
USART1_config();//串口初始化波特率为19200
1 Z2 V5 W8 N: v. Q) z2 ~//UART1NVIC_config();//配置中断
0 _$ v- }* ]" I3 u) ^///////////////////////////////////////////////////////////
& e" p  _0 |8 e- I6 pSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
- F& _9 |& |" @6 ~9 Z& D/ ~//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
8 S: Y- G7 r" B( ]' H" p+ I# l& aTest_f_getfree();//获取SD卡的容量和剩余容量
1 g6 \; `8 L0 y- l0 [, wTest_f_read();//SD卡读文件测试
) g- W% j5 f" P! X4 N, G2 g7 pTest_f_write();//SD卡写文件测试
$ l, q3 T1 r8 @. e" c///////////////////////////////////////////////////////////
  c, Z$ E4 w/ v    while (1)
: i% _' W  k; {4 ~  M    {7 {$ G! r" A8 P$ L5 _: n" [" N
        //printf("好的");
8 I4 z+ J( G; j# s0 Y    }6 O) a1 J3 d9 Z4 C
}*/% ?- o6 Q9 l6 p$ I
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0 R0 r% B5 c- l: z/ p4 `* E! `
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
8 r5 W, A+ Y, G; y4 T' g5 O{
" a% L8 g1 O2 G1 w2 @  H    FATFS fs;            // Work area (file system object) for logical drive; m$ C6 O2 F2 F  Q; p: V
    FRESULT res;         // FatFs function common result code
/ H; ?- K7 W! \* _/ B+ X- _/ z9 v+ |7 y  P8 F
        //检测磁盘是否插好
' c( e1 N+ ?# B& D        //if(disk_detect_OK()==FALSE ) return ;7 O: g5 `7 v! X. s! Z# l) e
        //printf("\r\n inaert_ok:>");; Q0 G3 U6 b. C! \! Z
        // Register a work area for logical drive 0
, d) E# P- u: `$ D2 e        f_mount(drv, &fs);
* U1 [* Q* r! @/ Q9 j  k. d        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/& Z0 |! e# i0 C2 I8 t' {" X
        //die(res);
4 m' I/ J6 m" o2 I! h        f_mount(0, NULL);: f* ~! Q; n9 V3 S7 Q
        return res;
5 E4 ?& b" d4 |$ |}
" L- m+ Z: X2 k- M( d; G# v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- D+ w  Q" p7 H7 hFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
4 G; j2 V! O+ n1 {! v* U0 ?) x* i{
$ q" ~0 I& q7 Y. t  D    FATFS fs;            // Work area (file system object) for logical drive, r6 h8 T" |. ?
    FRESULT res;         // FatFs function common result code
: {; y/ |  g6 b; L5 g3 P) Z2 ^5 ]7 }) K) q, l
        //检测磁盘是否插好4 `. G- [7 ~0 E8 L9 T: z/ y7 L
        //if(disk_detect_OK()==FALSE ) return ;' Y* F2 z" L* _- A- [  d
        //printf("\r\n inaert_ok:>");: t, t% a5 e0 C1 g, Y( n
        // Register a work area for logical drive 0
2 S4 _; v- ]$ Y* [5 Z        f_mount(0, &fs);
/ r7 `! n+ g2 ~* k) Z% m1 @" {        res=f_mkdir(path);//创建一个新目录1 F2 l# b( q/ n# u4 ^% ]( l" k
        //die(res);% ]0 w; X4 q3 x" A  T3 f" }
        f_mount(0, NULL);, m% @+ V' w* R/ p% l: n1 b- O
        return res;4 u" t% }3 Y; v. J  A5 a3 {
}
8 i) [4 J( ]7 r0 p0 _////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////. g' W) R8 z! T) N# j" T
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        9 W9 ?( B) f2 h0 I9 _
{; D( [8 N$ P. P
    FATFS fs;            // Work area (file system object) for logical drive
' E" }( ?1 K  E* H$ ?        //DIR        dir;% Y4 T$ W- @$ ^8 W
    FRESULT res;         // FatFs function common result code
+ d4 r- P7 R2 V! i5 K/ t
6 D' L7 u' u# T/ @1 F        //检测磁盘是否插好
/ H+ W% U* @+ Y        //if(disk_detect_OK()==FALSE ) return ;  T( a; i, d6 G, U$ O& C4 u
        //printf("\r\n inaert_ok:>");8 S+ w& p6 h& r' P  p0 }( D0 x
        // Register a work area for logical drive 0
$ q# ~0 A6 {, P) E! W% e        f_mount(0, &fs);
) E. r& R3 u$ X  e1 k- r        //f_opendir (&dir,path);0 B/ Y) o1 X" \7 f9 _' W" T6 R4 I
        res=f_unlink(path);//删除一个目录
, N1 h# v/ D! Z! ?, c( x        //die(res);
. |) _) [1 H. s) |        f_mount(0, NULL);# \2 q8 N( y: M
        return res;
4 X8 Z9 Y& g; j7 y; L* {}
, A$ h5 Y6 x% ]+ t7 v. i3 p4 `5 M////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////- N# h7 n% g- t3 o8 x
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        8 b& k& d- |  t4 P! i( T% f' H
{% C5 F. F" j# c! E! J% Y
    FATFS fs;            // Work area (file system object) for logical drive
. ?3 S& T$ e. L' k, r        DIR        dir;
( T: B* ]5 W- J  Y0 }/ t3 t        FILINFO finf;
; A& T2 `* S" F: G7 O9 o# S    FRESULT res;         // FatFs function common result code
9 g6 H7 r. ]. Y8 B6 [8 C: h& v3 {/ n1 _1 d' r" k+ x- g
        //检测磁盘是否插好* S4 R3 C, H4 w/ ^" \
        //if(disk_detect_OK()==FALSE ) return ;- i/ G1 w2 ^6 F
        //printf("\r\n inaert_ok:>");
8 }4 `- L! A6 N6 e% N( W  U        // Register a work area for logical drive 05 ]/ a3 o; |9 O: v( _: k- n: _1 [# Z) }
        f_mount(0, &fs);3 B, o8 g, w* C: M5 `: H) H" l
        f_opendir (&dir,path);( A, J+ o& Q! ]# O% e$ }
- p. c: A2 ^7 j. `3 X# W
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
& y1 @4 q( z2 N) s        {strcpy(*(filename++),finf.fname);7 |& H' Y6 q9 y. f4 v; c/ i! N4 q
        //printf("%s",finf.fname);) F5 s  @- X: k) Y% x! _
        }
* z2 ]# h1 j- B, T0 b- V2 s        //die(res);
7 U" h6 C9 w! f- F5 [- w        f_mount(0, NULL);
' j" C! u9 f9 [        return res;
- z- j6 Q2 f, G9 O}
7 o( ^, T4 d. U# ^////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 v/ R' j* d9 O: g  [5 q& NFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名
$ v; ~0 F+ E. e8 C2 g! ]3 u{
$ n2 O4 |5 J: U# _- B$ K% b6 J4 v    FATFS fs;            // Work area (file system object) for logical drive
  a' l3 v4 R% E8 `$ g6 b- V        FIL file;
( y! o0 O4 _% ^0 _" \+ @: g    FRESULT res;         // FatFs function common result code, m8 t7 ~+ k- v! Y3 @- O

* ^# u4 r# ~3 t/ c4 v        //检测磁盘是否插好, n7 l1 s0 v- ?6 C/ p7 c
        //if(disk_detect_OK()==FALSE ) return ;  q2 D; s; {6 f& W4 {4 e3 ~" \
        //printf("\r\n inaert_ok:>");$ v0 O& N, m$ X. g* ~1 _
        // Register a work area for logical drive 0
6 ~; L* p, D- c! [) U0 F        f_mount(0, &fs);* v! ~9 S! p6 Q/ K9 W) h  j
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
* _; v! n$ N3 ~0 t- \9 S" s/ \/ [                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
2 y& L% \' {6 T6 V! W5 P* G3 x. o                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。; ^4 _# j" l( _( |
        //die(res);
3 H( F1 {! ]! j* v" Y  r, y7 W2 @: X        f_close(&file);//关闭文件2 M; J3 E3 U. o  ^9 H
        f_mount(0, NULL);" w* k5 U2 U1 }: v2 Q  y8 ^7 e' }
        return res;
, T- }6 S& c! }; v. y- ]! e3 P}9 ~: e) l) Y) q7 P4 [7 a
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4 f) f$ P7 ?$ M" `' ^
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
( Z7 A4 X3 E- ?* ^7 W{8 A0 o1 @% }2 ~0 d% u8 x
    FATFS fs;            // Work area (file system object) for logical drive2 A2 f* J9 ]( A- P
        //DIR        dir;
. [7 `. d: \6 |    FRESULT res;         // FatFs function common result code* }9 k% J( X9 J3 d5 B8 @, l

' h* G7 t, Y. |1 T4 X7 F8 `        //检测磁盘是否插好
" c! N! e  S5 e2 x1 F9 i        //if(disk_detect_OK()==FALSE ) return ;2 P- Z" ~% o$ p! D
        //printf("\r\n inaert_ok:>");6 ?3 I" F, B$ m+ Z- R
        // Register a work area for logical drive 0! l/ F  T2 Z+ O/ k9 @, H9 ^2 d( D- ~
        f_mount(0, &fs);
( ^+ f7 }" z" j3 R9 X( ?* p9 [: n        //f_opendir (&dir,path);
3 D1 I7 |: E. z+ V4 f        res=f_unlink(path);//删除一个文件
) E6 _3 N; N, t% d        //die(res);
0 T0 a4 U0 W* u, {8 A        f_mount(0, NULL);: E8 }- Q. q# J5 j/ l! j" g
        return res;1 G% V3 j+ l! G2 Y( e% ^9 x
}
7 X. x8 }0 p' x% i. B////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8 b. y: U5 Y4 m5 q3 _& _9 OFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数
8 W2 h3 i) Q% V3 u" y& x2 B{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
/ J6 b4 t7 f: }3 y8 n    FATFS fs;            // Work area (file system object) for logical drive
# H0 Z6 k; y! `8 [1 o' r6 |    FIL file;            // file objects
! s. w* D+ R* W3 {- o) x" ]+ t, Z! ~    FRESULT res;         // FatFs function common result code6 Q! c# N: t. o" T- T$ b5 g
    UINT br;             // File R count 文件读回的字节计数1 o8 S9 |6 \) S  V# Q) o3 E
        //u16 i;9 k5 Y9 _4 [& D9 M! B2 s- [
        //检测磁盘是否插好
1 K/ y! S* ?6 X4 O2 T3 z. m5 L        //if( disk_detect_OK()==FALSE ) return;
+ v  p, g* Z; h  L    // Register a work area for logical drive 0
( |' T( i! M9 K9 Z  b8 p/ d1 q        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';/ [9 d- c' D3 N- Q8 N+ z
    f_mount(0, &fs);( Y3 u0 h3 J# ]
        //Open source file1 A$ U% T  z( T8 G6 B
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
% R2 s: R8 @( b3 l& c        //die(res);1 l+ T* S2 t0 W( [
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
( B) \( [% E3 C# |        //buffer空间设大一点,会提高读的速度。9 U. I2 ?3 v+ j$ C" e+ H7 W
        //如果文件实际大小512byte,0 i& z9 p1 ]  G, h
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。3 `2 \& O; S, f5 z: M
        //for (;;) 1 U/ g: z8 h* _
        {
+ ?7 b, d3 v/ c) X% z" ~                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
+ [1 b1 M& {4 g) M* `$ O  n
) H* B% u, X- u  E7 u, u( J: h6 e4 Y                res = f_read(&file, buff, strl, &br);$ U9 _6 q+ _$ d& @% Q7 u5 A
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出. R2 ^4 A2 F1 D3 _% u
                / D, y5 h4 X" C& S" z2 [/ c( w/ X
                //printf("%s",buff);        ! S, y( d+ C! k
    }                    
* b# h8 U6 r4 b/ J7 @! N    // Close all files
: T$ g# {) @* \* c- S3 j    f_close(&file);! P, B& |' Z) T' u/ _
    // Unregister a work area before discard it( M6 v: N& [0 H! F* f, K
    f_mount(0, NULL);
, P8 I) J  E- O# Q6 ^4 j8 }* @5 W        return res;  A: Y8 v( h% O! u8 H2 I
}0 x- f$ E9 Q, X4 R3 l
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 s5 E, r% x& h2 r1 a- H  Y) M6 x5 \FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
1 p3 H3 h5 I; Q0 ~{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));8 ^( J# v7 J. D' S
    FATFS fs;            // Work area (file system object) for logical drive, J% U, d8 H1 d& `5 L8 H; S/ z
    FRESULT res;         // FatFs function common result code8 m; ~3 q1 a' h
        FIL file;. x$ q. [% \6 b! K$ ~
        UINT bw;             //文件写入的字节计数
8 ~- u9 h( ]4 B3 A# A! m        //检测磁盘是否插好4 J2 b9 ~! P( r5 x  a8 G" i
        //if( disk_detect_OK()==FALSE ) return;
. z, Q2 b. ?0 D3 r    // Register a work area for logical drive 0
; U1 R0 U. C: n' s1 F    f_mount(0, &fs);5 U+ W  g& L( c* v
    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 , P) s& o" G! u
         //die(res);% _$ j; N; ~! U. e2 c, y
    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
) L$ Z4 k/ E3 ~7 F# M. ^         //die(res);
, a) o# T# \" k; u1 E; W* f+ D        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符
/ r' ~7 T& g/ C% ]9 k' p$ O         //die(res);+ X- ?" K6 x: d
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  ( r! ^1 M. b! `6 s* N3 ?
        f_close(&file);//关闭文件# r. L6 N; Q6 C% j, [) _
        // Unregister a work area before discard it
: k5 e% R: F  ?    f_mount(0, NULL);
! d  q6 f6 g: z        return res;
) n$ k* }" f3 }5 f1 O* u3 D* C}! _/ J8 q. l: q& U
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 z3 K% d, B/ SFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M- F$ X* d9 k& Z( {
{7 v7 I" ?7 C, H. C/ a+ H
    FATFS fs;+ ^! w5 o0 [  x
        FATFS *pfs;# f4 A" p4 `8 j1 Y3 e
        FRESULT res;         // FatFs function common result code
: W" X, p: Y1 V8 K        //检测磁盘是否插好
* X- P0 v, K& n# ?/ t        //if( disk_detect_OK()==FALSE ) return;
7 n! K2 c: h) p$ P# i/ U0 Y        // Register a work area for logical drive 01 Q7 B, k6 g- _; [$ @
        pfs=&fs;//指向& E7 d' ]1 g+ n' [" Z# @" o+ E
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间9 f+ G- ^. _" U" I/ X/ U) g
    // Get free clusters; h9 L, _, C: {  {2 k
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"2 h+ W. `; w0 ?2 h! z8 d7 k
        //die(res);
2 A+ r+ R5 ]$ G% S, j        if ( res==FR_OK ) ) Q' c/ x- V8 L! k; m  ?
    {
8 b4 K* L' G+ O: s3 b6 \$ G2 b            // Get free space' c5 L, a" z& o8 ^- r  I4 c0 j
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",& M, y' y7 a( E, L: F! y. I* \
               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
2 a+ d# r  h( m- z: p                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
! n0 w, f8 p2 j' D5 u         *freem=((*freem)*pfs->csize)/2/1024;9 B4 U) m% G5 K, r* l/ m$ ]
        }
" W: ]( Z  r3 D/ l/ U        //else die(res);//测试函数执行结果分析0 n% R' T  m, M
        // Unregister a work area before discard it
& p; B! d# o; n0 }    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
2 Q7 Q9 X# Y  k        return res;. o) A( x" @) {5 J% x4 |2 F0 t
}- ~* Y+ g& _. D3 i9 M

; u7 G3 I  T. P  x; ?4 w
, `' d1 @% g' X: y5 W1 K
5 c9 j# B$ S' X0 D$ w! E9 |- {/ Feb 26,'06 R0.00  Prototype.3 b# R- S3 }. _* \, H# O' l' o
/! l; z- u( E/ Q, R* T
/ Apr 29,'06 R0.01  First stable version.
5 [% f  o& x0 |: l' f) ^& Z/ d+ P2 D/& F: {/ T3 Z# `% \$ z/ u
/ Jun 01,'06 R0.02  Added FAT12 support.7 H: J* G& s# u% E- u
/                   Removed unbuffered mode.
0 c# Q( R. m8 @3 m* w/                   Fixed a problem on small (<32M) partition.
' Q2 A" [" e- M% n; V' p/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
% ]8 x( D  S8 b3 U/
- K& ?; _& m& @8 @- P/ Sep 22,'06 R0.03  Added f_rename().4 A$ N6 J' I; S( g2 I; x' Y
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.+ J; p% U) [  P+ ]% V" p
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.3 E. m8 y1 @( u1 j1 T" U
/                   Fixed f_mkdir() creates incorrect directory on FAT32.( [" H' E* b& u+ V$ r* q+ `. J0 w
/
7 V" }% m, p' ~8 X! g# H  g/ Feb 04,'07 R0.04  Supported multiple drive system.
, \: V* x  i- k  [/                   Changed some interfaces for multiple drive system.
5 ]* ]4 @4 ^% i& L2 |/                   Changed f_mountdrv() to f_mount().
6 R! B) W4 g3 \$ V! C$ R$ H/                   Added f_mkfs().1 U' K7 J1 K5 D, V3 X$ r) u  N
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.9 m1 Y# J# V# U( K
/                   Added a capability of extending file size to f_lseek().
2 e- t( q; Y$ B2 D) k/                   Added minimization level 3.+ a5 E: V- y, G# I0 g, L. R
/                   Fixed an endian sensitive code in f_mkfs().
* z: m* h, x* `9 d& |6 h/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
# Z5 r- ^: C: _/                   Added FSInfo support.
+ f# y) a* @6 ?( h' G0 M( B# z  ~0 i1 L/                   Fixed DBCS name can result FR_INVALID_NAME.
( V5 w% f6 W: K  ~1 e/                   Fixed short seek (<= csize) collapses the file object.+ A! K/ l. R/ }. R+ N* A5 X
/
) Q, ~  _. X* Q1 X: j/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
- ~7 A! X1 C: V5 ~: @+ n6 m/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.5 i, ^4 r: H6 L% p
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.5 ^& y6 O" q* j) R" u
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().! X! k; a% L" z
/                   Fixed off by one error at FAT sub-type determination.
+ h2 O" [  o& u3 c+ A6 c4 ^/                   Fixed btr in f_read() can be mistruncated.! Q2 L7 h( g, s! ^$ F7 E: ]
/                   Fixed cached sector is not flushed when create and close without write.
% y. ~0 ?2 c, k1 f! K' O. I  m/
- a3 k* A$ y) h/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets()., w  O9 s& f0 A( n$ f/ b
/                   Improved performance of f_lseek() on moving to the same or following cluster.4 `$ Y- p3 K1 t
/
, {2 W# e4 G; c9 z1 `; S( D/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
/ z+ ?" p; M- O& I6 ^  A: H/                   Added long file name feature.  w1 s  q, t0 a9 Y
/                   Added multiple code page feature.
' r1 d1 C* J0 N  H0 ?2 p/                   Added re-entrancy for multitask operation.
5 n. b+ i2 ~! Y6 f/                   Added auto cluster size selection to f_mkfs().
) Z, q  {6 T& o6 x9 z1 ^/                   Added rewind option to f_readdir().
1 G. L  c( J% D) }7 ^* t; e/                   Changed result code of critical errors.
) A8 z/ T* n' y' h" H/                   Renamed string functions to avoid name collision.4 j1 A3 r; c$ k9 _* o* X$ n2 M8 b
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
. {  c7 r2 W/ U  F/                   Added multiple sector size feature.
) @: I/ [4 F; x, [- A2 a/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
3 t; a. H" x% P5 e, h& {( g/                   Fixed wrong cache control in f_lseek().
6 J6 N1 A; b' i, P/ M6 I8 ?3 g/                   Added relative path feature.
8 c. u# c6 x6 z2 `; X, ~/                   Added f_chdir() and f_chdrive().% e. J: v, p3 F* {9 }. P
/                   Added proper case conversion to extended char.
# J! D6 _2 q2 c/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.& z7 j  K2 l' v
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.% J! y% k- i- |( y& i: X
/                   Fixed name matching error on the 13 char boundary.
# b  K) a3 V/ X( \% y/                   Added a configuration option, _LFN_UNICODE.
* l; T( W: i& `& I0 k0 Y: z7 [* n1 T/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
, M" C1 }. F3 ]. g' N# `( j; ]/
" Z- J2 j% n" ]) |0 ]/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)6 [$ t) ?5 Q: g8 k) J2 Z- z
/                   Added file lock feature. (_FS_SHARE)$ F* n# j, z* `$ [0 c* W
/                   Added fast seek feature. (_USE_FASTSEEK)1 H/ `" h; ~& E" U
/                   Changed some types on the API, XCHAR->TCHAR.
* d, f4 f( y0 P# m+ W$ b7 t/                   Changed fname member in the FILINFO structure on Unicode cfg.+ [  v& H9 }4 \- J! L
/                   String functions support UTF-8 encoding files on Unicode cfg.
' f. N  s/ i1 i0 M/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)$ z6 |! U6 V" ~3 [7 Q' q& Q/ P& ]
/                   Added sector erase feature. (_USE_ERASE)
; `7 Z+ L) e, L) g1 d5 A5 O/                   Moved file lock semaphore table from fs object to the bss.
& X0 i7 w0 _5 B& o* w/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
( t) A4 Z" a5 n- J3 e/ g. {/                   Fixed f_mkfs() creates wrong FAT32 volume.* l5 `0 x! Z: M" e7 N4 `8 p8 _
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
9 `/ ]9 I, [# C3 x! f" M) n/                   f_lseek() reports required table size on creating CLMP.. d1 u% p+ d, Z5 E
/                   Extended format syntax of f_printf function.
2 n0 L: `4 }( i& ~5 ~' v1 T/                   Ignores duplicated directory separators in given path names.# Q3 V: ?4 B3 y; _/ Q6 y0 S
/
) w$ q7 x" }- Y. X/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.# E& J. c3 Z5 _: S8 w! W% N- v# U
/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
2 f2 I! ~! S1 B/---------------------------------------------------------------------------*/
3 x+ F* |" z) X, v% O) v8 p  L! D: H8 d0 `+ h

STM32的SD卡FATFS.rar

1.24 MB, 下载次数: 8, 下载积分: 威望 -5


作者: Gegu    时间: 2016-4-28 10:04





欢迎光临 EDA365电子工程师网 (https://bbs.elecnest.cn/) Powered by Discuz! X3.2