找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1383|回复: 1
打印 上一主题 下一主题

[资料] 自己移植的SD卡的FATFS文件系统,FATFS R0.09 (MDK STM32f103)

[复制链接]

211

主题

652

帖子

1507

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
1507
跳转到指定楼层
1#
发表于 2016-4-28 10:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您!

您需要 登录 才可以下载或查看,没有帐号?注册

x
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK  STM32F103工程。下载即可使用。# _5 i. O# M/ T; x
/*----------------------------------------------------------------------------/
: d* k4 ]4 B1 J& `* l2 ~/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011: O( U- B: l4 _5 X6 c
/-----------------------------------------------------------------------------/& N! h" \$ x( h
/ FatFs module is a generic FAT file system module for small embedded systems.' C8 g4 I* H- {' C9 C: h, M
/ This is a free software that opened for education, research and commercial
, [6 G; P  L( s7 o8 |3 i3 K/ developments under license policy of following terms.: j0 n( |6 x) w, B
/
& d9 p  J9 [+ c" p4 N/  Copyright (C) 2011, ChaN, all right reserved.
7 {0 Z( @9 U# V6 {+ }) P/
0 r3 }+ e2 k! P2 V/ * The FatFs module is a free software and there is NO WARRANTY.
- o. D7 T/ F1 U- ]% P# c/ * No restriction on use. You can use, modify and redistribute it for6 Z- \' Z+ l/ X/ `# |: Q" m
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.% l$ o# ^, B7 u$ M5 h4 |
/ * Redistributions of source code must retain the above copyright notice.2 f6 l0 R8 ~/ Q* E  ?
/
3 m1 P6 N8 T/ \1 f7 [/-----------------------------------------------------------------------------/
1 E" b" k% A' l! q; {$ ?) Y" [
8 {5 F( B1 J* H- Y5 E/ y
- K1 N& y. B; f4 Y& s5 R/*--------------File Info-------------------------------------------------------) q% g$ Y% u, r0 t
** 文   件   名:  FATFS_Function.c
4 E0 i4 v0 G% z4 F1 {6 f** 作        者:~风中的叶~    整理+ n% [' T: i4 j# z
** 最后修改日期:  2012.01.18
; M" }: x; k2 `: U** 版        本:  V1.0( N% W. S, k7 V. z- P! Q
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
4 R2 R2 s- C% z' B8 M  a# o**------------------------------------------------------------------------------+ z6 z5 I+ |; d3 b7 u; ~7 d
** Created   by:  Dt.; l3 I. f. f% B: X6 M7 J
** Created date:  3 h+ p2 H0 |/ n. g  K( ~8 r
*******************************************************************************/
" s5 u" U- i) t6 ]7 V#include "TEST_FATFS.h"  v+ {1 @' r2 C) T
#include "string.h"
2 F7 Q) d; [- `7 v' Y) L! c: T% [' V- N
#ifdef TEST_FATFS_EN  }: M% r9 E8 M8 O2 c, `( S

9 z3 o- T& m1 Q# m8 y  V/ @. ^
2 n  H! t" }( V9 x6 S
6 F/ q' [' }% ~4 v( K//检测磁盘是否插好& [% i: D7 H- h; b: Y5 x; y6 d
BOOL disk_detect_OK(void)
" i/ i( u, S" u7 Z$ z) v{
; h  l/ }. {, O/ x- D: k2 T" t/ s* S& F    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
6 @# [: Z# R" ?/ ^( ?        {
0 P) S/ E0 ~  Z. A1 P            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
) ?$ B# G) f6 g3 R4 X8 P. ~! U                return FALSE;
- Y( A& y" L# h1 n# g  s, P4 L        }
+ B# }0 I: O8 r  ]6 i: u# G8 l* I        return TRUE;
6 E& b, D- n# t, ]4 {! Y9 h& B}
6 O8 \# }9 c  g5 c6 I1 j/ ^6 D% h3 E% D2 C0 s$ b% l
6 Q( V9 d- [: o% Q" H) W" D

  x  @2 Z7 v4 D: ~1 S9 r//测试函数执行结果分析
  [* u4 X( W6 {% a' rvoid die(FRESULT res)
2 ^  ~, I- }/ v0 B# U{
$ ~( `1 O0 j2 x2 C    switch(res)
9 o3 Q! K; L7 q        {0 P- X4 b$ }# [* b5 _% ~; m  r
            case FR_OK:        //The function succeeded. 3 v$ \  V6 H/ N. a! o- _
                {
7 a7 x5 p+ j- q0 s                    printf("\r\nThe function succeeded!\r\n");
. O# L) `" o1 ^! n7 S                        break;. H# _3 k9 m# Y3 R
                }5 u1 u- }( w- i
                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
% ?2 C- s8 Z/ y& R" n: f                {6 p- u) ]; H& I- a
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");+ z# {" }' T. F  ^3 G  V
                        break;
6 B, B+ |2 |* d, g+ j: U1 r7 b                }
! k/ g, H) Y9 R( G5 A                case FR_NO_FILE://Could not find the file.
1 @# y% r( m' {: s- Y                {  [8 H" U" i' Z6 a0 |6 h% i
                    printf("\r\nCould not find the file!\r\n");
! x1 D% R. u8 E/ p, g                        break;! L7 d  P8 p* w$ r) @
                }
3 {/ D' H; N9 ?' i! O7 f6 p9 b8 l                case FR_NO_PATH://Could not find the path+ w# H( @3 }' K& O7 Y* b& a3 P
                {& F/ O8 C+ Y, n5 M/ K
                    printf("\r\nCould not find the path!\r\n");
$ F. I9 t  H5 _. O1 s                        break;* S8 O+ R3 e- T* Y
                }
3 f3 U! }; k6 P3 ]2 B2 F# h, y                case FR_INVALID_NAME://The path name is invalid
2 G0 }/ F, o  }2 J4 d                {& Q: X2 G9 V7 W$ Y4 e7 p( i
                    printf("\r\nThe path name is invalid!\r\n");! g. [% k# d/ s& l
                        break;
  I* Q/ N7 d  y) Y1 S" u2 C% s                }; P1 n1 t$ H2 D' S* v+ c+ L" U
                case FR_INVALID_DRIVE://The drive number is invalid
( s6 k: B6 G) Y                {- x$ t8 G8 d. F6 a# Z( m; Q
                    printf("\r\nThe drive number is invalid!\r\n");7 F: ~) K% O7 G, [% P
                        break;8 k7 Y; j. [% n2 Y' W4 f' Q
                }" \; K0 x4 D( G
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. ) t- Z% q# F. e# i  f$ \6 y
                {* B0 ~6 \7 l. k' f. E$ ]
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");% N6 m8 s3 v! ~0 S: ?1 o
                        break;0 {! Y; f2 \* O. M7 C
                }
. D" u' C# {! [/ A& f' ?6 _1 j+ |                case FR_EXIST://A file or directory that has same name is already existing
  x. f/ r5 [) L7 r  ]1 p                {
) l, j$ H4 a8 d# ?! v+ F/ x                    printf("\r\nA file or directory that has same name is already existing!\r\n");. h+ q' V% Y! F
                        break;
: T" g  U7 s( ]' q" f. _( H                }
9 f5 ^2 a3 F2 I/ f" ]//                case FR_RW_ERROR://The function failed due to a disk error or an internal error
5 N' V! z" v) v: s6 o" b" j/*
) G7 h/ h; G! ]. _! n                case FR_RW_ERROR://The function failed due to a disk error or an internal error
! c% x( F; I3 }" K                {
2 R4 b1 A, e# c4 Q' h. D/ w                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
. D3 G; J' D) |: N4 U                        break;/ i1 z* c7 |9 b7 q5 [# ^! u
                }6 W& Y5 o$ s: X
