找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1392|回复: 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工程。下载即可使用。6 o' }" L6 g! A8 Y+ N. S
/*----------------------------------------------------------------------------/3 v0 `7 b* G! g6 u. i9 h3 R7 T/ h
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
+ z9 p3 U5 Y# A: p0 j& o/-----------------------------------------------------------------------------/% l3 C/ ?% v- g
/ FatFs module is a generic FAT file system module for small embedded systems.$ O  j7 U0 P9 M
/ This is a free software that opened for education, research and commercial5 ]% x  \3 N" I% L
/ developments under license policy of following terms.
0 W; R  q' V: s6 C2 M. b2 X/5 }  O- c8 U  c4 ^
/  Copyright (C) 2011, ChaN, all right reserved.
2 \2 {6 t9 u; \4 T3 Y/. u9 r; M* b+ d8 z
/ * The FatFs module is a free software and there is NO WARRANTY.
- c4 G; O8 W8 U7 z+ b/ * No restriction on use. You can use, modify and redistribute it for7 N& J! Z9 U% R' d, l! r% S
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.& g/ V% g, h, O% r4 M; [' t
/ * Redistributions of source code must retain the above copyright notice.  k" T! k3 |/ R+ `/ _
/
2 @6 J1 |# i" [7 y/-----------------------------------------------------------------------------/# y5 u6 L  x$ {. u( H
& z; [2 s# r: E/ @8 B+ ^3 y" C
% u" u9 j* L$ Q6 W6 P5 j
/*--------------File Info-------------------------------------------------------
( P1 m+ B- U5 A" E) A+ |** 文   件   名:  FATFS_Function.c
, u9 \+ K) L/ C' L; x( L" O1 o$ E** 作        者:~风中的叶~    整理
% f2 ?' y9 x. A5 U: A0 z** 最后修改日期:  2012.01.18
' E6 b  [0 y  S. t- s+ ]: k# o. T** 版        本:  V1.0
+ K; v0 y2 m. W9 D4 P** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
- U; W; i- u. w; {  K**------------------------------------------------------------------------------  o* v- n# p3 Z- J
** Created   by:  Dt.
9 I/ f. r+ O4 }7 x6 W** Created date:  
9 }: s# ?4 F. H, m9 [+ ~8 D2 X*******************************************************************************/
% L2 a! t: N) u5 Q% F$ p- m4 m% x#include "TEST_FATFS.h"5 B  _. g  Z9 S# c$ X  O
#include "string.h"  I4 E5 M" u/ X3 W; K9 C7 |
- u# p2 ^6 ?+ n  b2 ~7 B4 w) d/ \
#ifdef TEST_FATFS_EN
+ [/ o( _5 I* _+ L: c) g) j+ }( q/ N) H( g3 B# x
6 N2 H- b0 F. ]( q. b- Y" b

2 I  k. S! \- O//检测磁盘是否插好0 _% p0 X3 x. s5 \7 L/ }
BOOL disk_detect_OK(void)
; W/ P4 B% y" _0 G( {{
4 p1 ]& L3 k5 q' H9 C    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
! h- }& O6 Y9 s9 O( T" C        {- D0 @8 h5 v( r2 W0 P9 a
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
2 i* \! T- I/ q5 N                return FALSE;: `# L# B" r9 ?9 m# A: g2 M1 b# t
        }# j9 f4 N* ]2 m! p9 T
        return TRUE;: a- L! q) z5 b
}
  Z$ x, z; s6 c( c/ |
0 x- d* O+ ?1 {: f7 y, }; B& [8 X7 B. g' Y) _. ?# U- p7 o

6 k& V. |  v$ N% ~4 |( m/ g' E//测试函数执行结果分析
1 b6 V- ^( p1 S- ]' J! U* t8 uvoid die(FRESULT res)1 c/ b/ T  @; k  o  ]5 ^# p
{5 Y1 Q& {7 ]4 i/ e/ U4 T
    switch(res)$ m. i" G1 v( i) ]5 }7 y
        {2 j- z4 S  d" ], \& ?
            case FR_OK:        //The function succeeded.
' E3 r( N8 @) A4 y4 Q                {4 u6 Y2 B, P4 W, f* C# K
                    printf("\r\nThe function succeeded!\r\n");4 S+ p" }: y) W
                        break;9 Q3 J* y' ~, s7 z) L2 B) g
                }+ _5 X* `6 ]/ z) L3 G- C8 p
                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
2 Z6 U  x3 Q8 o6 B: I                {) ^! s6 l0 a3 L" T
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
7 Q, O2 n6 j' l. `2 Y                        break;
) B. f) `8 _7 D' X$ Q                }- D( a# L' T* D, z; Y1 G" }
                case FR_NO_FILE://Could not find the file.
. |+ o$ B* F3 R8 F  R* C" m6 O: K                {
0 \5 D2 }& `5 Y' k! k' t, w                    printf("\r\nCould not find the file!\r\n");* D1 K' |& n& h
                        break;2 p- l- l. V) I4 H# u9 f  O
                }
