找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

电巢直播8月计划
查看: 1393|回复: 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工程。下载即可使用。7 e4 u$ ]% q1 e% `  F' a) e% N
/*----------------------------------------------------------------------------/* A; ^  K8 k0 O" k* B
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011: N- Q4 G% j5 n, R
/-----------------------------------------------------------------------------/' c% U% s9 l% ]& ^& n; e8 h6 h* J
/ FatFs module is a generic FAT file system module for small embedded systems.: e6 P# B) U  f- J, L9 C5 y- i) O, b
/ This is a free software that opened for education, research and commercial
9 d( w. |: E* a, g$ Q# @! w& S: S/ developments under license policy of following terms., s" e3 N! H1 Q1 ]. w
/
- ]/ ]. R/ K! A" l7 T/  Copyright (C) 2011, ChaN, all right reserved.. c; V( f, g- _  ]: o- ^
/7 T0 U6 |" d  L" X9 F$ H
/ * The FatFs module is a free software and there is NO WARRANTY.
: V. [( E% O/ o6 ?1 d( a7 S4 P/ * No restriction on use. You can use, modify and redistribute it for. W% B( q( |9 {
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
: x4 W7 P2 L5 W. G/ * Redistributions of source code must retain the above copyright notice.; [2 Z$ N# u3 Q  L5 L- _
/4 i) j3 D$ \- p
/-----------------------------------------------------------------------------/
' m# L6 k' v/ Z. v8 P
1 L: Y6 `3 y) ^# ?
& v) L8 a1 A5 i3 L/*--------------File Info-------------------------------------------------------% T/ U) |7 v! I# E
** 文   件   名:  FATFS_Function.c; \0 X. a$ V; I$ w
** 作        者:~风中的叶~    整理$ G3 }' I7 V. L2 d. |; b
** 最后修改日期:  2012.01.18" I) W" O2 S( J' y8 ]
** 版        本:  V1.0$ m4 ^5 ]% i# E8 H  E4 k
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
( ^8 {) G1 f8 [7 m4 T5 @( s& M: e**------------------------------------------------------------------------------
7 x& _7 y5 [1 c0 n& W** Created   by:  Dt.4 r3 u: e8 D9 i' _  I% i
** Created date:  
( q& h$ _. i; J5 v2 ^*******************************************************************************/
8 V( [0 U, V! z8 T* o#include "TEST_FATFS.h"& E. a2 l1 L9 W( f; ]* G1 J
#include "string.h"# I# Q( P' L" ]/ _0 Z6 V+ `- Q
0 w. j9 E8 C3 }1 ?
#ifdef TEST_FATFS_EN7 N; |6 j8 }% J6 T
9 R  U: H# Q. b1 T

7 ]8 {; y/ [8 d4 d
0 H# Z' q; S* C8 ?# H//检测磁盘是否插好) Z  O1 ~, e# H
BOOL disk_detect_OK(void)
2 P+ l1 G! E6 c6 q' x{" a4 ]1 h9 i, q$ F, ]6 Q$ u' D' D
    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */& X* s  _1 U: _3 Z4 B8 ^0 a( m
        {
5 v# I* [# E3 p4 J* {            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");) J. G4 E, h8 y+ o- D  T: {
                return FALSE;$ b5 ~* }- c7 J- D1 B3 }0 `
        }/ P& Q. r6 G/ H1 L! D/ _
        return TRUE;2 I6 L4 |* F8 K  {
}" r7 o9 Y" f, s1 [
4 d. `9 C# n  K( k1 b2 g% w
& o/ A& K" r* I" u1 ]1 v/ y
5 v0 i( q: o  H% M9 f& N3 y& w
//测试函数执行结果分析% f* }2 q! y0 @7 e) {& W; U( P
void die(FRESULT res)
$ r& v, X5 ^. U( t. `6 n- R* b{
& f9 Y+ m0 K& B1 ]: x1 j+ Y* ]' U    switch(res)
; x' L: U* l# R4 k9 N  i        {
* @( G% l  w( w, e9 _            case FR_OK:        //The function succeeded.
$ a5 j. ?* I, T* B1 I                {9 u' Z7 f. V* P$ c* x& [
                    printf("\r\nThe function succeeded!\r\n");
0 O% p6 D6 `5 P3 M- h1 e                        break;" w  \& F9 D1 V2 v% I8 _4 |! C. o5 x
                }
' v4 W# f9 E$ D. H8 j% u( _                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason9 ?* A0 E& y" Q: Q+ }
                {( ?& b+ ?# k. P: D
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
+ A- T) L: l. V; u2 w) X$ C                        break;
, ]% s3 J$ i& g+ h9 Z, E  u' e( k                }
5 p  X; A* z: n  R- W8 l                case FR_NO_FILE://Could not find the file.9 e7 l' X: H5 z6 C3 G
                {  J+ c+ e% ]4 o( D; w9 t
                    printf("\r\nCould not find the file!\r\n");& g& w5 k" {  [
                        break;6 {* ]# q. \# t* E7 g0 L
                }$ S0 C" H: R8 f! G3 m6 Y  q
                case FR_NO_PATH://Could not find the path
* @. L! W1 h2 R/ K: U  F2 k                {+ s- f$ k% M* G% J
                    printf("\r\nCould not find the path!\r\n");
; m6 h. U7 N9 B* s                        break;/ N* L. J( L  o1 Q) U2 K1 @. B1 p  v. N
                }
! w/ o6 N( ]0 \) B                case FR_INVALID_NAME://The path name is invalid" W' L4 E0 ~+ I% y
                {9 d4 x8 d/ K* {; y  N& l) {
                    printf("\r\nThe path name is invalid!\r\n");% f6 z& L7 q  ~/ k
                        break;5 \, \) }! g* p! B3 x9 q6 ]
                }% M2 V# g6 W$ d
                case FR_INVALID_DRIVE://The drive number is invalid