*/  s4 \7 y4 l. j/ Z  B7 G
                case FR_WRITE_PROTECTED://The medium is write protected+ s. i/ G7 @6 G0 G# N. d% ~
                {
: t3 g2 |  X9 j' @2 W/ L                    printf("\r\nThe medium is write protected!\r\n");, l* l- ]; j/ }& s" S  @  k0 A
                        break;' u. I# X: Q+ G5 c" ?. S5 R
                }
6 ^) s/ U/ ~4 g$ N. @) j, A                case FR_NOT_ENABLED://The logical drive has no work area
5 k  {$ ]) Q: j8 [3 `" Z( b                {
0 ?8 B$ ?& |7 k0 e2 t                    printf("\r\nThe logical drive has no work area!\r\n");
# V3 N; y: o+ A& n* t5 r                        break;
5 \' V' C. l. m% I- K                }
7 t, g6 k. k3 ]4 S! A                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
, {: r. E6 z1 w8 ?+ l( m                {3 r. P  l7 d7 m5 B, w+ e" j/ h- [0 j
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");
! B! `6 Z) q; ^- e0 f/ h                        break;' _/ f  b& w( ], j% H- H5 B
                }
. d" W4 H) q# s2 k                case FR_INVALID_OBJECT://The file object is invalid
3 g6 \1 Y, n$ v, D6 Q3 |/ }' T                {8 @/ Y: u$ W' `3 ?; Y
                    printf("\r\nThe file object is invalid!\r\n");% [' L( t. P- Y4 M: w
                        break;: D, `% L$ m5 d" B2 D3 A( I
                }
& ]$ `: T$ B5 C) ~" x/ k" p  r& ]% R/ C, b  O7 a' v7 k
            //The function aborted before start in format due to a reason as follows.
) H( P3 E( p3 F' G        //The disk size is too small. " R4 K: q. \: d% N6 r. J( N# v
        //Invalid parameter was given to any parameter. 8 |5 G  O% v1 K* e' B) L
        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7. % g( b' r% U7 ^2 ?5 K
                case FR_MKFS_ABORTED://8 M; T8 R3 {( }* S7 i
                {
% Q5 S7 h, Z( O4 }* O                    printf("\r\nThe function aborted before start in format!\r\n");
/ h: b2 M7 A6 q! T* A                        break;! y/ l! E: Z6 |5 k/ }$ V
                }+ E5 w. j4 ^! U* U6 x% r. L
               
. _5 \8 E2 u- V( N3 y8 h( [                default:
0 C  V! m" Z) t2 Q1 G                {
. d$ e( q9 c2 ?1 R: R1 D( [$ H                    printf("\r\nerror!\r\n");# A# n0 E1 k+ S- `8 n
                        break;- |/ H" k9 `9 M' I! M5 A
                }        
4 G0 J8 w1 y+ T: {+ N9 O+ t        }) k  ?/ U8 t& j% w$ d1 |+ K% x' F
        return;