; w* \1 m' m1 G3 b0 z; a! F                case FR_NO_PATH://Could not find the path2 |) t- `7 V, X1 Y' t5 m
                {
# g2 l3 C8 B, l  y' u                    printf("\r\nCould not find the path!\r\n");
$ F5 ]  e4 ~8 s6 {3 b: T                        break;2 v# K8 Q1 z+ F6 a3 s; A/ c
                }0 `, d: ~) K2 x2 u5 A) ?4 @
                case FR_INVALID_NAME://The path name is invalid
! g! P' a. D) _3 H- @! h                {
- s  B9 ~. H& x' Q0 s                    printf("\r\nThe path name is invalid!\r\n");
& i" x5 \( z- w8 g                        break;
8 T* [. ^8 `" C6 }                }! L& m6 l2 C+ f' \; Q8 Y
                case FR_INVALID_DRIVE://The drive number is invalid
6 Z( [$ ^" `) [4 x* B8 X                {4 I9 e" Z6 z( `
                    printf("\r\nThe drive number is invalid!\r\n");4 @- Z! l2 T# c2 V4 L
                        break;
0 s$ X' z  ?+ [4 `) b                }3 }$ E" K" \" @3 @
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. * D2 [- b, g+ p( q
                {
4 s6 O! p; w# [( j6 |# |" M% `                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
, m# i6 @0 c% r( ]  p6 i1 {                        break;
3 N, @) r, T9 s8 A- m                }$ y& H) b: X5 l5 h
                case FR_EXIST://A file or directory that has same name is already existing
" E4 @9 q; E7 O, I: ^& X                {* d5 m) Y) ?) P1 c% m
                    printf("\r\nA file or directory that has same name is already existing!\r\n");
, L4 ~. U/ X' d6 A( z3 j                        break;
' P; g% m( \( I' [9 g                }
) _1 b2 I$ e8 z* g. H5 ?6 U//                case FR_RW_ERROR://The function failed due to a disk error or an internal error! j! }0 f" c& l2 ~- i
/*3 G' o: Q3 M3 d
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
6 P! C6 {- @. ~- ]# ^% |0 W/ U                {
% Y# _8 r3 Y) c0 r! }& t                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");; O: l9 F& {- p5 l9 l
                        break;/ \9 u7 e2 Y# a* z+ t
                }6 A' K9 \8 Y0 s# P% Q
*/
: C; B. g* ^( t% ~9 I) P1 h                case FR_WRITE_PROTECTED://The medium is write protected
2 ~+ ~( h1 U; l" ]5 d                {
6 d+ v) O' E& B  `6 @. g                    printf("\r\nThe medium is write protected!\r\n");/ Q9 v% l+ F4 }' e3 u) k: b+ b: X
                        break;