1 B2 V1 k0 c% P- _8 s  i                {# ?0 b; B% M2 n# m- D
                    printf("\r\nThe drive number is invalid!\r\n");2 V; O' }- C% z' v
                        break;; x$ W1 q, @  m; S
                }
& N+ K8 Z% s$ P5 S6 N' S                case FR_DENIED://The directory cannot be created due to directory table or disk is full. 5 f) F, ^  b+ n& i0 e
                {: W* R+ D+ z- F; Z+ n( }
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");) [: j- s$ W: a6 I) ^
                        break;
& o4 Z  |+ l# A0 B                }) H9 z7 n7 w: Y, u  l
                case FR_EXIST://A file or directory that has same name is already existing$ o' {  f1 i) S  W" ^
                {1 q% C: U* X& a& P
                    printf("\r\nA file or directory that has same name is already existing!\r\n");% Y1 k! N+ H$ r
                        break;6 l, w3 v3 q3 A& \9 r0 n
                }
! k9 I8 q% U. {- H! ~- E//                case FR_RW_ERROR://The function failed due to a disk error or an internal error+ k# j- w# Q$ z( U1 a' ~. z: e
/*5 g/ R+ Q, r" S
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
. H3 ?! J' O, N, w7 v9 G                {
4 X; d: N* ^, s9 u% `+ O! ]7 |" I                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");/ J3 v! ^3 @9 y% O; L: {' \0 \
                        break;0 e- _: k: V2 r, L# S
                }# w% ?+ O# D% y$ x2 `
*/8 Z2 w. z! I0 v% c. \
                case FR_WRITE_PROTECTED://The medium is write protected
$ n+ w2 Q9 |, b" O9 y' R                {# l( }/ L2 ^' S+ F7 ?
                    printf("\r\nThe medium is write protected!\r\n");
# v0 \) v4 O' _+ x8 n' c9 h                        break;1 y% e* n9 ~1 r  R  T
                }
, ?0 U4 U# _! C0 {8 O+ q0 o8 {4 w% B/ u                case FR_NOT_ENABLED://The logical drive has no work area7 n9 X8 E3 G! Q& X  |! X
                {1 l7 D6 c! u  H& O# C
                    printf("\r\nThe logical drive has no work area!\r\n");
; w6 N. e( z, v6 A0 M: I% M                        break;
0 N! J3 x2 f9 K" E+ x8 J! W                }
/ k$ K4 v1 a' e+ y& r0 X. x3 [                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
, r( a% U% o2 ~& T; J" p) |7 P                {
) `1 s  y( v* i( T                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");3 o8 A% }: [* X# g- ^
                        break;
! D. b* Y3 D( v# E                }- S3 ]" ~- k2 F! G5 B! B
                case FR_INVALID_OBJECT://The file object is invalid
5 S2 r2 h8 Y0 P                {# P- J. d; M9 x; `' D: l$ i
                    printf("\r\nThe file object is invalid!\r\n");
) K" j( F: P/ U' ?0 o                        break;
4 f" V  T6 l) ?7 H' G                }0 C% l: G4 }2 `$ o

& p7 ^) ?/ _1 n5 q0 k( W            //The function aborted before start in format due to a reason as follows. * o* K& ~2 E  s
        //The disk size is too small. 9 L1 o2 [* e% _8 ]7 s
        //Invalid parameter was given to any parameter.
) Y, b& A7 N* R5 w9 }        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
2 [# o7 O$ P  P5 S# X                case FR_MKFS_ABORTED://6 h8 R5 @: R/ S4 o" H' ?  k
                {
" s/ f6 I# C* g" m' K! P                    printf("\r\nThe function aborted before start in format!\r\n");4 u* y, E; K. w8 C
                        break;; `4 L- Z* ?# w# {8 f3 f
                }
8 ?. `9 D. n3 L! H( G( H                1 z6 t% X1 S4 Y4 q' s: T+ l
                default:
* U8 p, G/ Q8 w0 {& D                {
/ o9 |. V, t! Q                    printf("\r\nerror!\r\n");
" D! X7 A. V- J4 V9 G+ v- R' {                        break;1 k- q/ L3 m7 X' I4 L) t
                }        ( A* `) K7 x- ?, h. y/ n3 {
        }% c8 l7 j7 u1 f2 A' h! m
        return;
6 O! f7 \% m& D  T; ?}( c" y2 @9 J8 O$ d! ]
void Test_f_getfree(void)//获取卡的总容量及剩余容量
9 H) A+ P! k" \2 K8 [& X6 v{; _: H& o+ n3 I) U3 [
    FATFS fs;0 B8 q& _, O9 D6 |" c# Q
        FATFS *pfs;
6 |$ T  x( @8 }: r: a    DWORD clust;
7 n3 E) s  F5 X4 R  [$ P: W        FRESULT res;         // FatFs function common result code
; N5 r- }& f; w, @
- E! N! q5 W! n! V        //检测磁盘是否插好0 u5 @7 J, P/ v9 L4 l2 _! @! D
        if( disk_detect_OK()==FALSE ) return;
/ K) q5 v9 W# h1 |
& C# W" l; \( K8 s6 ?4 r        pfs=&fs;//指向* X( H) D" h! A! V9 ^
        // Register a work area for logical drive 0. t6 x  y& b1 m4 k" X% K# r) _' W8 C
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间* a8 \  c- j+ s: e8 E% ]
) Y+ N8 z5 d2 J3 P4 c
    // Get free clusters
" e" A, a; o' D. L* E9 v/ P    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
2 _6 m' ?3 Q! t3 \# |2 j0 J1 o- j    if ( res==FR_OK )
1 L  C: [+ d0 o1 C3 J0 n( R2 S    {
4 J  D3 q( c  Q' |* p; _            // Get free space
( f7 Y6 W) ~: B        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
% P( b4 }' f9 _                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
- D4 ^! m3 G9 J) x                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
; a: V. J& g5 p5 n( a! u* s        }
7 G5 ]& }3 j: ~" R3 m. P        else die(res);//测试函数执行结果分析
' S5 [% l8 y; ~5 M  O        ) _' C5 V7 a3 A# a0 C% G1 h
        // Unregister a work area before discard it: _# g  N$ B' ^- [; y
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间3 t' Z* G9 j8 m5 T
}
/ Q; Z7 {8 |% H1 i1 \  z& g4 X# \% p0 X1 ~4 o# Z
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
- @# Y: a! I2 @{3 s+ c3 q; \' Y4 y1 t1 G) M7 G
    FATFS fs;            // Work area (file system object) for logical drive
3 `. M* w; ?. ]% P    FIL fsrc;            // file objects
' k8 P) K/ ^6 d* y$ B: V! q    BYTE buffer[512];     // file copy buffer, t1 m/ X/ r4 K& }; P( j
    FRESULT res;         // FatFs function common result code
7 e+ ]( T- X% I( U% N, e1 G) s    UINT br;             // File R count
# ?) f3 I! D4 t; S- u2 \3 n: j7 [        u16 i;: c. q( M3 v( n  P
        
" ]! y4 j+ J# m1 z! }5 A8 u3 b! x" T) j/ W( Q) K1 G. k# X% Y# I
        char path[20];
2 R# i+ ]& B! f9 @
4 C1 r# _: l7 ~; y        //检测磁盘是否插好0 |% V/ ?3 Z; S, m6 u# P
        if( disk_detect_OK()==FALSE ) return;
, t5 T6 i9 W; `' ^! p/ y* R9 C- ^/ T/ S+ q( E& E
    // Register a work area for logical drive 0
; O2 b+ Q& R0 }$ E  Q9 o    f_mount(0, &fs);* Z* C# d7 _; c
4 J, `5 @; J4 q) N
        printf("\r\nread file:>");3 g6 W7 r2 u& P& y
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt, W- v0 e& H  H7 N4 W) z% g# P
$ a+ F8 N" W7 u4 u/ J, [5 \
        //Open source file' h. z) H4 U+ T  H+ d
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
3 i2 c. M, h+ y9 v2 ?8 q        die(res);
) _. T% h( U# k+ {  l        * j- x+ L) p' D7 J; ^; ^9 r
        //buffer空间设大一点,会提高读的速度。
0 g# Q( ?: _# G: E& C" M2 J        //如果文件实际大小512byte,
5 V" |2 J8 p1 J9 p! O0 e6 O6 {        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。, `; i: m: M2 u, n4 _1 X8 Z
        //下面两行主要是去除1s误差。! L6 N: t# q. i( U2 G) s8 N
* ^4 B  o; I2 A6 Z2 W
        for (;;) " a# k( M4 r2 {. ]) h$ e7 d& ^/ T- g. m
        {* {( `# O' B3 U" B& v, |1 r
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存. g0 z9 A. Z$ f) j" \

+ [+ u  l: v$ u' F' ]                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
7 N! h6 D" Q$ \7 C! S0 Q        if (res ||(br == 0)) break;   // error or eof        
' U2 R; I6 @- W) W               
3 D9 N9 g6 m0 w                printf("%s",buffer);        4 T* P/ t! T' m- {7 }
    }  m$ m% s/ e% ?: r3 o
" X  ^: H1 `* u) S0 M3 N- Q
                            0 I' G+ W; Y0 t: Z
    // Close all files
+ f1 Z0 y( W7 R6 H0 m+ ~    f_close(&fsrc);. H; d: b# z3 D, d
    // Unregister a work area before discard it  d5 R: T" g% f+ ^* y* s6 V/ E" v
    f_mount(0, NULL);
" f+ n. ?7 l7 a" v7 e}
/ `. T4 c( U8 M$ E$ D1 h8 o! f3 e3 w6 W* d5 I
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
, P9 |( o# N8 |( M{
7 d( g# c3 B- D! v( e0 W; u4 m, |; z    FATFS fs;            // Work area (file system object) for logical drive3 f- u# Z3 _; D7 F* o# v* t
    FRESULT res;         // FatFs function common result code
2 m6 Y0 o) h8 `2 }3 W        FIL Make_file;! ^& o, _6 }6 ]7 c! y2 z3 y
    char file_name[20];
: e$ Q2 N( X$ a    char Storage_buffer[] ="0";3 F& Q/ H, i, _: L% p! a2 G! u
        + U* c" R" v1 w! Y2 ?( c) r( y, ~; E
        UINT bw;
, a; b& g) d* H( W        //检测磁盘是否插好
, B* G6 h' v- [- E        if( disk_detect_OK()==FALSE ) return;1 I) B, c- C, a) Y
         printf("\r\n inaert_ok:>");1 M" b' [  f; `+ y
    // Register a work area for logical drive 07 A# R( ]0 d, |# `- d/ ~
    f_mount(0, &fs);3 l" E6 K# `6 y. z' @

7 }+ o) o6 P7 i! c( V0 S8 k- @        printf("\r\n Make file Name:>");
2 ^1 X- N' G* F, t: A4 J6 |% P& ?        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
- x3 L7 ?1 m6 m1 k7 g& j/ q" b# W" i4 W$ \
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
1 \1 \& T  }' N  h. V- K8 J! W* m         printf("\r\n open_ok:>");! }% l; Q1 l. y) X: i- s# w5 ?* Q: O
         die(res);
" ]5 N4 P$ h9 `1 d1 @/ j    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  " E: z8 o. w- W; y. k
      printf("\r\n seek_ok:>");
4 ]  o% ~, Y$ B1 |8 K' b         die(res);
4 ~. H- B9 y& R5 B. t        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
: r0 R$ l9 ]# I; v4 P2 c     printf("\r\n write_ok:>");
3 w- A, y/ N8 b+ c7 g         die(res);5 @6 x3 N* g' U/ u/ l
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  9 j3 t, H& r& ^& |+ ^6 [# h( _
        f_close(&Make_file);//关闭文件, a+ K# D' v+ @# ^
        printf("\r\n close_ok:>");- o9 U6 F( e" }

( Q( t" f6 L. [1 D9 S: k4 z7 F        printf("\r\n写文件测试OK!\r\n");5 Q0 T: `* W; T% n$ R( Q3 S
# J. h' O( v$ u  U# g
        // Unregister a work area before discard it
, Q5 W' a% ^! Z. b% u$ B    f_mount(0, NULL);
0 Z/ l5 Q  d! v$ x) _! I# u}
" O" `1 V# b" A# K. Z% {! D4 R$ d- c3 g4 L/ A9 H# N; ^
//The f_read function reads data from a file.8 K6 R  Q' B: B) l+ I  G$ p0 |
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样( i8 }3 v+ Y* f9 l+ y2 Z% S9 f, e
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了& X. C# [* f3 |" B6 g& n3 n
//所以以后要特别注意这个问题。5 B2 P0 L/ @0 p$ ^' |! o7 R

- c/ O! t' K* R5 O" V) Au8 StrToData(u8 * data, u8 len)3 s9 I0 k" K1 @/ l% k+ U
{
' T( z" C. C( r6 ~! q( I        u8 ltemp;
( |& l* p7 f! W2 x0 x4 d        if(len == 1)
2 Y& M# y4 k$ I! d9 _( e        {
' a! E1 @0 m; J. w7 Y                ltemp = data[0]-0x30;& p  F6 l4 w" X( r, {9 A
, @  h* S. @. ?. X  \4 [: a" C0 O
        }
) g8 j* Q* A0 r- x; L        else if(len == 2)
6 A, W: o- O9 d. \* k# g7 b. Y4 |; c- B        {
( f0 g9 ?/ U! Y# [. i; s# [7 R- O+ d                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
* t( v9 a  r* X4 Y5 F- f# q2 d" M$ m% N8 F4 f, `3 f( X( ?0 F
         }2 r* v3 `4 p; L
        //else if(len == 3); _; y, C  \1 ]$ _1 `: Q/ F8 K8 X
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];( L: ]- H! ?( \; ^' W) ]

% ?6 `9 h; ]6 A5 v/ W- n        return ltemp;% z  \! {4 U8 n+ T( O/ \, B
        
0 H& b. c$ a1 [6 \1 w}
8 H' |' L) i7 j& w' o; _
& ?9 f% |1 z9 F2 F8 b+ w" d; c
9 Q/ z7 K: B" s% r" O& n+ R#endif
4 o8 {& Q* u0 n% I: y
8 B- {) J# C- r, p5 G/ Z3 e/ g& L  |
/*
7 x$ O  Q" c4 J2 E" L/ b8 t8 Cint main(void)
% Y+ R: ~6 O* d: b{
& s3 W; ]3 Q8 g" e. Q. l; k///////////////////////////////////////////////////////////
% `3 n! a" n1 D5 Z1 Y/ x' T( nUART1GPIO_config();//串口IO口配置* D" u9 T! Q! v
USART1_config();//串口初始化波特率为19200
- G: R* Q+ r2 ], U5 X2 ~6 u//UART1NVIC_config();//配置中断
4 H$ r# ~) b* p( S" ]& M///////////////////////////////////////////////////////////
+ W$ E  S& C' w* dSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式* n, z! l* C& Z7 I# w, m
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
" X; b1 m4 w* `3 }Test_f_getfree();//获取SD卡的容量和剩余容量
6 O. M/ M# C& H, x4 fTest_f_read();//SD卡读文件测试
$ N  b5 K/ K( T7 U/ jTest_f_write();//SD卡写文件测试% d7 H# e8 |" B* l9 e* E
/////////////////////////////////////////////////////////// ; N$ u( C; ^' X) @3 U
    while (1)
' M+ y% ]1 [! W& i# }    {
6 e9 x0 B( v( @5 z/ |6 O* W7 a        //printf("好的");+ G, i7 a  a; b
    }3 b9 L0 y- G+ E$ n6 y' |) ~. E6 ^
}*/, t7 p% P/ g( ]- o
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////" a# K! i; h. [6 {0 E8 [  e$ E8 \
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0/ C) a4 J+ y& g- `& L0 @* M0 X
{/ Y! ]& u0 ~4 A1 N6 w: T% Y
    FATFS fs;            // Work area (file system object) for logical drive
( C; G7 ^/ X' E" K& ]    FRESULT res;         // FatFs function common result code
& R! {8 ~& l1 l! N: y
4 L; m0 Q6 E) L7 T6 k        //检测磁盘是否插好3 c- l# d/ g! d, `
        //if(disk_detect_OK()==FALSE ) return ;; k' _1 o; v0 _* |/ }. R
        //printf("\r\n inaert_ok:>");
- |0 Z  o4 e! O* `$ J        // Register a work area for logical drive 0$ H0 \3 l8 ^0 {
        f_mount(drv, &fs);
7 Z# W, u2 S7 B8 H. A" T# f& ~: W" z        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
4 r8 W& ~) _/ i; @        //die(res);" v* O) a# g8 g) ]' |/ m6 H3 U
        f_mount(0, NULL);
9 {) k0 j7 }8 c# v# n1 E5 L1 g        return res;
1 k2 u+ ?( E, E  t) R( W8 ~}
2 P3 s$ k5 j$ {( c  _( W1 {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# L7 e6 x% ^0 }5 l3 bFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
5 H+ _6 ]6 U$ \. K% n% C. N9 [9 j{
, E. s& o: q( N' s$ Y+ C    FATFS fs;            // Work area (file system object) for logical drive. E6 c# m# m: D( A* o4 V; A
    FRESULT res;         // FatFs function common result code' g) g  |* c5 S& _! i, `- n4 S

. L7 z: `- ~  v4 f+ d$ I, z        //检测磁盘是否插好) s5 [; a7 i! I1 ?/ G
        //if(disk_detect_OK()==FALSE ) return ;
# K' M# s4 l8 g; G8 ]        //printf("\r\n inaert_ok:>");& K/ j. ^% l* d/ l1 n) J* A3 P
        // Register a work area for logical drive 08 |6 j  Z  G& C2 w
        f_mount(0, &fs);
) `. _3 ]5 L: B        res=f_mkdir(path);//创建一个新目录$ w0 t) x( q  c4 t' {0 E# `9 I
        //die(res);# ^* L  ]8 w# H8 ]; e
        f_mount(0, NULL);; Q; E% V* w1 Q3 i# b
        return res;
- O3 p. z" F% B5 Y) ~}
( w) G' P- |" |1 K$ n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% }9 q/ B% y5 R) c0 Z  IFRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        7 ^5 f0 C7 Z! u9 P: ]% H3 P* v
{( P2 z7 X. B' ?* E0 _
    FATFS fs;            // Work area (file system object) for logical drive
2 y7 E; M- ?; T6 Y* z        //DIR        dir;
' \! a' x) g, w& U    FRESULT res;         // FatFs function common result code
1 W0 D5 U& h' \, ^1 n3 n
3 n: l, q  R, y; G. I6 f5 p        //检测磁盘是否插好/ K( X5 K0 m8 ]
        //if(disk_detect_OK()==FALSE ) return ;
6 }4 R$ k0 E2 R" {        //printf("\r\n inaert_ok:>");  o& k  e0 [% b9 X3 R
        // Register a work area for logical drive 04 X. g8 j( T7 C& ?
        f_mount(0, &fs);6 s9 b( }! A$ E9 B: i+ S0 n0 N* F8 @
        //f_opendir (&dir,path);& Y8 ?* x( w- E& x  _8 \5 J8 A
        res=f_unlink(path);//删除一个目录
& Q9 L$ B6 S/ V8 a) h! E& m        //die(res);( C% M8 N! w+ m; r
        f_mount(0, NULL);
0 Q5 h& ^1 ?9 I- g" y. K2 M4 L        return res;
; z3 z8 G: m. o: ~6 S3 [}
6 H0 A9 X; y) Z, j////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% i8 P+ s$ v& s5 G% U3 p7 j
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
/ P, M! N5 A# {6 N{4 G& g$ y/ _; {8 L
    FATFS fs;            // Work area (file system object) for logical drive