. [" @' A+ A7 m# {% ]& N}: h' U4 K" B" F- k& O
void Test_f_getfree(void)//获取卡的总容量及剩余容量
* Z9 d( m4 @; M/ u4 z{
7 T# w) b; W8 n2 C# T    FATFS fs;
8 k# C- F4 x9 N        FATFS *pfs;* K/ p6 R/ C& I% e  v0 S( F5 P+ E
    DWORD clust;
; O# J1 z" J0 z& g$ _" B0 R        FRESULT res;         // FatFs function common result code, t' i9 n& t5 C& x
/ K- j+ @# j% b. L$ n" X
        //检测磁盘是否插好9 r- B9 e: {2 K0 I
        if( disk_detect_OK()==FALSE ) return;  w  i3 h9 V, Z+ p0 @- D
0 }( b3 s! ^! i
        pfs=&fs;//指向. y7 i* `# {% U% C5 d, R
        // Register a work area for logical drive 0
1 e+ c' m+ c, h( E( {, k    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
1 j# V1 c! J2 T, j! x) r" Z5 d" c) j# L  W
    // Get free clusters
) C8 T3 D* q+ F- t* @$ d    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
: b% v* V6 J$ b1 Y5 q* m8 ~- \    if ( res==FR_OK )
+ T. I( A) |1 z2 r7 S    {4 f2 X+ ^% T3 d  U9 `& m6 A
            // Get free space% d: K: B: w9 k8 w1 @2 D# R
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
1 ?- ]+ i$ N4 ^                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
" S5 \! [1 g5 ~( `% a  J6 }                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
0 p; ^4 e5 d+ v  M: V( t" Y% h        }5 R& u! S5 W& ]( I; E) ^2 \
        else die(res);//测试函数执行结果分析
/ Q$ q2 P' {6 w. d        
! \% l* h  E) r' ^7 E" B. b        // Unregister a work area before discard it
" r0 G& H$ I7 @" Q( d# O# m( v" s: y    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
' v+ j+ z' C7 {6 U- n}
0 O% b% o% k. V% F% v# W+ a
1 u" z! g; O. d& dvoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误; a" N& }. I0 ~" L9 s
{
( @! \% C! Y9 P& M* _    FATFS fs;            // Work area (file system object) for logical drive0 q. I, s; G: \
    FIL fsrc;            // file objects/ s/ E/ w5 f8 `0 U- j0 ]. g
    BYTE buffer[512];     // file copy buffer6 h' Z( a0 ]8 \/ \3 E/ x
    FRESULT res;         // FatFs function common result code# _: m3 c! \( M, u5 k
    UINT br;             // File R count
8 M6 ^8 Q4 M/ R/ `6 k        u16 i;7 H/ M+ P' c8 G1 ?: I6 J3 T4 f7 q
        5 W+ \4 t2 Z  `% ]+ b; z, n/ o; g7 N! E

% N5 q' ]0 i0 f        char path[20];
- y9 Q/ M! D: v( w/ x9 }- S* ~& B! L1 J9 F. {. A; b2 {
        //检测磁盘是否插好
& y1 J# z! e8 v# x        if( disk_detect_OK()==FALSE ) return;  f' y" G( D( a# |" |, d
, x7 D3 h' i* x$ Z
    // Register a work area for logical drive 0
: _8 O4 N5 `, ~& e9 h- n) Y! k" T    f_mount(0, &fs);
( n0 f& [. P: ~* G( g0 f% J) D3 b0 D/ O5 T: C# h1 ~6 h. c
        printf("\r\nread file:>");
% j0 Q. [3 Y; Y. a/ ]! P1 G+ X        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt  b5 [! _$ a" Y6 \1 ~

4 Q  l( d& E$ V, M8 P        //Open source file, Z, `% }9 ~1 l( u/ |6 s
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
. e* q" r& X" q- F$ {+ Y        die(res);
$ P8 s0 p1 r2 Y# p        ' m  U7 i' x/ n+ @* z. F
        //buffer空间设大一点,会提高读的速度。
9 V  `/ s! w0 b9 u2 c% _        //如果文件实际大小512byte,
0 _8 Z) Z; `, _: I, j7 e  Y        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。# K) B- k& S- O" _1 I5 P, b! e$ M
        //下面两行主要是去除1s误差。0 a0 O0 I! o1 V3 o7 m7 l

1 k) t# L) V% G        for (;;) 1 L# t! H6 M* I: z6 A
        {
5 S0 ~" ~* N# @; N8 i  G  y2 Q. s                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存3 W6 r( e! `+ _; S* W' Q

4 X" ]" I9 J9 V9 Y4 h5 n. s8 g                res = f_read(&fsrc, buffer, sizeof(buffer), &br);( M& d8 U6 \/ t% E" A0 W
        if (res ||(br == 0)) break;   // error or eof        / `! ?8 J! i9 l
                ; l- v6 q, C1 a' f0 A. z; R3 W
                printf("%s",buffer);        
. y7 r+ \- q$ a  U! k$ R    }
/ f1 U- e  Y* s" g1 E$ C, ~+ O1 i9 `' ]  k1 q
                            5 T( Z4 A$ G) T6 r
    // Close all files
( s! ^; ~8 I+ K3 G* M2 i) A    f_close(&fsrc);+ H! V, g6 r" x$ {2 V' u# n
    // Unregister a work area before discard it: Y8 h+ ^4 ^% f. P/ f# G9 q5 A
    f_mount(0, NULL);+ g1 ]7 g) j0 o2 M
}
) U4 W$ G: K8 ~& s) `7 {! F) t4 _. y4 g4 m3 |
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件8 n" h3 A1 a) r4 T' D% O9 l9 z
{8 _6 K  z: z4 ~
    FATFS fs;            // Work area (file system object) for logical drive' y( {! }+ a  G
    FRESULT res;         // FatFs function common result code
& r* u5 x, E3 i( \6 l1 o        FIL Make_file;4 \" M# d" K- q0 A+ u; E/ l" ?
    char file_name[20];
  X( w. l/ N0 z; v% r+ A: w    char Storage_buffer[] ="0";
9 X" {2 `6 u- K6 T& f        
' j' o% [& }& y2 z9 n        UINT bw;" ~( r8 J9 i$ b( U% Q# s: s# ?) `% h
        //检测磁盘是否插好: L' c. C' `3 s
        if( disk_detect_OK()==FALSE ) return;
; l1 `( G1 e( P/ S) V7 B         printf("\r\n inaert_ok:>");
; ^. t. w. _/ o4 O) y    // Register a work area for logical drive 0
) ~$ s9 A" V# B4 q/ x* @7 o( g    f_mount(0, &fs);# Y( B$ A9 E. Y- I2 _1 A: i4 e
9 |. r: h. ^1 D' g
        printf("\r\n Make file Name:>");
; k* J( }. j# ^  {3 ~; l        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
' K0 ~; c! {  I, T  U
5 j4 C3 H# Z1 J9 B    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 * a3 w3 u0 t9 Y' D8 ?
         printf("\r\n open_ok:>");: _* v$ i  c+ ?" X1 L/ @
         die(res);
' U  L0 g2 @. d' C    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  % I2 X: C) F" N  Q/ ^
      printf("\r\n seek_ok:>");
+ M! `# K0 m( r/ @         die(res);
/ N5 y1 a  a8 p3 v        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
9 U, Z1 U7 _' ~0 j8 S# g     printf("\r\n write_ok:>");4 n' j% J/ k; Q! v. ~5 c
         die(res);
2 n1 y' |+ i0 u* d2 j: ?        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
; Z% B( u8 _7 r        f_close(&Make_file);//关闭文件
# I, |1 U9 w+ t2 ^+ p        printf("\r\n close_ok:>");+ W. A' R/ z! E
( ?5 v! [6 ^% F7 @* M8 I
        printf("\r\n写文件测试OK!\r\n");
8 x! z8 n+ G' {2 v
/ z% J) ]# ?* y4 c" y' t4 Z        // Unregister a work area before discard it
. p$ H+ ~4 P7 s( p$ b/ k    f_mount(0, NULL);
- X. d5 X: ?5 N}& s' m+ v: ]* w# ?% S

$ @* m/ l& S9 k2 Z& `. q//The f_read function reads data from a file.
+ }/ o5 P# Z" U" E//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
4 C# O  j  N9 l4 H//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了, g. Q7 z1 n: q" K* W- N% A) X
//所以以后要特别注意这个问题。
1 h: f3 u' x* `6 w0 D/ K$ U& S8 `: c& i) J* Y" a
u8 StrToData(u8 * data, u8 len)) ~0 W! S0 l2 L+ J+ p
{# d& E2 ]6 l$ z5 u! k
        u8 ltemp;
+ Q' P7 L* N! J; W1 k9 d7 a        if(len == 1)& o) m: \' W9 a6 @8 r/ o
        {
# A7 i% c/ o; w8 @* ^8 M                ltemp = data[0]-0x30;# \! \# [% ^$ |6 E
" A! ~. B$ V( m! o% ^
        }0 L4 ^' e% H) v9 \- u- R
        else if(len == 2)
3 v  B4 U) u4 i/ U9 \% |  ?        {
5 `, G: j# J4 i2 u: p                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
* g+ t4 \& U+ L4 j( w+ J# Q& @- r$ u$ k" R7 u' ~& Q) l. L, i
         }
$ d; y& |/ H6 K5 i6 X        //else if(len == 3); O8 ^8 W5 J) ^
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
( D( Q/ ?- X  I2 M2 c2 l% z0 u0 O6 v. a% h  x( H; |5 l" g
        return ltemp;
1 h) K, m/ W* p9 b$ v: m        . s' @' e* g7 c- t3 ?6 Y. T- }5 z
}) B2 t2 H( R) l+ b9 j/ q; S1 y
) @) j8 O$ `9 r/ u7 e9 e
" T. K2 c3 E7 _) \1 f& A. Q9 k% S
#endif. Z( g% T% {* m5 T
# E- q' V' U+ y

  \6 J0 W! j4 o% k/*
8 g3 U. u+ a) i- N6 [5 yint main(void)
% j* H5 T) f- _6 V- G( h{, q5 I; Y9 t8 k
///////////////////////////////////////////////////////////
+ s; k2 u. F% [UART1GPIO_config();//串口IO口配置
6 u- ?! Z6 ^9 `; uUSART1_config();//串口初始化波特率为19200
& q9 D+ F2 Q7 Y$ m& ]//UART1NVIC_config();//配置中断
* `) V2 j* J" |. M///////////////////////////////////////////////////////////
2 t, S/ U. X4 ]* M3 j/ y6 V1 u& CSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式2 x# a7 \! y7 y( ^
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它+ Y6 e& A0 W6 J* m5 A( h1 E; o
Test_f_getfree();//获取SD卡的容量和剩余容量3 A; N/ a5 \6 q8 `
Test_f_read();//SD卡读文件测试
% Z# D3 }$ |' R9 t, ATest_f_write();//SD卡写文件测试
7 r/ Z8 Q' `! z1 m4 T/ A///////////////////////////////////////////////////////////
4 N- D  z+ o' P* Y" E3 Y    while (1)' P3 o/ q+ R. v, B
    {
& \6 B3 v$ ?" R. P9 u& S        //printf("好的");, I+ r+ y7 v* ]" G( w+ ^
    }
5 j7 |% P1 u$ f- `; \& ~* h}*/
0 d2 E- W( \. Y4 Y# m+ a) O////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" _! Y( H% u/ a* j  ]FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0/ _; o. V: E, d4 r- }8 g' X
{2 {1 `4 b1 Q- B3 y
    FATFS fs;            // Work area (file system object) for logical drive1 ^- ?! Q1 t9 _- y
    FRESULT res;         // FatFs function common result code, Q* V' A* f  Z% L' n
3 X  y; |) P$ N; H# N3 V
        //检测磁盘是否插好, I3 l+ G/ |8 x* h3 [( G
        //if(disk_detect_OK()==FALSE ) return ;