" o# K3 e$ M" n8 ^                }% L, {6 l( ~- A* o
                case FR_NOT_ENABLED://The logical drive has no work area" g! N: C1 Y' l( X0 y
                {* q  A% v3 N% r7 T9 f- e8 O# l/ t
                    printf("\r\nThe logical drive has no work area!\r\n");5 A$ j2 o; z$ \; l
                        break;
& y* s& C, f8 q- c0 m  C                }
& b7 z& l4 t6 j6 Z1 b1 v                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk- I7 Q+ G/ u4 N6 p4 S5 t* R
                {9 e. f% J; y% ~" v. f4 \8 e
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");" k7 a. f; t" _% j- j$ r
                        break;
6 A: j( ]1 R1 v                }
" z* k  h% q2 {, Q& y                case FR_INVALID_OBJECT://The file object is invalid& q1 u. l0 n2 f* B& ]  \. C
                {9 r  d; L9 A& W$ j- L
                    printf("\r\nThe file object is invalid!\r\n");
! d2 t; B) M% h, m% K* Z                        break;
5 K, ], |$ q% T( c9 r                }5 o: d+ u& U; v; ~' f

& a9 R/ @6 V- F; u: S9 \            //The function aborted before start in format due to a reason as follows. & [1 S! S) j3 n# s3 W* D
        //The disk size is too small. * U! Y0 n) r; R. |8 N
        //Invalid parameter was given to any parameter.
2 d8 {& K- P) h+ P+ n$ m+ _" \9 O        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
$ n" B$ d* W0 w. l; M& B                case FR_MKFS_ABORTED://& k6 u9 N- f) r" q9 n" H  u8 q
                {+ [, e7 _) N( j# A
                    printf("\r\nThe function aborted before start in format!\r\n");
3 \% G. t6 I! n/ D. f0 Q9 Z, w                        break;* U9 Q. `  G5 ]+ D
                }
/ C# u4 }$ v! J                4 w; Z+ G2 {" F9 ~# y/ m" S) O+ e( H1 u
                default:! P, k3 _. e* T8 g0 j# q
                {
0 }: G, F7 ^! v  N3 n9 o: \' v                    printf("\r\nerror!\r\n");
- W" Z3 y5 G! u0 `: l* f0 `  F                        break;$ _7 D- ^) x# J+ s) p
                }        
' C% @2 b9 R, f5 e& q4 z        }& t9 M; N$ k9 j; g5 d" a
        return;
# D8 z% i; @5 i+ @: ?  m5 U8 P# V}
0 P! o; v5 z, a+ H$ \void Test_f_getfree(void)//获取卡的总容量及剩余容量7 M$ w% ?% `% b# N$ n
{
* e& z8 b+ ]2 g% m0 R9 O: A    FATFS fs;5 n7 X: O* a9 R! r# D+ M  C9 N' `5 o8 n0 A
        FATFS *pfs;
  Q1 }8 y! I! t# v* _    DWORD clust;
" H! T. g  R: N% m- ?        FRESULT res;         // FatFs function common result code, a7 I' M) R. t' ~) a5 [1 t

3 l, b  j: J! _* I+ h3 k: z# M        //检测磁盘是否插好
! |- R5 Z9 F. J+ N' L; R! n        if( disk_detect_OK()==FALSE ) return;
4 p* a) B' u  G! f. ], d" r0 N: J" K. c! s, I) K0 A8 v5 l: i5 V; o
        pfs=&fs;//指向
& n* @% }) F- Y* [/ q        // Register a work area for logical drive 0
6 U7 N( K7 A# m5 x    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
9 W- u9 I' j  @2 b8 ~1 @( M* A" G* X
    // Get free clusters7 {- ]' e! \8 _
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
( K. K3 d$ P! f$ d1 t2 m    if ( res==FR_OK )
- ?1 @4 [: s6 s. R. m/ c6 f$ u    {
3 A* w" n. q: v            // Get free space
# q4 D" T7 j* _0 o        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",2 G5 V% c9 p1 v4 _5 |5 w( D9 `
                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
9 j7 T* C1 ?8 v+ s- D% }! v                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10243 _8 @- V: E* E5 g
        }
/ K( v2 F9 x- _  L) k        else die(res);//测试函数执行结果分析, w0 O7 I& I& o0 h. e0 j
        
' j. k- M6 `  L/ V, ?        // Unregister a work area before discard it8 o) Z8 x4 Z# ]9 x( K# P
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
5 `3 ]5 Y. ]+ U! `9 L}
& l9 f4 I" I+ e: A. N0 N9 b) q: X2 e8 o% F5 w  ]
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
5 v! G& q% U* ^6 v  u- x{" K* U2 p, q$ \: i0 M$ G5 m
    FATFS fs;            // Work area (file system object) for logical drive
9 S3 y, y6 m( v    FIL fsrc;            // file objects7 x% H, E! g/ Z! F5 y
    BYTE buffer[512];     // file copy buffer; o, W) T0 ?; p, e
    FRESULT res;         // FatFs function common result code4 a$ {4 a3 d* j9 a/ d7 d& h% P2 f
    UINT br;             // File R count# o6 Z; B# s' l6 o/ @9 S5 L  ]& `' U1 H
        u16 i;8 h  @2 }' M3 [8 P9 x5 S. D5 @8 D
        
- r: u. x% {  n9 a! X1 d: I  t* z+ i! q5 b, `
        char path[20];" s( \0 |7 r: u  b

5 L3 l7 ~+ S; g        //检测磁盘是否插好  v9 ?0 z% \- a
        if( disk_detect_OK()==FALSE ) return;9 x. [6 l7 Q* k$ _

, D$ J5 R) |5 q2 [: @    // Register a work area for logical drive 0$ x# n0 J. u% Z1 o' l
    f_mount(0, &fs);' ~  E* _% {/ Y2 M% S
' ?" `" X0 o. A" [! c
        printf("\r\nread file:>");& w5 s  G. |% v; S
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt! @1 U  }: t+ v2 N

/ b: k/ T" a$ N        //Open source file$ J% g$ M9 V/ m5 ^% C# V3 e9 u
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
5 F5 w# R7 G# ^" t+ B; j9 d        die(res);
4 O2 C. x* b$ R: ]8 w! V" H; l" j        
, k0 P2 c3 M2 x, q        //buffer空间设大一点,会提高读的速度。
& u) I6 P5 H/ f        //如果文件实际大小512byte,* G! K: _, y6 J2 n+ H1 U. w
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。2 \" U2 ]' M8 ~  `& Q) x* F
        //下面两行主要是去除1s误差。1 [0 T8 F: f5 c0 ?5 B: p, o
$ S5 L: o  I. @) e0 n4 _2 d
        for (;;) 9 i/ B5 s6 F% t
        {
2 S; m" Z( R- x9 [" }                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存- o- t# x  X( b7 H$ T6 e

: T  F# Z  E- G- ^& A0 v! [  B                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
; H/ y  I+ q: ?        if (res ||(br == 0)) break;   // error or eof        4 B  e- C. H2 z, @: K) x
               
# I* {+ t7 g9 J( w( v1 r& p5 d                printf("%s",buffer);        1 G5 |; ~  {4 J
    }9 D4 ]- q7 J' |