+ n; b% y( u8 M7 ^; |        DIR        dir;
* D. n: g  j2 J& h" u: M        FILINFO finf;
1 E; d" U9 S) U$ R    FRESULT res;         // FatFs function common result code
. t  w  I8 W5 ]2 I: n- X; E8 T" R% g0 G+ a6 j9 [9 X' i. J5 |
        //检测磁盘是否插好" K* r; B  T, _
        //if(disk_detect_OK()==FALSE ) return ;9 l( W- r$ n. c& N8 H9 |" t* V
        //printf("\r\n inaert_ok:>");
7 @0 f! N$ f3 Z# D; O- i        // Register a work area for logical drive 0
' W7 `  p% P9 \" R* V9 f$ m        f_mount(0, &fs);" @, E+ M& x3 b7 M: Q
        f_opendir (&dir,path);
2 d  A0 t+ e8 Q8 o. S% T% W  p6 Y% i$ z, ]9 c3 y+ v
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        / a; I6 L# ~' E! |
        {strcpy(*(filename++),finf.fname);% k; M/ r5 k4 \! `: n; ], W2 Z
        //printf("%s",finf.fname);
; W- H5 F' N  P' \6 J& M        }# B2 Q  _9 b4 R
        //die(res);% L- Q, l# o; c9 X" s0 {
        f_mount(0, NULL);
7 @9 D5 L7 d% L+ c        return res;5 b* I1 A) ~: \: ?" T! b+ x7 k
}
* T1 d4 w4 U; r5 Q5 `7 H////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////7 `& I/ h6 `  G: i3 ^
FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名
) c# a& T9 t0 v5 Q% i# U{
* ~# z& g8 S% ?" I& W, T7 a0 Y  N/ f    FATFS fs;            // Work area (file system object) for logical drive
9 w$ z. W+ B8 V8 u; o% m% N( S( V$ N        FIL file;
+ O5 G$ I9 i* R* E, Z  ]1 P    FRESULT res;         // FatFs function common result code
+ \: N. }# Q) Z# r
5 _; r+ }# Y) `8 v& o        //检测磁盘是否插好
- o( Z. E7 I$ x: ?; n0 B3 k        //if(disk_detect_OK()==FALSE ) return ;
/ T9 t" t' W7 }$ i( _. u        //printf("\r\n inaert_ok:>");6 I/ B5 a+ ]( e- y
        // Register a work area for logical drive 09 P- Y; A" J7 P
        f_mount(0, &fs);: _% W+ [5 W0 E6 G
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。( Y- y0 r% d: ~0 J
                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
; \% G" r6 k- e! W8 q' ]* _                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
4 ^) `& J! @; k3 Z6 P2 ^        //die(res);
/ Z& z/ _' Y% ]7 d( g        f_close(&file);//关闭文件9 {9 g, n9 V6 @9 ^# G
        f_mount(0, NULL);- O% U2 a. A' W
        return res;
. t) M. U. M) z) `2 f, n8 [}
$ A8 N) b; o" U+ p+ C/ `3 c  {) _////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////  `; \8 o2 X8 v7 S9 ^( R* x
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        ; z- ^  Z6 Z$ l$ S, W
{. v( g; d" w$ K, z3 Z6 q2 D7 k9 ]
    FATFS fs;            // Work area (file system object) for logical drive4 e- P9 `" E! ?. G( |* e
        //DIR        dir;, t5 ~/ T& y1 e7 F0 F- d- x
    FRESULT res;         // FatFs function common result code
" K) a, E0 U/ ~) n
( c9 I7 [" e1 _  V( ^        //检测磁盘是否插好
  P, J. ~$ m( Q9 \        //if(disk_detect_OK()==FALSE ) return ;
- j! \9 ~  B1 F1 S3 C        //printf("\r\n inaert_ok:>");
! ^! [. f/ V4 D5 \# I        // Register a work area for logical drive 0. K4 o' A/ |4 T4 g2 x# [- I
        f_mount(0, &fs);  m0 a$ G2 g/ A5 L  j5 V
        //f_opendir (&dir,path);
! H9 q+ ~0 ^0 S0 S        res=f_unlink(path);//删除一个文件
! j: @1 ^8 w7 t- ]' p; O$ U, Y        //die(res);( p! D: F1 B8 S4 o" e
        f_mount(0, NULL);
) E5 H$ }( B+ R2 V% G3 N        return res;
! B8 {2 _7 }. g0 n, D; j) \, P}
; v  e, R  b* M$ w& Z////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////1 R& ?: q  X" J- c* T
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数, I7 p! Q0 O$ X/ _
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));3 n9 N9 M) f' J7 f: l& u- K
    FATFS fs;            // Work area (file system object) for logical drive8 w( z  c8 F4 W8 S& i; N0 E* T
    FIL file;            // file objects* y/ M/ o- K4 A' h. m8 |6 q! [: g
    FRESULT res;         // FatFs function common result code9 F$ M: ?! }0 C2 I
    UINT br;             // File R count 文件读回的字节计数