4 W* |2 a) d" D        //printf("\r\n inaert_ok:>");
$ O" h. {( }9 e0 u! C5 v        // Register a work area for logical drive 0
% f  b; y5 }- v, b. g6 m9 o& G" h7 U        f_mount(drv, &fs);
3 x8 w! J( x) y3 [7 n' M! _        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/0 I1 W! [5 H0 A
        //die(res);
' h! [  h9 E' H3 g& g        f_mount(0, NULL);
# i  s! }5 @$ k  q        return res;6 C) h& Q! u2 G+ E$ [7 S! ]4 t
}* \( z" s, S* |1 O* o  a
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% d! D9 @: b. F" i) N, P: oFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        0 M/ _4 a' x* S' v! Q
{
) M, w- G! \% Q( ]! t1 o    FATFS fs;            // Work area (file system object) for logical drive) l4 P/ S! a! w2 @1 S  r, d  b9 m
    FRESULT res;         // FatFs function common result code
# f! U+ P, d- T. M$ C6 `( M. {: Q- a/ V* W
/ w. o. ?" L' X8 I        //检测磁盘是否插好
' l+ `2 a  {5 @2 g6 A% b2 B        //if(disk_detect_OK()==FALSE ) return ;
; X1 f$ r2 ?. c+ x  }. `        //printf("\r\n inaert_ok:>");
& `# O! d3 V5 M9 o/ W; j2 @        // Register a work area for logical drive 0) ^( I' K% q+ N6 B  x8 V' [$ N. V
        f_mount(0, &fs);