8 a4 q1 [9 S8 Q
                            0 b1 u' C% l8 ~8 K2 R& o
    // Close all files! c) A0 b7 \/ a) I6 C$ e) Q
    f_close(&fsrc);" ]8 }5 \% W- m7 B; ?1 A
    // Unregister a work area before discard it
+ |# n4 R! _) L) O9 p7 o    f_mount(0, NULL);5 D& h1 K, j2 H+ t
}
1 i3 s, p, T4 C! n' f8 o, \0 ^) F3 e4 ?+ O7 o6 P$ M
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件3 c+ W$ z+ f* u# @4 e7 ?+ f0 ~
{6 b4 ^: v7 v( e" Y. q  D& c
    FATFS fs;            // Work area (file system object) for logical drive0 K+ k" M7 @/ ^# n1 n
    FRESULT res;         // FatFs function common result code
! _. e0 H) j! s: k( v        FIL Make_file;1 Y0 E" t2 t8 T( S- w. w* i1 [& ]) c
    char file_name[20];
& r. L: J; |3 |: H6 Y    char Storage_buffer[] ="0";/ ~" e  b  \+ k) A: n# i
        
/ q6 \6 ^! J0 L  r* m$ ]/ E        UINT bw;
: L" J& e  o; M( H) J% A0 [1 E        //检测磁盘是否插好$ `+ J$ h% w- }  m8 `# B' G
        if( disk_detect_OK()==FALSE ) return;" q7 h8 X4 h* t0 n0 Y; l* v# G
         printf("\r\n inaert_ok:>");
+ I7 P+ S: m1 Z    // Register a work area for logical drive 0
" Y' k9 g0 f$ Q3 w# l# @1 Q    f_mount(0, &fs);
8 ?- [. i8 O8 e' ^% R8 ]4 H* h& |5 W7 [
        printf("\r\n Make file Name:>");
: `( q: r$ N+ [8 w; b. O4 e5 [        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt5 V' \9 B) ^) @/ Q" h! r# `4 {

1 E4 Q$ `4 I: @' i# T    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
( C1 n, `' |5 c/ C9 k         printf("\r\n open_ok:>");
! }* h3 u) ]+ F7 d         die(res);
" m" h- o" M* Z+ v$ {. a    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
* R& c, T0 Y) i5 f8 ]      printf("\r\n seek_ok:>");* R2 B3 D. y8 b+ X( e
         die(res);
& |6 ~7 F1 R3 Z; X6 v/ S+ n& a        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
; e7 Q" l& {! Y7 B  |' r/ R! I     printf("\r\n write_ok:>");
8 ], h% A5 T6 J6 S) o1 s0 @, |  Y         die(res);4 `$ v9 ~- I  ?3 h- p
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后    l: r; o7 M: X6 I" }% O
        f_close(&Make_file);//关闭文件
6 K- }4 y0 H9 ]+ A        printf("\r\n close_ok:>");2 d' q) q4 @, _& ^( `: I6 M

% y( ?4 W* M8 k" s        printf("\r\n写文件测试OK!\r\n");
' [; x! U; w7 w" l2 n( @0 m" b- D& N& t( s; k
        // Unregister a work area before discard it; l6 {8 b4 ]9 r
    f_mount(0, NULL);
, s& w' }6 f8 x/ ^, a+ J}. u+ d( p/ h2 ]0 _/ Z2 A
. [4 i$ b5 n# n" v  n0 P& L" a
//The f_read function reads data from a file.; }5 o. a5 @" t" W5 p9 X
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样9 u8 l0 P( w; q: q- u  |! Z  X
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了, T- A  ~, ?5 d- {" m  P: q* N+ s
//所以以后要特别注意这个问题。
! V! m+ i5 X; |  i6 r" A
9 ]7 n* s7 q/ @  L1 Eu8 StrToData(u8 * data, u8 len)
6 Q) {& u6 _/ J! R{
0 Q' h2 z! b" b- N4 E8 o  ]* q6 `& O        u8 ltemp;
" a8 g0 P$ |; T  ]3 f        if(len == 1)
" i; k% E* s# C; b6 h8 ]        {& I+ Q% i- S5 W3 z
                ltemp = data[0]-0x30;8 T. i! y1 A- W- K5 M+ M
# k8 T3 U8 ?  c( O9 z
        }
1 [/ X8 ]2 l! V        else if(len == 2)6 h) M1 V: j4 B$ X
        {+ u6 l/ u% }" g3 Y
                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);7 X! U- J- [% Q* G1 k

4 w) q  E4 L6 H+ ]4 n6 v& x         }
" h9 U6 r7 N! x8 H5 [        //else if(len == 3)
3 R" r2 D* r7 G/ ?& r                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];% ]8 X$ s' }+ b1 }  h  c  J
/ n( T7 F) `+ g, K2 a5 Y, D
        return ltemp;
2 `8 Z. y0 B! Y, v# k3 l8 h        1 D( @# x! T& y
}
% p3 E% B% O5 f8 t- G) `; C: Z- N+ p1 ?+ m' g& A7 @

; s; Y# {3 |6 q$ G( y6 B6 Q#endif
* U, w; H& t2 a+ s  B9 c* I$ b( ~: B5 @" H

5 l/ V/ ]; [, r1 ^/*
7 u1 o$ o5 Q/ g" h0 A0 nint main(void)- ]) D/ R# I% A( d' \$ U
{
  ]" c# t$ e! ?1 Z0 \) ?4 {; H///////////////////////////////////////////////////////////( K1 B& d2 v8 f8 j9 L
UART1GPIO_config();//串口IO口配置
5 M" Z* h3 ^  A8 [7 }, ?USART1_config();//串口初始化波特率为19200
. J* j) M) K+ s3 j8 u7 n- L//UART1NVIC_config();//配置中断
9 U8 w# }1 F+ J& v9 v///////////////////////////////////////////////////////////- ?% P1 F/ b9 J
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式6 B' C: b) }0 J7 {- `$ v7 c
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它/ X9 y0 b0 i5 @! ^4 I
Test_f_getfree();//获取SD卡的容量和剩余容量
) K5 H) P; U0 Y/ i( A& \Test_f_read();//SD卡读文件测试
( r* m2 N5 `  e$ A* C. gTest_f_write();//SD卡写文件测试; a4 s1 S. l6 a6 H! n2 K$ C/ m! e
///////////////////////////////////////////////////////////
3 e0 f- _# I5 T& p0 Y    while (1)1 O! I7 h& L: L/ @- C8 b7 Q/ R; N
    {' S) j7 \* w; ]0 {
        //printf("好的");( y5 l" s3 J2 n/ E: {3 [# |% q
    }
4 z8 ~1 E3 W# z6 S}*/9 B( V/ X5 t8 E9 B1 E
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% [& G0 N1 Q( ]9 H/ L1 x
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
1 @# w( o# l( s4 Q* g+ e{
  N9 L+ W( f# Z/ V    FATFS fs;            // Work area (file system object) for logical drive
# E) S5 j! {, d) ]: c8 C6 {    FRESULT res;         // FatFs function common result code. n8 b( m# M3 E

  w) ]' E1 r8 ?( \3 Z) ?        //检测磁盘是否插好
2 H# f  p+ `$ U' Z6 b' ]" l        //if(disk_detect_OK()==FALSE ) return ;
4 B  h1 J# v& N. n        //printf("\r\n inaert_ok:>");
# P, k. V) q2 n, e1 c        // Register a work area for logical drive 04 J8 t% q$ s. O" D* ]
        f_mount(drv, &fs);, i# L+ z1 M" J0 o# A0 c
        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
3 ]+ m8 c' |8 ~; }. a        //die(res);$ H% B- M6 t" b% D9 N% @
        f_mount(0, NULL);# |) ^# A% h9 t, d
        return res;. q8 P! y+ {! O& U/ P, z1 H' U2 ]
}
* P1 E2 j+ I$ [2 Y' w; j8 u1 _////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////' @- V9 }/ \  T& Z7 M/ e1 s1 b7 Q
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
) g8 u6 X* u; ~- q{
" t" `' c; ]& ?5 P$ @    FATFS fs;            // Work area (file system object) for logical drive  r5 H2 V( M- F4 D
    FRESULT res;         // FatFs function common result code- U, E: t9 n. v0 z- ~9 s

6 o9 w2 ]2 z0 [/ q+ V        //检测磁盘是否插好
! p/ \! D4 M, M9 O        //if(disk_detect_OK()==FALSE ) return ;
# j( A0 W' f, e% t        //printf("\r\n inaert_ok:>");
! ^; A9 n7 p9 B- ?+ z        // Register a work area for logical drive 0
5 n$ W, R2 J9 S1 h1 |( O3 W        f_mount(0, &fs);- ?2 R9 F9 z. N/ d! B
        res=f_mkdir(path);//创建一个新目录9 I$ X1 ^$ ]0 f( J
        //die(res);
2 p6 q  l/ E7 q3 H  d& }% L        f_mount(0, NULL);. {- n" {$ y2 P$ L/ o
        return res;
$ o) ]8 L5 ]! ^}
1 x* f  }! t; u: {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////; L; S/ @1 ]7 {1 x' ]9 l  n
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        ' x! k9 b: M6 F% ?% j& |
{; }* v8 ~9 u; d% Q' h
    FATFS fs;            // Work area (file system object) for logical drive. }, a9 i$ ^- W4 F" Z
        //DIR        dir;
/ o3 K/ K$ e& H, d8 N( `: V    FRESULT res;         // FatFs function common result code3 ~: r6 |; C* g9 f* K
: x) M( i; [; g" U
        //检测磁盘是否插好
7 Q3 D) V6 ]" k( }. z        //if(disk_detect_OK()==FALSE ) return ;
! z# g+ j5 ~; V1 h& J        //printf("\r\n inaert_ok:>");
1 R/ Q6 i# v$ x* E2 C2 `! ]        // Register a work area for logical drive 0' s& a" m" c- V  n
        f_mount(0, &fs);2 Q3 Q; H: ]1 ~/ P6 h, j6 |* {7 l
        //f_opendir (&dir,path);! o. ?) w) ^* }, c
        res=f_unlink(path);//删除一个目录
! K9 ?4 ]6 J7 a9 @        //die(res);; }1 x1 X) s+ P  g
        f_mount(0, NULL);/ Z$ a' H% u' j) M0 a
        return res;
