找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

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

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

[复制链接]

208

主题

649

帖子

1492

积分

四级会员(40)

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

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

EDA365欢迎您!

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

x
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK  STM32F103工程。下载即可使用。9 K, A+ E/ ]0 D
/*----------------------------------------------------------------------------/; I: W6 h. {) e
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011/ y6 o; t- g5 J) x  x6 f, J  I
/-----------------------------------------------------------------------------/3 G4 l- P9 K8 w9 t
/ FatFs module is a generic FAT file system module for small embedded systems.
1 |8 s; R& Q% Y& d6 q9 ]/ This is a free software that opened for education, research and commercial
6 p( U) T* g% ^% C2 m0 Q' D/ developments under license policy of following terms.
% s+ G* _4 C1 z! y) z& b# J/ J: N/
/ ~0 D! _9 W) ~4 L, k5 F) |/ E% k/  Copyright (C) 2011, ChaN, all right reserved.
: I, E. v6 p% f2 K! L3 q/$ I$ [1 S0 n$ X. V5 J& S) f
/ * The FatFs module is a free software and there is NO WARRANTY.- x6 W6 Z6 D% C/ [6 |, |( v
/ * No restriction on use. You can use, modify and redistribute it for
, v- ~7 v4 D3 q5 ?4 J! Q4 N4 V& @2 F/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY., k( q' q$ r& Z, z+ u
/ * Redistributions of source code must retain the above copyright notice.
  O/ m; m0 w" \2 q, t' ^/6 \3 Z8 ^$ ^& H+ O% r! T% n
/-----------------------------------------------------------------------------/1 T  J) v. {( u, A6 }% c) X. v

# i9 i& Y6 {8 ]5 h1 x" w" I5 {" Q% `( a8 }5 E' _+ M
/*--------------File Info-------------------------------------------------------
0 a. w, }  C) c& [** 文   件   名:  FATFS_Function.c
# W( t$ l- s! A! I** 作        者:~风中的叶~    整理" N. p5 o+ X7 o* y
** 最后修改日期:  2012.01.185 s( @( F& O! ?2 i! K
** 版        本:  V1.0. m- a6 \. d6 E
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出* o. c* h2 q7 u- W0 |4 j
**------------------------------------------------------------------------------
5 V( {/ U' n0 a! K** Created   by:  Dt.
7 N, b& q7 R' ^* c% u3 h1 b. }** Created date:  
* Q" ~. G* W" S0 d; Z. A*******************************************************************************/
; Y" W: W( {4 m" V# T" c8 V/ R1 v; I#include "TEST_FATFS.h"
  e+ _6 n; z. R/ Z/ @#include "string.h"3 G) @9 |  _1 }1 ?