" u7 s4 w/ G, m        res=f_mkdir(path);//创建一个新目录
# W. @7 V1 f( d7 S$ b$ f1 @        //die(res);$ g/ u( I5 v8 v2 ]  K# ~
        f_mount(0, NULL);
) E* `: `( Q+ _7 ]( Z; u% V1 [, R0 s        return res;
3 L- E* E8 U6 o}( E4 P: u! ^  ^8 Z
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7 O0 j7 e6 Q1 K2 b
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        
' x3 d/ g" X) l2 n1 c" z* d{  A' O2 `6 V. |% D) {, Y
    FATFS fs;            // Work area (file system object) for logical drive1 @) J& A) a0 M# I
        //DIR        dir;
6 ~5 t+ m' c  w4 P    FRESULT res;         // FatFs function common result code
% C; O9 q/ q7 }7 i/ |$ R( {* B3 `0 i5 T4 E3 x6 q6 A' R
        //检测磁盘是否插好
% }, T5 _% q2 N3 B1 R' D- o        //if(disk_detect_OK()==FALSE ) return ;
1 T9 k2 Q- @' @9 K! Q( @' [        //printf("\r\n inaert_ok:>");7 O, s5 D0 q" ^  H' R0 j  |
        // Register a work area for logical drive 05 g! s6 _+ U! [+ V6 E- o
        f_mount(0, &fs);
6 D; R+ k/ t2 C2 p        //f_opendir (&dir,path);8 Q$ B" b) P) x7 L% U7 z
        res=f_unlink(path);//删除一个目录0 W4 z* j0 u+ ~  a* `
        //die(res);
% Z7 ]6 o3 l6 \3 H9 g/ s" v1 @% K        f_mount(0, NULL);, p9 {6 J6 E. I  K
        return res;9 x, T5 X1 c# M; g2 ~- s
}5 p/ u7 o8 Y: N- F
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////# ~2 N+ F' b! \- i& ]
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
$ X4 o2 i. @8 M  z8 ]& x2 f{9 d# F) o5 m* Z6 @5 F' S
    FATFS fs;            // Work area (file system object) for logical drive( Q: p0 c# D$ h% l) ?8 ?& p& k
        DIR        dir;
! i0 A) h! ~8 G! K1 Q9 z        FILINFO finf;: E: a9 Z; X: c& V+ }; Q
    FRESULT res;         // FatFs function common result code