* [/ x4 d; q! Z% g5 ~, s6 q}
( S) ]% Q0 j1 s7 D6 s" F& B////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////2 D  @2 U6 m( s0 r+ S0 _- [
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
% s. D. e" o5 D; k# d/ C6 ~{
9 ~( o& \$ g- J% N    FATFS fs;            // Work area (file system object) for logical drive
; I8 j. b( ~& b! l! q        DIR        dir;2 p1 i! @; |1 \' I8 M# r6 [
        FILINFO finf;! K4 G$ s- z7 F2 l4 `8 W
    FRESULT res;         // FatFs function common result code1 y! Z% L. ~; `1 f" s3 q

, `( |" W4 i" H4 D( d, U* l        //检测磁盘是否插好
6 t9 E* X" H! v0 I6 c6 p        //if(disk_detect_OK()==FALSE ) return ;, }: m8 @1 H* c4 j  H' D! H& M# z
        //printf("\r\n inaert_ok:>");1 V3 X5 y) H9 s/ ?( c
        // Register a work area for logical drive 0
9 V+ A( T  b* O+ W3 B        f_mount(0, &fs);) }" L3 ]5 z5 a
        f_opendir (&dir,path);8 M8 t2 W* K5 ]2 @; \# }
1 e9 b8 q6 W8 o5 j/ v
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        . Q) J( R3 ]# E) M! D" L
        {strcpy(*(filename++),finf.fname);/ m6 G5 V( G# Q; H+ Q6 J% T  ^: `
        //printf("%s",finf.fname);
& f: Q9 b3 b  b4 ~3 ?        }' B! k) u2 O. x+ o  r, q8 P- ^
        //die(res);. @; w* w( b( D- A
        f_mount(0, NULL);
9 K  m" N( U) F9 y; L        return res;
  H9 w. d$ m5 ?4 m8 y. p}+ r& {4 Z3 Q' k( H  O3 z: H3 k
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////3 ~, h, a9 [  I5 b+ F$ O8 ?( V5 p
FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名9 q- J! k3 l9 [3 N, D# H
{
9 U: w- S1 z9 g0 x* y& x* f    FATFS fs;            // Work area (file system object) for logical drive
. e/ _! O- q4 N- D( b        FIL file;
/ N: }8 Y1 x! }( \" {1 }    FRESULT res;         // FatFs function common result code
- D0 R9 V0 q* ~8 m! M" _; s5 J. K$ ]9 A6 P+ m6 e! x
        //检测磁盘是否插好
4 I# ]# d4 E8 Y* v% b# h" a1 [7 G        //if(disk_detect_OK()==FALSE ) return ;
$ V6 [4 X, I1 W, b        //printf("\r\n inaert_ok:>");
6 e1 Q1 f+ T9 n/ [0 B' }" N/ f        // Register a work area for logical drive 0+ ?3 h+ M# }% A; w  j
        f_mount(0, &fs);
2 v, x) \( D. y( H8 c0 Y4 r        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
% `0 u4 }" K1 S                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
- ?2 m& p8 A/ T+ ~' A# O# L                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。; c. l) H! F3 m) y
        //die(res);
* \, A. y% \! p; i  V        f_close(&file);//关闭文件
8 q6 b& d5 V1 t        f_mount(0, NULL);/ I' b* E# N+ f' m
        return res;
/ L* ~: p* F3 Y* B. d4 Z4 W0 _# ^+ a& m}9 T  `, h" k, ~2 ~# t% r  Y# E" N/ Z
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5 W! u$ j2 N& N* D1 f
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        & |# z1 J+ h/ w# n9 r. Y" V
{
* Y/ G* q) Q$ n" }$ y    FATFS fs;            // Work area (file system object) for logical drive
2 E0 ?' l2 s2 E        //DIR        dir;
1 h$ f) h% F  E  T1 D" ]; E    FRESULT res;         // FatFs function common result code8 N4 q+ ]1 x, B) P
3 v' r5 q; i: }# L
        //检测磁盘是否插好
5 `) m* W2 Q' {1 f2 }3 T        //if(disk_detect_OK()==FALSE ) return ;9 {$ _! W1 d8 N& W1 Q$ E
        //printf("\r\n inaert_ok:>");, C! A9 _$ i5 a
        // Register a work area for logical drive 08 c; L2 z5 R2 j$ y
        f_mount(0, &fs);
/ R9 M4 e* D2 D% u8 ~4 {8 a( M" t        //f_opendir (&dir,path);2 j. s7 G# B! H, B& j
        res=f_unlink(path);//删除一个文件$ q: m$ C4 E5 S% [* K% [
        //die(res);
2 I5 c, e4 {3 J0 X        f_mount(0, NULL);8 q4 b3 e" r  x7 x) f
        return res;
6 D5 P3 A. r  A4 {. Z% c}
. ^% A8 k' O6 y, a+ G. S////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0 v  X# W7 G/ Y9 YFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数! u8 D9 ^& d5 W2 d5 A! L
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
* ?) }" ]( `. A; c% H+ g$ T+ A* a    FATFS fs;            // Work area (file system object) for logical drive
# U& a( I2 J( e$ {3 N# m    FIL file;            // file objects; A" g7 W3 s& z* m5 l
    FRESULT res;         // FatFs function common result code7 W. m" D: \! J$ V9 v% b0 [
    UINT br;             // File R count 文件读回的字节计数9 f- J- o2 t( \- S5 W# |) P
        //u16 i;
* o5 K  w- @0 p, w! t5 @9 ]        //检测磁盘是否插好
# _1 P; f# U4 d        //if( disk_detect_OK()==FALSE ) return;  p7 z1 p. G* _+ M* s) v4 p
    // Register a work area for logical drive 0- K4 C1 ]; `7 a% A
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';+ M6 T# N* O6 |" Q; y
    f_mount(0, &fs);  q6 L2 V0 t: l% B
        //Open source file: m5 G: r/ r1 K% Z
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误/ N; V& D2 `  a3 _
        //die(res);, T( n4 D/ ^9 g' b6 z
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
5 A- M: }. U/ X        //buffer空间设大一点,会提高读的速度。
3 Q- R4 U% a) d, \        //如果文件实际大小512byte,
: e" X; Q. P- E1 v* @6 L* d( b6 M) P: F        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
7 A1 l2 a1 M9 Z5 F        //for (;;) ( {! X3 `6 z, o
        {! _' u, T# P0 x# R
                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
# `0 I& [3 p" B0 {  ^; Z4 Q8 C2 C0 |0 k$ n
                res = f_read(&file, buff, strl, &br);
0 {& }' [9 D9 _& O  Y. K* G# \* u        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出
/ L; b2 X5 {7 o: p               
2 S0 o: Q) Y  r- I1 {" T- c! J                //printf("%s",buff);        ' l, V1 ]* R4 {/ T
    }                    0 D- {- c; h: p; ?
    // Close all files
& _+ T" m! C) H4 e3 _6 H) ^/ G    f_close(&file);) ]" V5 L+ ^1 R9 C2 E3 T3 u
    // Unregister a work area before discard it
. S) ^2 ?- X# g; B" |    f_mount(0, NULL);( `) D6 n0 \2 u- A
        return res;
1 Z( }. d4 f1 b* s/ q0 l}
0 Y# p8 b. ?( t$ k2 z7 R, u' M  O. z////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% m$ L- u: M4 w6 {/ B% ^+ T2 ~) `
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数. }+ ^$ F+ B  n; d& P
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));
  W; u; g# p2 F6 m, G1 ~# R- H) ]    FATFS fs;            // Work area (file system object) for logical drive$ E* ^! J0 O6 S4 X( G; f; L8 ]
    FRESULT res;         // FatFs function common result code6 T  w) |6 J: p" f% P9 o' r
        FIL file;
' K) j" {' C9 e& r" }        UINT bw;             //文件写入的字节计数8 f4 i) Q9 r/ B- s, C8 M
        //检测磁盘是否插好
4 m" Y6 `9 R7 ?        //if( disk_detect_OK()==FALSE ) return;
% e- U& I( o9 l    // Register a work area for logical drive 0, S$ n7 K! b& K+ w
    f_mount(0, &fs);( C2 e0 n2 ]# F2 D7 \
    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
2 o/ q, t$ v/ Y8 Y2 m1 ^3 h& x4 F         //die(res);# Z$ {2 j; e- @  ?
    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 ! }: a" x+ }) x" \# ?$ F
         //die(res);
2 {0 d5 k/ y& ^" w* Z0 d        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符
3 f4 z6 c$ X0 b& X: |. J: m! @         //die(res);$ ?- g/ U$ X* J1 `' b7 j) C, N1 T' K5 A
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  6 t  G  Z3 R+ o. ?& X. S. G
        f_close(&file);//关闭文件! o  O( P# A! w9 ^$ m& \
        // Unregister a work area before discard it
" T) \+ J' O! d7 ~+ n+ _" l    f_mount(0, NULL);
. L9 r* d' C2 O' n- [4 W! B        return res;& N! \* x1 f9 M- y; h5 S5 s, H
}$ r9 W! |, n* ~+ _- L
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////- |5 e& o7 Z$ L- S3 A+ X, n
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M
) u2 u+ G! ~' g# i" S7 e! a6 w/ {/ r{
2 Q. x4 j5 W0 m4 F! C3 F8 G9 H    FATFS fs;, h8 H! w6 \2 [+ ~4 I9 F
        FATFS *pfs;  u* {' R0 E6 B( G; w
        FRESULT res;         // FatFs function common result code3 `, g$ v: E4 v1 y+ y8 B* p
        //检测磁盘是否插好
1 c9 ~4 q$ A& g        //if( disk_detect_OK()==FALSE ) return;: [$ D" q' V7 ^1 L, E+ y1 D2 Q( V
        // Register a work area for logical drive 0" ?, j& Y3 {& D0 Q, \
        pfs=&fs;//指向& P9 P$ _4 a+ A1 a2 J; I
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间& b2 A; v8 v9 G1 A
    // Get free clusters
8 r7 y7 W  a( ?    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"9 X7 V, o2 \: z; d( \- F
        //die(res);8 V. x- l% |8 u) K% `5 w
        if ( res==FR_OK )
8 i& n/ {8 t/ c, R    {
. ~6 R) `, ]+ s3 E% u; ]) G3 {6 f            // Get free space) G2 i3 r( F  N; `. U
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",0 h) j- M4 h3 w0 Q7 v0 D- M
               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
) U2 J! w  q6 a! [: u                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10242 S' w4 R+ O' K0 [
         *freem=((*freem)*pfs->csize)/2/1024;
' Z% {/ _. P2 o2 \7 \        }
: q2 q' T, W; X7 R4 C        //else die(res);//测试函数执行结果分析
- D% p8 U, \, s! B        // Unregister a work area before discard it
: o+ M$ n; l3 M6 f2 v9 K    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
' O$ \0 j9 Z! o9 |& O! I        return res;
' w4 {6 j- y6 g% I2 ^4 E}' b& j% l0 {( C" Y
. x0 X' a  l' t* n2 b

0 \' b, f4 J  }' ]1 U" Y9 l; A% |
* W4 y: }& a2 f  B/ V$ D/ Feb 26,'06 R0.00  Prototype.
! M4 L& W* @* i. b& J( E/( e3 N+ t6 z, Q" X5 n5 e* p8 [5 F! a
/ Apr 29,'06 R0.01  First stable version.
, [, @( ~% x( ?/& \- D4 a. h; `" y8 L" z
/ Jun 01,'06 R0.02  Added FAT12 support." b% A3 h4 I$ `+ a6 u1 v0 O
/                   Removed unbuffered mode.
0 W+ t' _, q5 {% L- s. j! m/                   Fixed a problem on small (<32M) partition.* o$ u4 w. X0 g4 o1 C
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
1 T, C7 U: S2 e/+ ^2 s1 v" c  O0 t
/ Sep 22,'06 R0.03  Added f_rename().6 f1 {! L0 g/ }+ v' q: f; e9 h
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.' T( w6 ^/ U3 C
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.4 k5 D9 r9 |, M3 ^
/                   Fixed f_mkdir() creates incorrect directory on FAT32.+ Y9 C' w  K7 \* E& b" A* [, p" G
/: c- F' n( q. }0 J: ^9 A
/ Feb 04,'07 R0.04  Supported multiple drive system.
% E, m( M# i. j! A5 |2 _3 V/                   Changed some interfaces for multiple drive system.
. C: E) U: \5 z, m) q' N6 G( W/                   Changed f_mountdrv() to f_mount().
5 q3 [$ i1 g3 b/                   Added f_mkfs().
5 ~# D' s% p( W2 C% `4 Q, |/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.
! p( o5 r) g' x/ _. R& Q5 f/ k/                   Added a capability of extending file size to f_lseek().  v- F" j" o9 T. R# z
/                   Added minimization level 3.
+ P. L! L- S0 }# Z% h5 R/                   Fixed an endian sensitive code in f_mkfs().
2 B6 f! h- I6 I/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
& c% l* `# N! _  |/ d' o/                   Added FSInfo support.& y4 y  C7 ]& x( y0 N/ i6 R9 Y: r6 o
/                   Fixed DBCS name can result FR_INVALID_NAME.& S) u  _! I( B  x
/                   Fixed short seek (<= csize) collapses the file object.
' U2 g) h6 x3 V, i, c0 L4 w) N/
- V! c' K/ R& T. O6 K* Z( d. Z/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().& c9 N4 G, Q0 a! ~6 Q
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.8 X% X! r  r8 m, U( b/ [
/                   Fixed f_mkdir() on FAT32 creates incorrect directory." u9 G) E4 l2 |2 d$ h
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime()., O* g5 p! I( a7 Z% h
/                   Fixed off by one error at FAT sub-type determination.
1 v/ }: j% `' Y8 t* l: n" P$ x3 A/                   Fixed btr in f_read() can be mistruncated.9 h% ]( {/ U' q. c! c7 U
/                   Fixed cached sector is not flushed when create and close without write.
7 M, G# E# w6 s( E' J! m/, h% j; \% X0 O+ G3 t% _7 x
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().
) L6 k$ @8 L; Y/ @' z/ Z' ?/                   Improved performance of f_lseek() on moving to the same or following cluster.
2 y! U, }1 C' o# W/8 }' f2 L* u# o9 Z2 c; {  x
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
1 }; _+ Y; _8 x8 b) v7 B/                   Added long file name feature.7 u- c3 Z' ~/ Z
/                   Added multiple code page feature.+ j: Z0 X) I- F" R. c5 m+ d% f
/                   Added re-entrancy for multitask operation.4 ^# d8 ]! y( T
/                   Added auto cluster size selection to f_mkfs().( l" R% ~0 f' o. K9 x' k8 [
/                   Added rewind option to f_readdir().
" Q5 }  ?0 d/ p) B6 Y  E/                   Changed result code of critical errors., c' s" u7 {8 E5 G8 E
/                   Renamed string functions to avoid name collision.
, \# P& u0 ~* H: w3 U/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.* ^3 D0 d/ V7 b
/                   Added multiple sector size feature.7 g% w6 I9 g' |$ `( W; L! J
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.! G5 Z- ]/ m$ S
/                   Fixed wrong cache control in f_lseek().- R& W4 ^: q; ^* `
/                   Added relative path feature.% Y* ?1 d9 F6 |; E% i* ~
/                   Added f_chdir() and f_chdrive().$ S) C' i2 d7 M0 C! s
/                   Added proper case conversion to extended char.
" {) p! w3 ?. [# n0 X/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.) n- [. c  U1 k6 b; S# u; B/ ?0 D
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
1 K4 \* U; f, J* x% F* K# M5 }/                   Fixed name matching error on the 13 char boundary.
1 r( X) s; o% |8 J; J: D! y, s# D/                   Added a configuration option, _LFN_UNICODE.. ^! Q* ^( ?" N  ~5 }" J, v( A
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
: J" Y% ]3 u& b2 H/
, x% O4 T, X; Q" E2 I  r, K6 m/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)0 g1 Q8 p- b4 q( ], o
/                   Added file lock feature. (_FS_SHARE)
4 T% V( H6 ~3 q2 f2 b/                   Added fast seek feature. (_USE_FASTSEEK); _. ^5 X4 r! C6 w+ A
/                   Changed some types on the API, XCHAR->TCHAR.. J: \& {$ z( N6 h7 \
/                   Changed fname member in the FILINFO structure on Unicode cfg.
  D! J1 I! T$ `" ]/                   String functions support UTF-8 encoding files on Unicode cfg.: S6 p# h9 l' u! l& ]( w9 E4 E
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
1 m; g! U9 K% N! ~/                   Added sector erase feature. (_USE_ERASE)0 O4 Y, f( _+ B( O5 E5 M% o9 P
/                   Moved file lock semaphore table from fs object to the bss.
/ v! E1 u' B+ ^% R' u9 ^3 Q! P/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
3 f: X, u( s* _8 ]/                   Fixed f_mkfs() creates wrong FAT32 volume.4 i5 }0 ]5 M/ c$ c: g% M
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write()." z" x, Z. n5 z& m/ Z
/                   f_lseek() reports required table size on creating CLMP.
* c8 M# W' y+ N1 K/                   Extended format syntax of f_printf function./ h/ _. S# t6 T* A7 e
/                   Ignores duplicated directory separators in given path names., p" l! z# p# F" y, I
/
) Y/ i, L# H, R: j" u9 Q' r5 Q- z/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature., E0 {3 ^4 K5 I) w+ t/ U
/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
/ N3 m8 \# f7 ?2 [  M/---------------------------------------------------------------------------*/
7 X6 G( R, z  ~2 w9 E
4 A: n3 B% r( f  T2 n

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-5-26 09:10 , Processed in 0.064265 second(s), 35 queries , Gzip On.

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

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

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