- v. R0 b& Z7 O7 a+ q0 S: r#ifdef TEST_FATFS_EN
3 z% B8 W- K! Y; P* z/ G. ]; B( u

1 y+ g7 X! E/ u. C" v- J
, o4 y) a# A5 s/ I% v//检测磁盘是否插好
. O' h5 y7 A1 G" e8 EBOOL disk_detect_OK(void)1 Y; h7 s+ j3 F
{
2 {$ S8 ~- x. F" f! P( L" y    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */- w: v& r( g* f( v# I
        {
2 O, V9 ?1 K' u1 Q, h1 f            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");1 Q( c- M7 x! v1 i3 v8 Z1 ?
                return FALSE;% g/ U! P1 e% q0 c0 G! V! `
        }5 m  @1 Z) u& U5 v* V1 K, b
        return TRUE;
" Z9 n$ b- v% Q: |! k  {0 W. @}
0 b! y: q7 L2 U7 [
- C# s% B4 ^' x! Q0 @+ c, i" A4 i" x- N: r; ^
* X8 E* w  F; J( a# l
//测试函数执行结果分析
" Q7 l( p" U& x7 V" z) [8 Kvoid die(FRESULT res)
3 Q' X1 l! }' L# Y( n{
; m7 p1 o6 j, r8 V8 y2 h    switch(res)' h$ y  b# R6 s3 F
        {: g" k' @; j, T6 b9 A. L8 a9 Y" C
            case FR_OK:        //The function succeeded. 3 n" ^, h7 V* s" u
                {& v% P; U7 {7 ?) c$ G4 z: `6 ^* v6 I
                    printf("\r\nThe function succeeded!\r\n");
2 n0 S9 Z# k) v6 t: H/ x4 G                        break;. x3 p  o, |- ?4 s/ F
                }& `5 v( O. q) s( l/ O: E! U  J0 A
                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
1 d) G' ~/ V. F                {* Z+ @$ t5 z- A- @* N
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");& a- ?$ I0 a; j- t- y
                        break;
$ N( p9 F# {1 x/ N                }; k2 d* @% L% D$ g9 r- K( O% @
                case FR_NO_FILE://Could not find the file.# W3 Z; A/ R7 M* C
                {
. |1 t8 |, W# |                    printf("\r\nCould not find the file!\r\n");$ |; R4 C$ `" s! X9 b
                        break;5 ?' Q% k% y% X4 c
                }& Y, m9 [8 b. Z+ c, t8 V
                case FR_NO_PATH://Could not find the path! C$ b# e4 B9 \5 A$ K6 W- `
                {
0 R' u1 q5 H4 O. b' A4 ]                    printf("\r\nCould not find the path!\r\n");
9 X0 h2 [! o: z6 y: y% g6 o5 R                        break;* \; Y2 d6 A  V5 B+ y: v4 U
                }3 l- s* d( _) S3 Y
                case FR_INVALID_NAME://The path name is invalid7 P5 t0 t+ s( c
                {# Q1 x+ A8 @# c" Q/ {; f( Z( w" i
                    printf("\r\nThe path name is invalid!\r\n");
, j0 n5 ~: o1 {  r8 E                        break;
$ B* ^; \+ ~) i, C                }
, W7 f* f+ m: o' q7 m8 @                case FR_INVALID_DRIVE://The drive number is invalid) [7 P; w1 G* m
                {8 c+ G% n8 l4 v8 N: Q  @$ m; O0 N
                    printf("\r\nThe drive number is invalid!\r\n");  \3 h( ^  J0 }. J( F/ ^9 K, P
                        break;0 R% [" B+ U9 J# X
                }
% o( Y# u5 e) q" d+ r6 Q" w% D) T                case FR_DENIED://The directory cannot be created due to directory table or disk is full. 1 `% ^' f& N/ e5 r7 i
                {0 p5 m! D  O7 N. U. l2 k9 z
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");: n5 S, C* z2 H
                        break;
* o2 [& F2 I0 _0 f1 Y                }
) U& k3 @! N- h3 u- W: H/ G, }0 A                case FR_EXIST://A file or directory that has same name is already existing. [% A" Q% ]: @/ x1 u" c; y6 b9 N) q
                {& @! P9 B4 M8 ?
                    printf("\r\nA file or directory that has same name is already existing!\r\n");
9 n; R+ y9 t! E' U. [% t                        break;% Y0 V1 ]: Q$ F$ r/ _9 s
                }
, `; N) `! a; U# Y! E& t$ S//                case FR_RW_ERROR://The function failed due to a disk error or an internal error
3 N0 \3 b' n7 p: T& T/*
+ O& @; ~: F, D- H6 Y  j8 _                case FR_RW_ERROR://The function failed due to a disk error or an internal error' b, C3 ~; h8 N# e" o
                {# n4 a$ d! t6 |+ C2 i
                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
2 {4 H! b( Z# ?" V                        break;
- x) i; `# `0 O0 X- w                }
: y# o4 z; }0 X: D*/# \' V6 N8 C2 T- E" h% ^+ c4 ?
                case FR_WRITE_PROTECTED://The medium is write protected
2 J8 l, j: G9 w; R% Z                {4 u! A- ~+ D' O# c* i4 M4 ]
                    printf("\r\nThe medium is write protected!\r\n");
/ p' e) N2 Y6 _                        break;0 A4 j- Y, X0 t
                }  a# H# {, _0 W! a
                case FR_NOT_ENABLED://The logical drive has no work area
. ~9 s+ A; n2 ~+ q                {, z& I0 Q' C# y/ w; d8 c- L
                    printf("\r\nThe logical drive has no work area!\r\n");
. t. e6 B' c- A" H9 U                        break;. M& n+ p( B' s& E
                }5 I6 M1 ~1 t  T3 }, \
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
9 u. w* P3 R7 u' J+ s                {! X" W) V6 \0 E; T1 Z1 Z2 |
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");
& Y* @9 w0 ^' |: X" ?                        break;/ L/ M3 Q( M+ G3 x0 t; U( o/ n9 T* z8 l
                }: y, z) u5 n1 {, j/ ~5 J( k; s7 h
                case FR_INVALID_OBJECT://The file object is invalid3 e9 Y7 _/ D* A" V' c4 m8 P2 [9 E
                {! Z3 g+ {$ M0 D% F& J9 k! C
                    printf("\r\nThe file object is invalid!\r\n");
! N) D/ s' g1 f" I                        break;
! R# f2 J0 t) ~& J* F+ X6 n! Q1 x                }( s- O4 X' N0 u, d9 Z1 _

! [8 e8 q& Z# T+ s" X$ X            //The function aborted before start in format due to a reason as follows. * H) Q2 P. C* s  q6 D& j% P
        //The disk size is too small.
7 R, k" d  S0 _0 |- ?: B! Q        //Invalid parameter was given to any parameter.
  Z3 Q; r4 N6 R/ E8 y+ ^5 Q        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7. ; E5 I( _0 X1 j) [$ s: T2 S6 L/ {
                case FR_MKFS_ABORTED://4 ^- [6 ]: _: Y8 ~
                {. {" W% g( B4 A' p) u
                    printf("\r\nThe function aborted before start in format!\r\n");
6 P' h" H* {( V                        break;
) k- D: M" H$ g                }4 [5 ~3 g4 I5 d. Y7 L6 d) p: y
               
' c$ O! _# m7 m; \! b+ B                default:$ ~* N1 Y# _5 \
                {1 ]; _  r/ z$ V( g  X/ l' E. x
                    printf("\r\nerror!\r\n");# \* w1 X4 H$ ]: }7 w9 |
                        break;: X, _! O' Z) i8 _6 g4 @
                }        
: |& F& K3 c$ n* S5 g. I3 {5 b; d        }* d0 k$ h  N1 P; y! z9 J
        return;2 a' [; I2 A6 Y: t( P2 e1 T
}* ]- P% Z8 r% R8 }: m; ]& P! }3 o
void Test_f_getfree(void)//获取卡的总容量及剩余容量% H% W; b% f8 ?4 z
{1 n) k# O6 q" `) b* j6 S
    FATFS fs;
; r3 `. W6 G& F- k' ~6 H        FATFS *pfs;
& q& {) V! u4 U) w% {2 P6 P9 h: F    DWORD clust;
) D# `) o; {* a0 [( L- S$ U9 N2 T        FRESULT res;         // FatFs function common result code
7 L# J$ |/ F) _  G! @! b' E/ k+ W2 `; y- {$ d- o
        //检测磁盘是否插好
+ F& g( [% k" y" C0 V) @5 ]& }, J        if( disk_detect_OK()==FALSE ) return;
# r1 l' h6 H' \2 `0 p/ t. ]" G0 B! ~; p( A) }8 x( V$ I
        pfs=&fs;//指向
! w" a6 j5 Q: ?% s& o        // Register a work area for logical drive 0+ o7 m4 y5 v2 E. G8 _
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
& d3 u$ P8 v4 e/ l) f+ k7 z
5 w: i, s8 I: v( n) q6 |; m7 J    // Get free clusters9 _0 R1 M' U6 y* ~# W* H1 G/ }1 P
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"1 N& l7 X" ]6 O0 r/ ~* Z, g3 n
    if ( res==FR_OK ) # m& \! q9 o& {
    {
0 e& i( \" u4 {% B" I            // Get free space
- F$ K5 N2 E' H: c1 @- E* h" j        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
& Z+ m" j- G2 ]. S( C7 j6 H. Z+ {                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
% W1 m0 D3 u/ _- f                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
, T0 I" E9 @: D# O+ u        }# I8 w& q# s2 U& y% ]( E2 K
        else die(res);//测试函数执行结果分析
" X2 g* Y" d$ `& T' w( s        ' F" F7 k1 A& }2 X" d3 k
        // Unregister a work area before discard it* Q! z/ c# J' U5 h
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间8 d6 V% @+ f* u
}
" a: R; M/ k2 v+ ~  N5 [
8 ~  K% W" v/ Hvoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
) S; J+ [& l' Q9 ^- ~  j/ K% |{
* s6 n4 {/ o- T0 U    FATFS fs;            // Work area (file system object) for logical drive
# h* \0 z' H$ G; S, `- c$ i    FIL fsrc;            // file objects+ Q& ^& n0 |0 @9 m! d
    BYTE buffer[512];     // file copy buffer6 m- ~5 h" h  j- S, W7 \# |# f
    FRESULT res;         // FatFs function common result code5 t& D* y% u% f# M/ E/ `
    UINT br;             // File R count. Q5 g4 j9 A1 W6 J! G* L
        u16 i;
- m5 n/ U0 g6 n/ _9 j        
5 E+ J5 ^+ \% b1 h& t6 x
  S7 Y' C7 A  o( d        char path[20];% _7 S% c7 X$ ?* w

% d1 X/ ~& ~$ Y8 k# }: z1 w        //检测磁盘是否插好
% v" N/ _% L: X7 l8 a        if( disk_detect_OK()==FALSE ) return;
- L% a% [' [4 |! L+ \! |) t0 |1 m( o' u5 M1 c
    // Register a work area for logical drive 0
) j% E: k* {# K+ ~    f_mount(0, &fs);
% z* O9 q' o6 m0 i9 H$ ?- j
7 Q. }4 {! ]7 [5 ~9 A: K        printf("\r\nread file:>");
- q& c2 R& v) S8 g        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
5 P0 i/ t0 {$ ]! n: C
8 [* P) H, b( [; G7 s# y) N7 n4 W& _        //Open source file* v, d0 W- P$ c. _- _0 j
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
# F+ N% W6 k) D  X$ I        die(res);& g/ X; d+ {9 A7 K' a$ C
        
7 F6 n) q9 M3 P. c' x8 y, Z, x& V        //buffer空间设大一点,会提高读的速度。8 O( f7 O9 m3 O+ D
        //如果文件实际大小512byte,. ~+ S' g5 _* [2 a' @
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
* m  \2 V4 S) e& v# d        //下面两行主要是去除1s误差。
1 {( ]4 X- S) A! s& `
% @+ y& |2 e$ o        for (;;)
8 B2 U2 e1 [/ d+ K# L/ M% n/ `: Y0 J        {
; i) |" b0 s3 x9 N. [* ]                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存
: M1 P( z. O  j+ Q3 t1 O% }, k
                res = f_read(&fsrc, buffer, sizeof(buffer), &br);6 Z, ?4 |( h- h/ \; f" @3 @( I
        if (res ||(br == 0)) break;   // error or eof        6 p5 L  o" R* x5 o2 Z
               
/ `, r1 K. w# M0 W& Q" q5 p) h0 e, E' X                printf("%s",buffer);        ! Y; t  {$ }* ?
    }
! M% J  l" W: Z( t% ?6 _
, h( P/ J2 [9 f+ C  ~1 x- `7 m                           
  K9 n1 V2 K% k. t    // Close all files& [+ `8 @' V% z3 U/ K* @- s
    f_close(&fsrc);; S2 E( y" j4 G+ m
    // Unregister a work area before discard it, |7 z) f8 z  w
    f_mount(0, NULL);
- n3 T3 z& S9 a" g" a) K! e/ j5 U}7 T1 I  N. ]) b5 j; M. y7 V
1 ]2 u5 {/ s1 O; S5 [0 {  Q
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件+ j" |( z* k# I6 X. I
{- h& O0 Z& _8 P
    FATFS fs;            // Work area (file system object) for logical drive, D, l' Q: O# K1 Q: z
    FRESULT res;         // FatFs function common result code
1 d1 z5 M# S: n" d( [        FIL Make_file;
' [" ?. b+ N9 w. V+ v2 t7 F  s    char file_name[20];- Y* @% ]( ~* a$ G( X
    char Storage_buffer[] ="0";
3 z* q& b( g) t+ T        6 M& k: x+ Z; S5 K4 }
        UINT bw;# p* u6 K0 {3 c& ^6 H( `
        //检测磁盘是否插好
! E" d5 m3 p- X9 C1 p2 b        if( disk_detect_OK()==FALSE ) return;: Q  [0 J+ S% c8 N. `4 R
         printf("\r\n inaert_ok:>");
( x0 B: {  _- h# e7 m2 R% l% p$ A    // Register a work area for logical drive 0
9 w. G' _  S9 h. J! S    f_mount(0, &fs);
* A6 T2 @. F  ~6 ?5 [* b$ h6 H& W3 h, e* N
        printf("\r\n Make file Name:>");" j4 a2 D! {# R: G0 t7 s! }
        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt9 U6 I8 V: W- o& n6 Z
# u1 ]: u# T1 R; x; Q6 b
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 0 P% X0 a: F* T+ d, C
         printf("\r\n open_ok:>");
! b! L$ M9 e8 D% c( I; @$ s         die(res);! c  l6 y8 m# D6 t+ y4 O% @
    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
, G" i8 v% _3 n- Y* ?" C# q( s      printf("\r\n seek_ok:>");5 K4 x8 F- ?; J- f. o
         die(res);4 T# B, K9 V3 c# t- _) j
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
# K2 b; ~+ E4 j7 |& d" s     printf("\r\n write_ok:>");
; q0 W. [" {* M+ r8 K+ l         die(res);
$ M3 ?8 N# s$ [7 t" F  o, x        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
' W0 Q/ w+ k1 ?1 t. G4 m        f_close(&Make_file);//关闭文件4 x6 b/ M0 I/ ~
        printf("\r\n close_ok:>");
7 d4 {' R# v0 |% w6 S+ p
. F7 P4 b! k7 h( T. T0 o: c        printf("\r\n写文件测试OK!\r\n");  Z7 i" `2 a" G: a! O% D

4 M0 J# a7 [; g' j  i; G        // Unregister a work area before discard it
% E1 i, \' ~  g9 _    f_mount(0, NULL);
/ a- G: t0 Q) h3 o}
0 p) L, Q3 @! `  H5 W( M3 v2 c+ C: @  Q1 s# n& ~  i
//The f_read function reads data from a file.
$ B: Y: D+ G4 e//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
# S* g4 l) G3 G//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了4 b8 l. X8 a3 c& I6 z5 ]7 k
//所以以后要特别注意这个问题。2 A: r# N4 n6 M2 T

% G1 c0 B* c! a8 {) D/ Ou8 StrToData(u8 * data, u8 len)
5 V. V; W& K+ X1 ^{
; I4 ~# V: ^; {# r) b* f        u8 ltemp;
$ G4 i( U4 n$ ^% o        if(len == 1)8 `6 e" z9 r9 T# }( p4 Y
        {7 V% ~+ C; W  z* z
                ltemp = data[0]-0x30;# I1 t8 Y. X. g; l

8 X7 l6 R4 ~9 Z) n8 A0 L        }% m* W! t# l: j/ B9 a
        else if(len == 2)
5 R  A/ `3 ^# c. x4 g' h0 M) P        {
9 `. i7 {. F: C1 d8 W8 a                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);' \/ q8 n8 @4 [4 w; j
6 j" F- E5 I" u8 S, S2 \. n' u
         }9 c; t; k1 C) a; U: z# q9 D; l
        //else if(len == 3)
; k& a( [) Y) o7 B! T                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];1 F( n8 K8 r+ ]: Z  ~

6 h( K+ }4 a6 W. L! c$ |        return ltemp;
0 i) V6 d0 v1 a" v, S3 V  q        3 X! g5 S) m2 S2 c5 F
}3 A% l2 K: ~; W/ C

* T6 _0 y) q: h3 i5 J9 `4 ]& E( M$ @! y
#endif
/ s# k+ K9 E( H$ z; t' q  i
, z$ d8 F7 o. H
. h; _: h5 S3 G, K! K/*# O: [1 [* R5 r7 c% S+ @) T2 J# x
int main(void)) F0 E  E9 s  M$ i* Z6 u! T
{
- N; ]* @" Q# Y" P" r' C///////////////////////////////////////////////////////////
$ ]0 B) B3 J: {/ I1 ]UART1GPIO_config();//串口IO口配置5 @1 F( \$ A; L; |3 y/ C
USART1_config();//串口初始化波特率为19200
2 ~' D1 _6 F+ \% ^//UART1NVIC_config();//配置中断, g( x8 P; f& h
///////////////////////////////////////////////////////////
7 g+ }, M6 \& f. _/ T! m3 gSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
; O+ n- T( a5 t4 G. l3 \//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
9 M2 B4 Z/ j& I3 W( JTest_f_getfree();//获取SD卡的容量和剩余容量
' E& a4 G5 I7 N0 i  j+ [, a% FTest_f_read();//SD卡读文件测试$ _& g3 Y) L# l: p
Test_f_write();//SD卡写文件测试2 A5 Q+ d. x; n  f' x
/////////////////////////////////////////////////////////// ) F) [1 y# A- w. {7 e3 y% Q
    while (1)6 t+ E& U; P5 o! c/ _4 v" z
    {
6 Z* V$ n6 P. U: U# j+ N) d        //printf("好的");
* \5 ]) g3 g- c3 T( E    }
! u  d4 K/ g3 P}*/
; k0 g2 S6 D. C////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 Z$ r) h6 S( y; JFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
) S" `+ D, E3 A7 M{# Q' {& I  x4 e/ h
    FATFS fs;            // Work area (file system object) for logical drive, `! F! R, v0 Y& j& c' o
    FRESULT res;         // FatFs function common result code! S% W: v- ~, K; L
! o1 ?3 j1 F' T( v* o
        //检测磁盘是否插好
3 W7 U7 o, x6 F8 I% n7 p7 U3 \% f        //if(disk_detect_OK()==FALSE ) return ;- i8 o2 n) `+ L4 P
        //printf("\r\n inaert_ok:>");, h- y( ~; G) w* Q1 u. U3 p
        // Register a work area for logical drive 0# A; i6 k& B& A' ~( ?
        f_mount(drv, &fs);
* @8 K; ^) [4 X+ d7 g/ t3 U        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
6 _" T1 c& J# A) ]8 X* c        //die(res);
/ I% z0 n: @$ g( l        f_mount(0, NULL);
. r# r6 O2 a7 ~9 `6 X! n        return res;
, r$ x2 v8 R9 i1 N  ]. M: A2 U}
* C; V1 e4 F2 G////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
& E& q& X% Q3 c. Z+ T/ r' d& u+ ]FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        / U6 C; g. ?0 y0 L# v0 s. I. h8 r! b
{
9 L. Z% D9 u! L+ e2 x6 i    FATFS fs;            // Work area (file system object) for logical drive8 Q7 k+ l5 c2 G3 E6 f/ M8 S6 m
    FRESULT res;         // FatFs function common result code, N1 _% ]1 s6 ~. B1 f

  ]1 S- R) X- I) z+ V; J        //检测磁盘是否插好9 m2 x2 U4 V2 [
        //if(disk_detect_OK()==FALSE ) return ;# G, q  N. a! {2 ]' m" M
        //printf("\r\n inaert_ok:>");% V& w4 A7 l& Z4 I# v
        // Register a work area for logical drive 0- L$ l3 Y1 f* J; o" k; D
        f_mount(0, &fs);
+ n" g3 e4 N. S1 f+ T7 \; j        res=f_mkdir(path);//创建一个新目录: V/ R! L& @7 t* Z* w9 B& K
        //die(res);
# {7 p; ~) t8 O* O        f_mount(0, NULL);# c4 f" `+ B& Q* q3 e0 N
        return res;6 ^  v# I$ {' H' f
}
5 w% `$ C4 v0 D5 ^4 R0 r////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
: c2 y: z6 m/ M: A& c' XFRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        ; B6 m4 G0 e( Z! D$ O# n& }2 J& ^; c
{" q+ S* z, Z* ^
    FATFS fs;            // Work area (file system object) for logical drive: C) {7 |) C9 [3 d
        //DIR        dir;
' ]# d' n9 y6 W! z2 w0 K5 t    FRESULT res;         // FatFs function common result code
4 G2 n' g- B, H6 ^! \. \" z5 L! r; j! l; q. R1 V
        //检测磁盘是否插好
8 H8 U) H# M$ d$ v$ e3 i        //if(disk_detect_OK()==FALSE ) return ;
0 y2 V3 F" U* }% P        //printf("\r\n inaert_ok:>");
, k7 e8 O( v* ?& F+ M# _9 m* V        // Register a work area for logical drive 07 }3 j' y! X: U) ]5 R
        f_mount(0, &fs);
! K7 [3 l; l$ }+ w# J8 ]+ {        //f_opendir (&dir,path);  t& j2 M$ K2 S3 u2 C& F
        res=f_unlink(path);//删除一个目录0 J9 i7 g" i: e' {; i2 U$ U
        //die(res);5 z# L2 o! }9 {0 X' E9 G5 Y
        f_mount(0, NULL);9 |. {- C& C! H7 `/ p
        return res;