( a# Y/ q1 n0 p5 v0 q: j7 @- w. e! j# G+ e0 o- P% n* t' K
        //检测磁盘是否插好
. P7 r; H5 u7 w4 s7 m; Y        //if(disk_detect_OK()==FALSE ) return ;; J: v1 f; L# X
        //printf("\r\n inaert_ok:>");
$ M* \" g4 J8 n/ e: B+ ^: Y7 A% A4 v        // Register a work area for logical drive 0
- |% k3 c5 ?; r- V9 v2 o: X& r        f_mount(0, &fs);" m8 \3 p- l/ k$ E4 N
        f_opendir (&dir,path);$ N" r; X$ K; }
3 {# G$ b4 W/ V& L
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
/ s; a0 C$ r( e2 O        {strcpy(*(filename++),finf.fname);; u" o2 j1 M* I1 ?
        //printf("%s",finf.fname);% \- u0 I5 C# o5 d
        }
% h9 o8 V% X6 C8 c        //die(res);
- {- \. B, D1 h6 n7 o, ]: o2 Z" T        f_mount(0, NULL);
; _4 ^$ H, T7 Y& a' U0 _3 S: s        return res;# _! f6 \4 {, H6 r; y+ t
}+ b/ g  j. F6 R8 R& @& R" y
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
) R+ f+ Y  @4 q- i1 {+ B% S% j& DFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名
# A4 M( u  j3 [8 }4 f3 Y{7 y- l: W/ n9 i
    FATFS fs;            // Work area (file system object) for logical drive
4 A6 I. Y7 y% a% s& u        FIL file;
' ~4 f1 W! G6 N. D6 a    FRESULT res;         // FatFs function common result code% f- {, e* M, h" E' ?* T0 h
( s: Z2 M- h' k
        //检测磁盘是否插好
7 u+ x" N* c1 T# Q* v8 A3 g! ^        //if(disk_detect_OK()==FALSE ) return ;
3 J: X/ p- |& Y* ~( B: }: [        //printf("\r\n inaert_ok:>");$ n. ]$ x6 s. P- L9 D( a; D
        // Register a work area for logical drive 0
' [: ]  {" X. [  V        f_mount(0, &fs);
$ l6 i5 }  w- \, d: H        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
4 @1 Q/ ~) S' g/ w3 N0 Y                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
. ^5 K5 Z0 C, N' c                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。* m! @0 \3 g( C) F. I* O; M9 r  x
        //die(res);
* T% W* R% c& t        f_close(&file);//关闭文件0 z- V; J# r* N: A. {- I
        f_mount(0, NULL);1 y, c+ S# e& H" d
        return res;1 l, A. i" s2 E6 o# X
}8 ?& d7 ]. r7 s( i2 R3 @
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
& X  B2 e6 }; M/ a. l$ EFRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
$ u- v1 g6 _+ S2 X{# p: W8 D. h; V: ]+ `$ O, o+ Y# a
    FATFS fs;            // Work area (file system object) for logical drive- I' Q4 C0 F1 r
        //DIR        dir;
2 X) W1 g. j7 j    FRESULT res;         // FatFs function common result code4 s6 u4 _$ k, Z+ S. T3 l0 |! O  }

6 g# f1 d9 \4 n' b& F+ ~# E, g* R        //检测磁盘是否插好
  S* \! L$ Z# ^2 g6 T        //if(disk_detect_OK()==FALSE ) return ;
) {+ A) \( }* o1 h- n8 A" t3 D8 v; P        //printf("\r\n inaert_ok:>");: _) D# a& P; {
        // Register a work area for logical drive 0" n. _  A: L2 y5 B0 A
        f_mount(0, &fs);
6 g7 W9 @5 }$ N        //f_opendir (&dir,path);% R  h0 U* ^* G
        res=f_unlink(path);//删除一个文件4 ^- f, H# G# B( T% n
        //die(res);  G6 j/ c1 D4 X" y6 X5 J6 o
        f_mount(0, NULL);
+ r( H/ c' Q2 R% s: l0 Q        return res;. v" a; J: O; B% L
}
. Z" `; N2 V" }( H- @% b& v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5 H; s  S% t. Z( S/ f+ B/ GFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数3 c3 r0 R; j  d1 t4 U' l" ~5 P5 L" L
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
4 G  V; _1 \, m    FATFS fs;            // Work area (file system object) for logical drive
! `7 G9 d; k: R6 c8 ?1 \& X    FIL file;            // file objects( E' l" A5 q' o
    FRESULT res;         // FatFs function common result code4 G, X0 ]5 R) m6 a
    UINT br;             // File R count 文件读回的字节计数) P( R3 W. ]2 a# N5 p7 g
        //u16 i;+ M) A' z/ c( k0 }. X
        //检测磁盘是否插好" r2 U6 f7 Z0 [9 u8 X$ F
        //if( disk_detect_OK()==FALSE ) return;
5 r4 G8 P7 M* E8 c$ T; Y# G    // Register a work area for logical drive 0
; H& H- v6 I" N        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';
% `( y0 I. ^) v! A+ m+ E4 i5 r    f_mount(0, &fs);
- V2 W4 F% D6 J; B8 R" w        //Open source file. V0 [0 z2 S9 c
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误+ @% j3 f9 C* W0 V6 f5 ]
        //die(res);$ d' g' Z$ Y; [. g/ R. _
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
8 k3 q: f' G0 I- ?6 ]9 `# P" P( r        //buffer空间设大一点,会提高读的速度。7 Y; E  m, @7 V1 g+ `4 M
        //如果文件实际大小512byte,
' W# E" y! b5 |1 b        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
1 y0 `, d: c1 o, y  o9 f. Q7 ~        //for (;;)
, T: s% u8 j4 G# |. t7 G6 l: r  A) E        {
6 e% K, E; G2 }& u! L, m+ f, C                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存3 u; Q" d+ P2 h/ |2 H/ v

( P" E* r: k, _5 y: ]2 v/ q5 s2 u4 g                res = f_read(&file, buff, strl, &br);- b5 e4 B$ g7 j
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出
) g5 `. o7 ~% d7 }) K4 E' O                & c3 }) i# z4 s& F# f1 j& @
                //printf("%s",buff);        + `+ O6 g: b) X, W
    }                    
: U  N2 p0 g. ]5 i. z; V    // Close all files
: t5 @. g2 Y3 q5 v" f- B/ A    f_close(&file);
3 Y3 s$ U' V' o4 Q* _( e    // Unregister a work area before discard it
" l7 W( O2 z& F- d# E' ]    f_mount(0, NULL);
3 a! P! r& }7 j% a" ~8 E9 B, Y9 M        return res;
' v0 n3 n. C. H  T}" M, K/ Q+ W- q
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////# m6 V; E7 N: H
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数- p: E0 \- c* R2 w; R0 V
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));" y3 N8 b( r7 K. Y
    FATFS fs;            // Work area (file system object) for logical drive3 ^  U  [4 P4 L; \2 }, Q
    FRESULT res;         // FatFs function common result code