6 W  K9 ^& n7 j6 R; m5 L$ U        //u16 i;6 S$ p$ ?6 K6 C& ^- L3 H8 q
        //检测磁盘是否插好
% B, J5 g7 g: E3 U. q! R        //if( disk_detect_OK()==FALSE ) return;+ Q2 O4 H, V6 U; n$ ^* K
    // Register a work area for logical drive 05 \2 a: ~/ m3 G
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';* B* _) m( N) o1 I
    f_mount(0, &fs);9 E+ `1 i. t. L" l! h
        //Open source file4 T9 u0 e% X/ i( v. e
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
  E7 l2 p+ q9 T( @0 I  w8 B* ]2 d        //die(res);
* I' P" m. w) Q+ p        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
7 Y5 \5 t+ b/ K; c: T  ]4 F9 o        //buffer空间设大一点,会提高读的速度。: R/ I# C5 @: O7 p# ]" |/ ?9 V
        //如果文件实际大小512byte," e" @. g: f9 P' {& e3 ]
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。/ u5 N! Q# P; H6 p- Q
        //for (;;) 8 C8 v. e" R$ n4 G; S& i7 W* F
        {
3 w( D7 T7 Q3 J  R                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
/ G0 ~4 \) \  X& F
' R* x; C3 e/ o& u                res = f_read(&file, buff, strl, &br);4 w& P8 R6 G" C
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出5 p* K% O2 x9 d6 e
                + P4 y" y" P+ [7 x. v' x
                //printf("%s",buff);        
. V# G$ m6 ^# B8 r7 ]+ [    }                    # U6 @! ~6 k. ?8 x1 S6 i* u- [; _
    // Close all files
0 N' S8 W# f; a5 Q& Q7 x$ r% `( T% N    f_close(&file);* Y) }( |9 N! B5 J: b
    // Unregister a work area before discard it
5 s; p) }0 }% J# Z$ n  v: E( Y0 X    f_mount(0, NULL);
7 G& v, k2 [/ g+ l9 M        return res;. V2 Q' ]' d3 r5 H- j
}
6 {: {9 O! R4 [////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////- A' y) r, M7 ~9 _
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数0 N% ^4 ?, m/ P& |; s
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));% [* P  x7 M+ A( |4 Z9 t& r4 e
    FATFS fs;            // Work area (file system object) for logical drive
7 R" N9 h8 y# V) d: v! m    FRESULT res;         // FatFs function common result code
/ c' C: e8 A$ V. |& s5 m        FIL file;
* W. Z- ?3 K+ w+ v) ]& t        UINT bw;             //文件写入的字节计数/ G2 N: h1 Q/ i) l
        //检测磁盘是否插好
( A5 w7 K1 F2 t+ ?' w5 H( `3 ^! p        //if( disk_detect_OK()==FALSE ) return;
+ u1 Z- }- Y9 p7 s/ d    // Register a work area for logical drive 0/ k- n0 I& V  H- o1 M. u
    f_mount(0, &fs);, I5 F, y; V, v, W% J. m
    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
) i- Q  j: R2 b2 t4 O* Z5 v8 h         //die(res);
$ M* g9 k3 Z% y2 E; p    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
9 |: U' N) y' b. \( W0 N         //die(res);
) j; t; U* r2 r1 I" b: P. `        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符+ g( @1 m, M/ \" Z/ Z
         //die(res);5 e2 o0 L# _$ w# Z* e$ `
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
( e, r7 {' @6 T/ [& c$ j* C# U  ~        f_close(&file);//关闭文件" T) _2 O6 P, k4 m2 L
        // Unregister a work area before discard it
( X- {1 B# d  y    f_mount(0, NULL);
& w7 c) `1 m$ V8 _, I% J1 O! Q% U        return res;) N$ j& s" O8 j6 N# Q
}2 V8 q3 |8 ]( L
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% f! ~' j  ?+ X- ]" ]) s/ k
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M, v  m9 K, _9 d4 i7 x! D5 ]
{
) @  [: c" g( X2 n    FATFS fs;
8 q( `) W0 X2 A5 h& {* R8 U        FATFS *pfs;* s7 [5 @3 A& m
        FRESULT res;         // FatFs function common result code
, |, h5 F* Z. i; o0 a( D        //检测磁盘是否插好+ C/ |7 _( p" E% z3 W
        //if( disk_detect_OK()==FALSE ) return;
9 `# ^# z, K" K1 u        // Register a work area for logical drive 0
. d1 g( R% }# t" P- k/ k' F& c& _3 }        pfs=&fs;//指向
; n3 S3 G8 b* H    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
, L% p3 P0 e2 |    // Get free clusters; P* ?" @0 E5 i. M1 @( U' p
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"% Z5 `7 h, q4 ?6 X& S) k
        //die(res);  _0 ~  U$ v1 T1 c0 A) p
        if ( res==FR_OK )
& A+ z4 T7 _2 _  J3 S    {
* T$ f. ]9 R3 h' ~# ~( [* K, k            // Get free space
! d& |. Q3 I. j! H        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",3 g: ]$ G7 q8 ?( k7 B; B
               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024  v! s8 ~, G: x0 l
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024$ }- p5 M# K0 d: H4 ^* A
         *freem=((*freem)*pfs->csize)/2/1024;
$ p: _4 M4 j3 k  P8 D5 Z$ s2 e& I. p        }
" Q/ J7 a* k5 M& @        //else die(res);//测试函数执行结果分析9 I( e' x/ e- B- l
        // Unregister a work area before discard it
0 k- o2 h, k' d5 q. [    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间/ e$ s( L1 D! u0 T" ]
        return res;8 ^: c% c! T% i* d( r2 h9 }
}# ^6 k& q. [6 R4 ^$ O# Z

" _2 }- D3 u% g1 p" l2 r4 q! _, {5 X# w8 I0 A/ m8 w
; |2 U# j4 s) W6 p) m
/ Feb 26,'06 R0.00  Prototype.
; o: l2 N) i0 A7 M  j0 K& M- ~; S/
( ], ]$ t9 Q; _. ~' b/ Apr 29,'06 R0.01  First stable version.
" m. U7 A; f& \7 j/) w" @, f' Z$ ^( ^+ Z
/ Jun 01,'06 R0.02  Added FAT12 support.$ F) ]' L  O# w. b
/                   Removed unbuffered mode.
3 A) \+ q2 r) n0 ?4 a6 j/                   Fixed a problem on small (<32M) partition., s. Z" z( s6 x9 @2 q
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM)./ S& k( e4 c* E; u0 v) c
/$ B( Y" A0 F1 \: E9 M
/ Sep 22,'06 R0.03  Added f_rename().1 I  G( ]; _8 \! \2 H) ?
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE./ J: {% H- M/ l" g$ \
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.- e8 x) ]# x! L) C$ e
/                   Fixed f_mkdir() creates incorrect directory on FAT32.# O4 L% L1 P5 p3 ^1 b7 y
/' n4 w7 ~7 A- Q4 Y6 A
/ Feb 04,'07 R0.04  Supported multiple drive system.
% ~0 V/ H$ t' D  a- \& s/                   Changed some interfaces for multiple drive system.% l, v7 G: ?( Q4 S( Q" G" {2 d; `' a: l
/                   Changed f_mountdrv() to f_mount().
" ~* @8 P4 k, \/                   Added f_mkfs().
3 H: o9 H- p2 q/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.
! N+ B/ `) C0 m, c" K6 @$ w2 E. r/                   Added a capability of extending file size to f_lseek().
/ ]+ B$ m7 F; r$ O/ Y/                   Added minimization level 3.8 \5 `! \5 q' ~! D6 I0 E
/                   Fixed an endian sensitive code in f_mkfs().
$ c( o; o! B$ ^6 `! |/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
  {% u5 ?- J* _) _+ z/                   Added FSInfo support.
3 s1 u5 g0 d8 ~/ s6 Y) k/                   Fixed DBCS name can result FR_INVALID_NAME.% P1 i( _1 d* R, m, m
/                   Fixed short seek (<= csize) collapses the file object.
* B) R  j$ f, o/! Q+ ~5 P) q5 J( Q0 z% U& @
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
  T" u$ }2 P8 E  I/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.' _& o& z1 H: E; Q, Q7 J
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.
, n' w( x& i5 Y% X/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().8 Y( N3 \4 x; v  k
/                   Fixed off by one error at FAT sub-type determination.
1 d6 E( N% U: }* A# j# f9 q+ j/                   Fixed btr in f_read() can be mistruncated.
' N  k  N, ~, d/                   Fixed cached sector is not flushed when create and close without write.4 k; u$ B# U8 V" A( P
/
" e5 ~5 f% M5 b" ~- u6 t1 ~8 Y/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().0 i7 \1 K  S2 @& ?
/                   Improved performance of f_lseek() on moving to the same or following cluster.
( t4 A: Q" v9 k6 K2 u/
% O: s) D1 Z3 Z2 J* f7 l/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
# M- Z9 W1 V& p$ O8 g+ Q. m3 p/                   Added long file name feature.
  L9 M- P  i8 N9 f: ]& R/                   Added multiple code page feature.
) s8 _. r$ G* J$ c/                   Added re-entrancy for multitask operation.- N- o5 ]+ U, Q! N) M
/                   Added auto cluster size selection to f_mkfs().
$ R1 x  p( d" u( I9 _/                   Added rewind option to f_readdir().; D- F, M- V$ y& F% Z. P/ i$ M& [
/                   Changed result code of critical errors.
6 @$ W# E! g. l: w# b9 H* ^/                   Renamed string functions to avoid name collision.
# H7 v, X7 J( e' y# B/ D/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
+ L8 n3 |0 q; n$ f/ p. L6 R0 |/                   Added multiple sector size feature.! J6 [# t! o/ u$ [
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.$ Q. S2 q  {9 L  U) K
/                   Fixed wrong cache control in f_lseek().7 [+ w2 m( N* c4 G% `! k; U
/                   Added relative path feature.
0 ~+ u; G7 i3 X( t/                   Added f_chdir() and f_chdrive().+ x- E- ?' j) C" @6 i% H
/                   Added proper case conversion to extended char.) V6 U" ?& k7 t. r, X: R4 P
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
* G% W5 h3 F- q7 `. Z/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
# j7 J. [9 ~3 v/                   Fixed name matching error on the 13 char boundary.
0 }5 J) i6 b2 S+ t$ ?/                   Added a configuration option, _LFN_UNICODE.
, O! a  B5 R. i/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
% Q: f( L! I3 T8 ]! z6 N4 Z/
! f$ Q  U0 d( v' P, B% `/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)# x) N0 A* E4 x+ H6 i
/                   Added file lock feature. (_FS_SHARE)
0 T5 f8 }9 S6 ?4 b% ?! @$ {1 Z4 o/                   Added fast seek feature. (_USE_FASTSEEK)
% c' r1 B1 V9 H/                   Changed some types on the API, XCHAR->TCHAR.* M, D0 F* i' M
/                   Changed fname member in the FILINFO structure on Unicode cfg.
4 U, J+ Q2 G7 z/                   String functions support UTF-8 encoding files on Unicode cfg.
% o+ D0 [9 {0 l8 Z8 U0 W7 }. C* i2 P/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)* X: w: ]  y% S& C6 w. _4 s3 f
/                   Added sector erase feature. (_USE_ERASE)' s8 p8 r$ |; J, s* D& S
/                   Moved file lock semaphore table from fs object to the bss.
! b$ `6 t9 \. b) V8 F' M% U* E/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
* L7 T2 E2 T' D; X/                   Fixed f_mkfs() creates wrong FAT32 volume.
' n$ k4 _7 h' x/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().2 Z3 X" l- G: o
/                   f_lseek() reports required table size on creating CLMP.
& ?% P/ @; W6 Y# O, ~/ S/                   Extended format syntax of f_printf function.6 o4 F8 n- K# x( f! c0 x% S
/                   Ignores duplicated directory separators in given path names.7 J$ E% W; b% f" q
/
+ [# a! m( V5 h% v' J/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
8 ]$ y- P8 d5 Z: _8 Z- \6 q/                   Added f_fdisk(). (_MULTI_PARTITION = 2)6 A. I+ c$ U6 J0 i+ p7 k; w3 K6 h
/---------------------------------------------------------------------------*/: u9 v3 [+ |1 l' t6 }+ W4 `) \5 j
1 U( O) H; ?  v. d+ O8 L$ W

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-7-1 04:34 , Processed in 0.070507 second(s), 33 queries , Gzip On.

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

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

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