2 Y2 ~4 F$ C* P' F$ r) h  N& k$ _}
' S& E, r' k; N6 s9 Y////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0 ~, u, Q' x+ cFRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
* Y: v# w0 V) z2 W8 x! w{/ q5 F, U) X# K
    FATFS fs;            // Work area (file system object) for logical drive" r" k" J5 v: W* N; R! s; v
        DIR        dir;9 p' d# N! ^6 V0 z( s
        FILINFO finf;
6 _9 G, u! o. c/ l% s4 a( K    FRESULT res;         // FatFs function common result code
8 o$ [0 q6 y3 `9 \' E
# I4 ^/ G, J1 I        //检测磁盘是否插好
$ h1 ~3 k; E* w* H4 j# D        //if(disk_detect_OK()==FALSE ) return ;
& l1 ~$ x  c4 G& d8 ]4 L2 B        //printf("\r\n inaert_ok:>");" U9 W: f+ p" |: e' g) k8 d
        // Register a work area for logical drive 0! j4 b# [, [! a9 U8 P7 v( P2 m+ g
        f_mount(0, &fs);
2 L  m5 \/ A6 G' E        f_opendir (&dir,path);
9 }. ~* g/ l4 t, @9 r
1 m1 o% C0 C! b        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        0 Z5 J) j1 n* j# |
        {strcpy(*(filename++),finf.fname);
( S4 U. \+ O/ N, \& l- z& j* @9 o# A        //printf("%s",finf.fname);
$ M0 Z+ Z' u  e6 h" r# K* F        }
) V' a% ^# T% |. ~' K) O$ D        //die(res);
9 {1 J; A: K( S& h        f_mount(0, NULL);
+ y# ]. @5 d8 q, z: R        return res;$ L, W8 t1 F1 K7 w( A0 N
}3 G, v8 |0 r2 X8 y2 B
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 j' q2 |# U) _9 OFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名; `2 f+ y' p+ A
{7 g4 d: G, \# L8 b$ c1 j( s
    FATFS fs;            // Work area (file system object) for logical drive# G9 \9 J- b2 @  k
        FIL file;
: E+ [/ p, V% t! L. I& X    FRESULT res;         // FatFs function common result code
. Z8 w  q, c' l5 {& G, J+ Q) `$ J4 C
        //检测磁盘是否插好
/ O# P" e+ a" i- y5 a; ^        //if(disk_detect_OK()==FALSE ) return ;1 D" c6 e% z* Q, E/ J- p1 ^8 |
        //printf("\r\n inaert_ok:>");
' `2 M% m* Q5 ~        // Register a work area for logical drive 09 ^" }; k" T2 C; F6 n5 W  s
        f_mount(0, &fs);( y  O7 C% q5 D1 l4 g
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
* y/ `2 |  U" z+ W- E: [( v& F                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。0 b: p. b! q6 ]0 u8 a  _
                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
5 a% m. D) S8 D        //die(res);
5 D. l) W  }! w1 q2 [        f_close(&file);//关闭文件. ]* ?8 q- i0 O4 x+ v5 b! K
        f_mount(0, NULL);
' o9 Q6 }. G* E# l3 e! X7 V2 D2 T        return res;. T6 _. ?) w& C5 I$ Y7 N
}
* p5 [2 h7 x0 \; v- e* ?2 h////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  U; H) K) K* b' T) @9 a
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        # k; _( y- H9 o9 W5 O* h
{
9 k! I: n6 d& P/ x4 ^/ W" c# |( T0 m    FATFS fs;            // Work area (file system object) for logical drive
; X( R8 s; u4 i) X* m! N        //DIR        dir;7 k: B7 A, I0 q/ P; |9 D; C0 C
    FRESULT res;         // FatFs function common result code4 V1 y: U) t% m( A5 W7 }
5 D- ?# h* f, C+ N6 U$ }' \
        //检测磁盘是否插好
) P) m7 Z. i% a9 i9 W! U8 Y        //if(disk_detect_OK()==FALSE ) return ;6 S5 s3 u3 w, T1 b, G% D
        //printf("\r\n inaert_ok:>");( L$ \& M8 D: [3 a( ?
        // Register a work area for logical drive 0
' ~/ J- u3 e1 ~6 j7 T        f_mount(0, &fs);
8 y. w. k- A0 `# P        //f_opendir (&dir,path);7 @9 Y& V  i! @. j
        res=f_unlink(path);//删除一个文件7 F) {* d7 {" u
        //die(res);
+ n% h. ?! z( D2 w        f_mount(0, NULL);
, T' ~/ b! P2 C+ ]# {        return res;( X( F! x( P' \
}
; v, I1 T  `* k3 k0 K$ o+ L////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////' b$ ?$ L0 l0 Q, q
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数
5 [9 R, {7 n; [* C{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
7 m9 f* w' k8 V1 D    FATFS fs;            // Work area (file system object) for logical drive
9 N9 j+ }) A1 `9 I: R    FIL file;            // file objects& o+ }' {4 q& l
    FRESULT res;         // FatFs function common result code
8 B7 C$ }" }* F" i    UINT br;             // File R count 文件读回的字节计数
2 Z5 U: @& W" \+ d0 J6 j- s: S1 N# v        //u16 i;
) @) G. C; j- v: R0 t  Z        //检测磁盘是否插好
: [8 `* Y2 `0 Q5 I( I        //if( disk_detect_OK()==FALSE ) return;
8 O: i/ k( P5 Q( P% M8 q% c4 a" K    // Register a work area for logical drive 0
) U1 F" E  |# y. `        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';# X7 F! d5 f" ~# U5 i/ h" s
    f_mount(0, &fs);9 B3 C3 V* }' E3 |1 l
        //Open source file
; S* B! K  D4 T- J2 z' [" p8 c    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误+ v9 {0 X& x5 P! K$ O
        //die(res);: d( a# q$ T; [! ?0 Z
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处' L  p* ^5 _# \5 u) N
        //buffer空间设大一点,会提高读的速度。
0 d. {* l. V" u) ~9 L, J- z& k        //如果文件实际大小512byte,$ q; R8 j  A7 b6 q  |
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
6 _4 l& o) x& ?4 Q        //for (;;) 7 M4 H7 i1 W3 ^! Q8 j5 v/ ~& U
        {: M2 L, f7 R% C$ V9 p/ q, e
                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存6 x/ L6 d- n" `

$ ]" W# ?# p2 x8 w+ }# O! W$ W8 u                res = f_read(&file, buff, strl, &br);1 p; v( H4 v/ |: x. l0 y1 z
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出' W0 ], C0 B$ r! H* g% i1 o3 L
               
  D7 |+ ?, Y8 D9 N/ f* m; }                //printf("%s",buff);        
# j8 U; @- [5 i( e1 C  `" {" p( v; L2 F    }                    
# R# F3 u0 t% W5 Q    // Close all files/ W- V1 M! U. F1 N8 K2 n
    f_close(&file);3 [8 s5 u  }* ?
    // Unregister a work area before discard it
) g5 e* `! Y6 G- ^. Q    f_mount(0, NULL);
, `3 s4 L! C- K" X  G        return res;
1 x' K  E7 x) B}6 j2 y* u3 |* y+ |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
  C; h' E: Q* N9 I( f* hFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
1 R) E" {: g- b{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));: A0 H/ G. x& s. }
    FATFS fs;            // Work area (file system object) for logical drive& g6 V7 G) n/ o7 M* e, o
    FRESULT res;         // FatFs function common result code
. Z/ n4 c6 i! ~/ n; ~9 x0 z' K$ x        FIL file;' l  W/ `+ _6 F+ y& r6 X$ J6 g
        UINT bw;             //文件写入的字节计数  m$ B# S8 }7 j3 c3 V4 e$ A
        //检测磁盘是否插好" I9 R1 ?, m2 |% f$ K* ?
        //if( disk_detect_OK()==FALSE ) return;! Q7 o6 J$ S3 U0 [$ J! C
    // Register a work area for logical drive 0
' K3 a) Z/ D* h) ~    f_mount(0, &fs);
, e& l/ e; D5 u$ @, b2 n    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
% }5 w+ M, T" O0 a" f& m4 R         //die(res);
3 R9 J0 W6 P. |7 w1 h    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 ; A4 V/ k; q% y3 @+ [5 e, H6 g2 p
         //die(res);
3 ?1 [, M% @2 z3 h* l        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符3 N3 A' P4 j3 N( u. d! F' {: X& H
         //die(res);$ s% Y4 e% K+ [6 I; J
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  ( D' h% }' W0 J* A/ B  O
        f_close(&file);//关闭文件) I! K3 |! ?4 c# O2 o- T8 d( ?
        // Unregister a work area before discard it
: M  S; R! T! E    f_mount(0, NULL);) w) g" p1 e4 U. D$ e  g
        return res;! X, F3 l# E$ G3 m7 X. k  I7 y
}: S/ B, q/ Y; O
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; q8 B1 o2 ~6 r4 eFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M" d9 p3 R- p( a. i( D+ n
{5 ]3 p/ K  z! s" M  h' }6 q
    FATFS fs;0 e3 o8 n% {7 Z& `1 {9 o
        FATFS *pfs;
1 F9 F# N! p, M. v( q, [        FRESULT res;         // FatFs function common result code
! z6 w1 X7 m2 p  q        //检测磁盘是否插好
+ U3 w2 p) e- H5 \( X        //if( disk_detect_OK()==FALSE ) return;
% Q9 P. {& K8 `' `  x        // Register a work area for logical drive 06 p9 [2 s9 L3 M5 x  T& Q" D
        pfs=&fs;//指向
4 K' k4 G4 O# `7 Z5 X    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间, I( H3 ^# L# I/ w
    // Get free clusters- I% w' k0 c: a. H3 J9 e
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"; }3 N- ]; N6 A) J( g6 @' u
        //die(res);
$ r8 ?! E4 a& M6 |' G  Z( Z! ~        if ( res==FR_OK )
3 b2 H4 Y( U' v& |) S0 ]    {" @7 U  U0 o0 }% c) G& f. f" B
            // Get free space0 C3 w; m2 j; l/ |+ \3 C
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
* X, I8 n: g7 J: a# D               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024$ y- D5 O6 i3 l* d1 T
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024' u- T% O( x; d& C$ n2 n2 ^( u
         *freem=((*freem)*pfs->csize)/2/1024;4 z/ v+ s9 Y, p- k  {) O7 ?$ Z9 o9 x+ x
        }
, F% M. [# m9 e# Q1 M0 R        //else die(res);//测试函数执行结果分析, y. Q2 H: G7 U) M7 b0 D
        // Unregister a work area before discard it0 Z5 @4 q$ x, g- \3 F
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
1 X/ [. S$ a7 u1 F6 K; W        return res;. G8 G' o1 E! q& t: ^! y0 x# U3 j
}" R5 J1 h( L0 s; [* W) z7 l
: S4 d8 \, }% x9 m
9 }0 A) t5 a, k+ m' [

, G( a( s, L' f/ Feb 26,'06 R0.00  Prototype.7 Y7 \" k/ b( N8 c4 U$ s3 n( Z5 S
/
7 f& u/ N) ]% H; V0 F+ l4 f# v/ Apr 29,'06 R0.01  First stable version.
' {& w9 h. M( O$ N/
- _  ~, _! C% p3 h4 n9 s/ Jun 01,'06 R0.02  Added FAT12 support.
# a3 ?: n, B- W: I* x0 `/                   Removed unbuffered mode.- [4 j9 _  Z& f/ R2 s
/                   Fixed a problem on small (<32M) partition.
/ ^" [' y2 C5 ?0 [# @9 g, z/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
/ P3 D& ]( d' j9 b/6 J9 f" f" |& i+ d0 \* G8 c
/ Sep 22,'06 R0.03  Added f_rename().
. F3 H. k$ G, R, R. U/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.
( c9 I% W0 H# D: N! o& g) f/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.% {4 J. i( d, V' H4 s7 ?" F
/                   Fixed f_mkdir() creates incorrect directory on FAT32.
* W0 b0 g- O& c+ p  {0 u/
: F4 Q( U3 `& Y$ m* ~2 d) p5 [/ Feb 04,'07 R0.04  Supported multiple drive system.! i, R0 K7 B, h) j. `) \2 E- R
/                   Changed some interfaces for multiple drive system.
/ E0 f7 M. J3 n* w( E3 y7 O/                   Changed f_mountdrv() to f_mount().7 Z# P6 k. R, d7 Y! [1 V6 {  u
/                   Added f_mkfs().! Y2 h& y% I0 M) D8 Y$ N0 f3 a; u
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.; V4 x) d( J6 M" k, B
/                   Added a capability of extending file size to f_lseek().  ?0 t  ~2 U# B1 C
/                   Added minimization level 3.& m$ W; s' [. [. u5 D
/                   Fixed an endian sensitive code in f_mkfs().
" S4 ~  X# R( X9 z; l/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
6 e; h1 e& A! \( G, N& a( J2 l/                   Added FSInfo support.' ?  U" }2 F2 J
/                   Fixed DBCS name can result FR_INVALID_NAME.) Y6 M  K, U2 A# I6 j4 K
/                   Fixed short seek (<= csize) collapses the file object.
, ~& n" ^( v; s; m/
; L9 _/ y4 _; F- B& ]/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().) r6 E8 |9 _' w/ Q8 m3 w0 J4 E
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.7 ]/ _* ?, m/ c4 q$ D8 i
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.3 k- B) C( p& F- s2 A
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
, W6 W& B* i. }* ?% v/                   Fixed off by one error at FAT sub-type determination.
# h1 R' a4 H0 R- U6 Z$ W4 Z2 t/                   Fixed btr in f_read() can be mistruncated.6 E$ w8 F' ~( \3 ~5 P, j
/                   Fixed cached sector is not flushed when create and close without write.
* \. }# `& i: c! X& e4 x/( S1 K2 h. o# ^5 ^
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().: F# V# x, Z; O
/                   Improved performance of f_lseek() on moving to the same or following cluster.
/ ~9 ]. [! F' @0 N, g" J$ g/. Y! _8 p) v! r1 _
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
0 w: l1 p9 u+ p7 Z/                   Added long file name feature.8 x# f) d7 z, ?* ^3 e* d$ l
/                   Added multiple code page feature.1 [* A" `, f4 X- ^7 q% |' y3 `" |
/                   Added re-entrancy for multitask operation.
2 z. ^! ?, Y1 W& z# V3 A, R/                   Added auto cluster size selection to f_mkfs().
' ^/ o: d+ h0 k: g+ \6 Z/                   Added rewind option to f_readdir().
9 p) J4 u, \7 J8 t7 B0 A/                   Changed result code of critical errors.# p7 G# N, ]! a! L) D
/                   Renamed string functions to avoid name collision.
  r' x2 T1 E) m/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
0 k; [  Z5 |2 i7 X7 H/                   Added multiple sector size feature.
# ~2 F& o& U' F* i+ z/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.1 d+ a" U9 ~; k5 [' p3 O; m
/                   Fixed wrong cache control in f_lseek().) x  M" o8 {; l, q, Z0 g
/                   Added relative path feature.0 E2 Y  S3 A; A
/                   Added f_chdir() and f_chdrive().  K* Q3 H% S& Z6 ~; x$ {2 e
/                   Added proper case conversion to extended char.$ h" j8 ~0 P2 I& v: Z- P
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.* v# {  A6 x" Q# }: e
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
  r6 J& D1 \6 \/                   Fixed name matching error on the 13 char boundary.
/ T5 Y# ^7 _* l( g/ o/                   Added a configuration option, _LFN_UNICODE.
4 l! `. c( @0 m+ E% D- r) b- A$ A2 P/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
# S) q( ~! y" [' O. B& k/7 n0 W' \. |: S5 c$ b3 C5 F. v
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)
# j# b/ d& v0 ?1 Q+ ]% v. I  I% g- @. r/                   Added file lock feature. (_FS_SHARE)
* Q3 j; l2 w' i9 c/                   Added fast seek feature. (_USE_FASTSEEK)5 W9 q- p6 G8 V% Y
/                   Changed some types on the API, XCHAR->TCHAR.
' C" Q4 D6 r2 T* l' p9 J/                   Changed fname member in the FILINFO structure on Unicode cfg.
$ ?7 W. q) f+ r, A) H& r/                   String functions support UTF-8 encoding files on Unicode cfg.) k# w) T' A1 g# M* D
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)5 c2 E- C. I; A
/                   Added sector erase feature. (_USE_ERASE)0 l) l, G/ s* K- |* t7 N! w+ o
/                   Moved file lock semaphore table from fs object to the bss.  Q' q+ Q. j* j! N+ P
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
! p1 u8 U. G" x/ _1 n! [7 }5 ~/                   Fixed f_mkfs() creates wrong FAT32 volume.
6 f* T7 u. `8 A. W2 [+ k/ x/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
" U, J* c; H4 }0 f* Y; Q/                   f_lseek() reports required table size on creating CLMP.
# m6 [! W/ P! i/ s: h- T& A$ f/                   Extended format syntax of f_printf function.% P2 i$ E5 \/ V& Z. A! ]
/                   Ignores duplicated directory separators in given path names.$ h7 [, S2 x4 S8 I+ h( }2 ?2 a
/0 P+ _1 a. S% b! N! [
/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.4 o' ]" P2 R5 E: c
/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
$ D' O3 p4 H* L( G/---------------------------------------------------------------------------*/
& ]7 h) x+ ^# [* L  }3 q2 q% f& I# z$ ~, r

STM32的SD卡FATFS.rar

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

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

208

主题

649

帖子

1492

积分

四级会员(40)

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

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

本版积分规则

关闭

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

巢课

技术风云榜

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

GMT+8, 2024-9-17 03:58 , Processed in 0.080912 second(s), 35 queries , Gzip On.

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

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

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