: k3 ^2 L5 x: Q/ Y( E! x2 C        FIL file;
! V/ U- s$ t( T        UINT bw;             //文件写入的字节计数9 ]  I1 a3 D. h3 `/ u  ]
        //检测磁盘是否插好+ X9 P5 p+ F* E" e2 M# n6 Y- p
        //if( disk_detect_OK()==FALSE ) return;
) J! C6 V% l% t6 @    // Register a work area for logical drive 0
+ A, P. ^# C6 x$ ~% f7 e    f_mount(0, &fs);
" h5 {8 M5 W9 V8 l% h    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
) @0 |) `* V$ A; m2 T8 J/ J8 c7 e         //die(res);
7 |* I4 q' T  ^4 l; [    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
; }$ e0 Z3 T/ i. B3 T3 r1 ~9 c         //die(res);! y6 _; ~$ z* y- R
        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符, P% ]+ s; r! X2 I" q7 R
         //die(res);2 ?' w+ N  o4 q% E, m
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
' N  F; C' I: j! G/ D. g        f_close(&file);//关闭文件
  K4 u4 ^  W& ^        // Unregister a work area before discard it
& ^9 F9 V2 g9 j    f_mount(0, NULL);7 ]* I3 r, S, P8 W/ W( D# @- K+ C
        return res;7 M+ z9 i2 x' t: w4 N
}8 F" @" P7 ~/ J/ y! v  v1 v( m7 j
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8 X; ?, w2 W$ S5 P
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M
; S. Z( ]3 V1 T1 U{
3 h: r6 X% F7 U5 z9 n0 o  A9 E% ]; u% K    FATFS fs;4 N: D# e/ \8 @' ^7 Q
        FATFS *pfs;
5 |8 d5 F( V' A  B; |6 R, }        FRESULT res;         // FatFs function common result code  u/ k5 s" }8 Q1 I5 B
        //检测磁盘是否插好& |! p  u2 c6 ]: K0 @& p) f) b7 Q
        //if( disk_detect_OK()==FALSE ) return;
( e: L& ?% |/ a' T* j* \$ o7 x0 d% y0 A3 c- O        // Register a work area for logical drive 0
2 A  ]  U" T* O# y        pfs=&fs;//指向
" V3 {9 \" @- g! K. a. U    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间" q, o& d4 V* ^  U( H5 b6 f- {
    // Get free clusters
4 T) [5 W* r$ O. a/ L! Q    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"( w+ V" O6 }& {9 P3 y
        //die(res);
. h& Q' v$ V4 a+ A* h% v1 [        if ( res==FR_OK ) 6 ?9 B. g- h4 r5 x% |9 Z
    {
) ~( f7 v4 B& K+ V" d( o" [" e            // Get free space' |4 C( D" @. E9 k8 T$ c2 G( [
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
- i' Q  m. p4 s  a( M               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
# M- T% A4 [7 v- ?' ?! P                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024( A3 d% e5 m4 h, {
         *freem=((*freem)*pfs->csize)/2/1024;- X7 [+ [' W9 J+ Z+ [4 s2 h5 q* Q
        }
; [( Q, K- k/ X) q( L8 W1 y        //else die(res);//测试函数执行结果分析
  k* a) e' l( o2 b, X+ J        // Unregister a work area before discard it4 N2 s# r$ G! C7 |/ O6 O. ]: V
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间/ y& L' d: I0 J
        return res;/ R8 S. Z2 q% g7 O# X
}- A% S) b/ i( r" T5 c

( W; X& n0 R! j' c* f1 ?6 R/ I: z
( f6 r0 y/ X5 O" D; L0 |3 }/ W6 D) ^  R
/ Feb 26,'06 R0.00  Prototype.
7 v; \3 I) z  k( `2 l/
6 D% J, w& R' F0 B% S/ Apr 29,'06 R0.01  First stable version.7 G5 J: r. U# S+ @
/
# S) Z4 l0 ?, f4 X0 p  ]/ Jun 01,'06 R0.02  Added FAT12 support.9 `+ H: Z: G; J; f9 q! A
/                   Removed unbuffered mode.
9 }# ^  O( }0 j0 e/                   Fixed a problem on small (<32M) partition.# Q# R0 N' {1 o5 u5 b
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).0 f- n8 |( T) B( X7 b
/& j$ L. H& o/ D# G# ~  u! O5 G2 B3 _
/ Sep 22,'06 R0.03  Added f_rename().* P  y- e4 Q2 l& a# k( h
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.  g, n0 P; Q( L& x, V% J0 R) p
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
; l0 s: _1 b' W+ E: |/                   Fixed f_mkdir() creates incorrect directory on FAT32.
* z. U$ P$ D4 [7 l  C! r/& D5 N1 Y( M" J9 Q5 [
/ Feb 04,'07 R0.04  Supported multiple drive system.
: K2 t/ A& _+ C/                   Changed some interfaces for multiple drive system.
* L7 c" e8 ?; ~: z) `/ U$ S/                   Changed f_mountdrv() to f_mount().% q0 }1 s$ x0 o! V1 @
/                   Added f_mkfs().: l/ R; X# a) ~- W
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.5 A0 ]; r( U! j# E9 T1 w
/                   Added a capability of extending file size to f_lseek().5 A! q# G+ U: \2 l3 V2 T1 o
/                   Added minimization level 3.
% q% ]* x+ l5 U( W' \  J/                   Fixed an endian sensitive code in f_mkfs().3 M& r" l8 N+ Z6 q
/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.) P, l, p. }3 K2 k' y4 p4 c5 s' Z
/                   Added FSInfo support.
. K6 L# u8 _- d% u2 d* L/                   Fixed DBCS name can result FR_INVALID_NAME.- u/ c1 `2 D6 ^, y% F8 m7 V" V
/                   Fixed short seek (<= csize) collapses the file object., }7 K7 X/ D1 y3 w) d# _  C
/4 P# J3 G/ m: `! |, ?
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().' Z' o  u, T. ^0 r, }
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
' |/ [# i8 z: Y8 ]: @9 o; a) f9 S8 l/                   Fixed f_mkdir() on FAT32 creates incorrect directory.
5 f7 k: T" b' H- \2 a/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
0 F% q7 O, y. O' H' ]1 N/                   Fixed off by one error at FAT sub-type determination.
0 b6 p/ y& r' O/                   Fixed btr in f_read() can be mistruncated.. l0 B1 C; p: q6 j! Y0 G
/                   Fixed cached sector is not flushed when create and close without write.$ D6 S( ~" V$ j( l
/
3 j$ b  t' {0 K8 ?4 S4 X/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().8 M1 k/ E3 L! g, g% g
/                   Improved performance of f_lseek() on moving to the same or following cluster.  S  f- Y: B9 p
/4 o: |: s; I0 C; J+ I5 n0 [
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
2 b( d8 Z5 c3 E3 V9 ?4 ~/                   Added long file name feature.& l  u: F4 t3 o: P% v" g+ K
/                   Added multiple code page feature.
4 A; B2 H5 D! J) Y4 C  v3 [; a/                   Added re-entrancy for multitask operation.
" H, u+ G7 r9 H8 _7 c/ f9 j/                   Added auto cluster size selection to f_mkfs()." r# A# V: u* N% n/ N  r4 b
/                   Added rewind option to f_readdir().
8 N/ `& l! c: J1 y/                   Changed result code of critical errors.# Z* L) D" \: l
/                   Renamed string functions to avoid name collision.
) g9 c5 Z. O% j/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg., t6 B/ j$ W- X" n
/                   Added multiple sector size feature.# f1 m* K; Z9 w' u9 ^
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
9 O+ H" u) _2 Z3 u( s$ W1 ^/                   Fixed wrong cache control in f_lseek().
. l3 j. C, s0 v) t& Z. \6 y1 V+ d/                   Added relative path feature.
5 x/ D+ t0 \" u: O* L/                   Added f_chdir() and f_chdrive().
. B, y. [( e  E/ f( o- m/                   Added proper case conversion to extended char.
/ X; v; k7 h7 L' W; P/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.; g, J7 U0 w6 {& f$ L: U( x/ n
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
- k4 H6 o9 w/ C# Z/                   Fixed name matching error on the 13 char boundary.
) }' {! P: ?: y. s2 @/                   Added a configuration option, _LFN_UNICODE.$ Q7 c* Y+ F6 O
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.$ x" o/ t7 h- n# k% h, m, P2 P! t
/( _7 }! r0 }; b0 X% U
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)7 E; P9 ^) H" o: ]* }
/                   Added file lock feature. (_FS_SHARE)' @5 E. M  M' u3 L
/                   Added fast seek feature. (_USE_FASTSEEK)
& ^) J; w4 T" U. Z; a7 \/                   Changed some types on the API, XCHAR->TCHAR.* Q* d- k0 U+ N% `5 C
/                   Changed fname member in the FILINFO structure on Unicode cfg.& [6 I" f# B5 X6 \4 P1 H
/                   String functions support UTF-8 encoding files on Unicode cfg.4 X6 G& r+ ^8 q, |6 W
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)% G7 J7 T6 X0 }$ `% I
/                   Added sector erase feature. (_USE_ERASE)
$ ~8 p/ T6 Q7 h* g" i$ ^4 P: _7 {. a/                   Moved file lock semaphore table from fs object to the bss.7 L  Y# C' Y0 u( Q  N. W
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.: O5 U# r# u$ y# t1 m, n
/                   Fixed f_mkfs() creates wrong FAT32 volume.
+ u7 w* ^3 x0 r" y% a/ G2 \/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
/ h" u+ Z% W/ x. u% P/                   f_lseek() reports required table size on creating CLMP.0 }; s; |8 S2 A" `& r: O5 g
/                   Extended format syntax of f_printf function.
' o! S# D* u/ B, g( j/                   Ignores duplicated directory separators in given path names.
1 N. ?- v! Z. A% x8 c: v7 v/  b( E5 B( y' h7 v; X/ l
/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
) O6 F6 `1 k, w5 I  C/                   Added f_fdisk(). (_MULTI_PARTITION = 2)4 _# X3 b. ^9 H
/---------------------------------------------------------------------------*/: L1 P3 c5 P! k+ @, t
6 L3 k$ Q! e$ x6 Q; u

STM32的SD卡FATFS.rar

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

分享到:  QQ好友和群QQ好友和群 QQ空间QQ空间 腾讯微博腾讯微博 腾讯朋友腾讯朋友 微信微信
收藏收藏1 支持!支持! 反对!反对!

211

主题

652

帖子

1507

积分

四级会员(40)

Rank: 4Rank: 4Rank: 4Rank: 4

积分
1507
2#
 楼主| 发表于 2016-4-28 10:04 | 只看该作者
您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

推荐内容上一条 /1 下一条

巢课

技术风云榜

关于我们|手机版|EDA365 ( 粤ICP备18020198号 )

GMT+8, 2025-2-1 14:04 , Processed in 0.070744 second(s), 35 queries , Gzip On.

深圳市墨知创新科技有限公司

地址:深圳市南山区科技生态园2栋A座805 电话:19926409050

快速回复 返回顶部 返回列表