找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1370|回复: 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 p9 S. |* g3 u- s0 T- [  n4 P
/*----------------------------------------------------------------------------/% R% ?& z0 H0 q, C3 k
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
& ]3 l: k- D9 S1 J! p/-----------------------------------------------------------------------------/
, A0 I5 }! P% l  X. S7 c/ FatFs module is a generic FAT file system module for small embedded systems.
3 r+ x- N; }, E' Z( B$ M( e/ This is a free software that opened for education, research and commercial
# P; m' T/ ^7 a- B% P. z$ \8 n/ m/ developments under license policy of following terms.
5 G/ p5 Z- L" X- e/( f, p. h* V0 R
/  Copyright (C) 2011, ChaN, all right reserved.
& C; Q! x' B3 I, f/
; Z: k* h; ~1 k0 y  ?: O/ * The FatFs module is a free software and there is NO WARRANTY.
/ X+ k6 L% P# u  @1 {/ * No restriction on use. You can use, modify and redistribute it for
& ?9 V; B; t8 u0 n3 k9 e5 Q0 a/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.: [5 H6 N! P% m9 N* k5 W+ ?& C
/ * Redistributions of source code must retain the above copyright notice.
$ M8 v6 l3 _) c% V9 n/
2 j/ t+ a7 X# H/-----------------------------------------------------------------------------/8 A; G7 r& O  D

0 U: o- z! E3 q/ ?
( e4 j* W( ]$ i) O4 r, c7 z" ?/*--------------File Info-------------------------------------------------------
( R$ V7 Y5 @+ r2 {/ B) `1 j' {. z** 文   件   名:  FATFS_Function.c5 c1 }6 I  l7 S$ U
** 作        者:~风中的叶~    整理
1 Q9 e! v- e9 ~** 最后修改日期:  2012.01.18
# s6 u4 ?( [  n$ V$ D  R7 c$ _2 g2 l** 版        本:  V1.0
9 w- Y! _, s3 N/ |" \. P# F4 N** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
/ C7 h$ |  \$ C7 }% @) P**------------------------------------------------------------------------------
2 L; A2 O/ ]' w  v, h** Created   by:  Dt./ g3 w; d- t# T# V
** Created date:  ' R2 M' Z/ @1 C4 g, v8 c
*******************************************************************************/   ]0 G" @& C8 B. A$ z; t1 U& h+ x
#include "TEST_FATFS.h"# c( k( a: ?/ L; v& r
#include "string.h"
! ^( N0 h8 l1 S7 F
6 z. R' y' K* r' N  u. G2 @& B. K% Y#ifdef TEST_FATFS_EN+ P5 s  R& i- R% \7 `6 @, |2 G1 X* p% A

( x* c0 h; \: S7 c6 K; [- S( {! b, o* h) g( X
* {, S! t. X9 z, e
//检测磁盘是否插好
! F0 |# H6 l: ABOOL disk_detect_OK(void)5 u! h6 Q' L/ t8 n# n
{
0 S9 B& `6 H( t1 B! d    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
2 {8 I" _- O. t# @1 ?2 ]* K        {5 {8 c( ^6 b" `- Q6 D/ g! F' v
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");0 J: O! Y1 I) E
                return FALSE;8 f0 [- `  i8 u4 |* Q! E: i" N
        }9 H8 K6 N5 b. \5 y
        return TRUE;0 t& |# b9 a1 ]7 [* e! J
}3 i! w: m. v8 A
7 M$ R% ~, K, j, z* }% }; ^
( K9 [1 k  _5 l$ F

7 h7 n+ i3 c. _5 j" j3 H# @//测试函数执行结果分析
% k: L7 i7 S5 r( J  zvoid die(FRESULT res)
, r: ]8 g0 Q4 [8 ~! d. M7 g5 Y{! x2 ]3 y# Q6 H7 ?( t5 w0 t0 f% @
    switch(res)
. e. E5 I; \$ N8 ^        {9 L3 P, E8 R" _% @' D1 V0 |) i
            case FR_OK:        //The function succeeded.
4 @& @9 t% T7 L                {
$ f$ v, _+ A8 P/ Z( p8 P                    printf("\r\nThe function succeeded!\r\n");
) u8 W+ v+ [$ x2 p                        break;% w- N6 B% y( O' v: Y! e; z( e
                }
* }6 [. l& T: b6 d; f% i9 y4 t                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason$ q$ V2 {/ E& q  A, Z; g4 k
                {
  h! N5 l4 w& q; I7 B  a3 R                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
1 F. u; k' |3 I8 a9 _. p/ X                        break;
* [$ I& C" ~4 C; b; O                }
( A, I# M- U6 c6 Y! e                case FR_NO_FILE://Could not find the file.
3 M# a3 |9 V5 C9 N0 T, K                {
. ]7 F' f$ p) ]6 u5 N( t) L6 P1 `                    printf("\r\nCould not find the file!\r\n");$ r  h3 A$ _. c
                        break;; e( ]6 B5 g" u1 i. j" |
                }
& z  ~/ X5 @8 l! n                case FR_NO_PATH://Could not find the path2 I' h# u0 b$ X. e, Z
                {$ v. S# A% j& s" B, U
                    printf("\r\nCould not find the path!\r\n");+ Q* J* o+ ?4 h/ P1 r
                        break;
, I) d; F2 O- w+ T% r/ V                }
. L* w% q% a4 V                case FR_INVALID_NAME://The path name is invalid
. b& W. m2 s" f& I# }                {' c, f4 a6 Q: a
                    printf("\r\nThe path name is invalid!\r\n");
# k. H4 @9 H8 h# M1 t' G4 h, D                        break;/ _, O* e$ b! x4 Y
                }. a" m+ m+ v) k- b5 C/ v$ O7 p
                case FR_INVALID_DRIVE://The drive number is invalid" k6 }& `3 o8 d% P9 {
                {/ a( g  t* F' I' h. Q( N
                    printf("\r\nThe drive number is invalid!\r\n");2 P; @- {, {% l# _7 v1 J6 y
                        break;7 G, A: i4 m9 l; Y: Q
                }
( k# r- V: P5 B                case FR_DENIED://The directory cannot be created due to directory table or disk is full.
$ }) Z4 A; Z7 g5 h* \2 R% v# t                {
$ B% v# P* _! t, L                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");3 [- e& P9 A$ P0 U: `
                        break;
0 s5 M8 D8 C1 N" e* ~( {* Y& A                }
3 G5 ?# f# H! S5 I5 U: w+ s                case FR_EXIST://A file or directory that has same name is already existing
& n2 d" t& C8 Z) I% |$ A" k                {3 c- r7 g6 x; P1 y' l
                    printf("\r\nA file or directory that has same name is already existing!\r\n");
6 m' ?1 E) m" }                        break;4 k" F" R- `1 G
                }# c; A/ Q" M0 [% C. g3 N! U
//                case FR_RW_ERROR://The function failed due to a disk error or an internal error
8 T6 N8 ]9 T$ w. U2 g' p/*1 \- X  R7 ^! Z0 d4 q
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
1 \6 O4 O3 m3 O                {0 Q! a3 w' w  J3 i5 \
                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
! l0 R( @% \. O, ^                        break;
  m  ~5 T% ]. e/ P: S) v$ D! o2 p                }8 I! _1 S& y! p3 ?* N) U$ I+ L& `
*/
0 ?; w1 G/ p2 T; Z                case FR_WRITE_PROTECTED://The medium is write protected
9 w8 }  c/ |6 w7 X! H* e                {0 L0 z4 j8 I: P; T9 g. P
                    printf("\r\nThe medium is write protected!\r\n");- q( R7 Z; b/ ?; [. x
                        break;
/ d7 @: R- u) x8 X% D% ?& A6 J                }9 L, l6 g* d; J4 G
                case FR_NOT_ENABLED://The logical drive has no work area
5 ]1 w- W( c5 X$ Q. j                {# e8 S5 R& P/ f- A! z" b- R
                    printf("\r\nThe logical drive has no work area!\r\n");
, J5 y2 H! [* J                        break;
$ W2 X0 J1 |; ]' t  t                }5 X! i/ T: }5 F$ {) ~( |: Y
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk* v/ Z9 l+ \' n% D5 K
                {
# K, J5 f' ~' V3 E0 {                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");
! J4 ?7 H( B5 q                        break;' V' s# c+ x0 A6 w! @/ @  P
                }
; v% @6 q  L# \; I9 O! ^                case FR_INVALID_OBJECT://The file object is invalid# [& k  e; ~2 {9 Y4 G  m8 y- ]
                {
/ u: P) @3 r9 ]8 K$ T                    printf("\r\nThe file object is invalid!\r\n");" r, D0 y- M# S! Y" Y3 {0 q
                        break;) ~# R( r( {8 W- t, c
                }
1 a3 R6 T7 r: a1 Z8 z* Y( ^2 C9 }  @2 P% g/ h' _. s+ I
            //The function aborted before start in format due to a reason as follows.
( C. a" P1 m! {        //The disk size is too small. : E/ }( f# W2 o) y/ D
        //Invalid parameter was given to any parameter.
, D; U5 X8 ]& T1 I- D        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7. 3 O* }0 o7 a1 b, _3 [% D$ D
                case FR_MKFS_ABORTED://' ~) V+ z9 z- ?
                {
# @* V7 X: l  u, l/ M                    printf("\r\nThe function aborted before start in format!\r\n");
" W& U+ {9 a# J! y                        break;, w. J) k, A# A+ @" D7 E, J
                }
6 d0 j+ p  ?) s. D/ q: I7 M: f               
! u. ^: h  a! D2 W+ e% `                default:- D, b( Q, O0 V3 A! g! F
                {$ ]9 m5 P8 C0 |
                    printf("\r\nerror!\r\n");  |$ j; f8 @) T0 t' s
                        break;8 F6 g2 f4 X  b. E7 o
                }        3 |+ ~! H4 U; T. Q
        }
( {  o$ @) I; P9 k) I% D% O' l        return;" s! C2 a$ T5 I/ \$ C, N! p
}
5 f' M/ I' L: _void Test_f_getfree(void)//获取卡的总容量及剩余容量& b! m) M# h/ R$ L
{
6 ~' V& f* j% K+ F& B    FATFS fs;
. y3 E2 s; X& i! W7 J2 J% n        FATFS *pfs;
) @7 ]' ]) `7 G    DWORD clust;; e3 B% O6 n9 }" Y
        FRESULT res;         // FatFs function common result code/ r0 B( Q( n! i/ P& F3 ~
6 Y+ {# N  e0 g, B; H
        //检测磁盘是否插好  \' ^# G- f. h1 l; r4 G4 ]
        if( disk_detect_OK()==FALSE ) return;
& e7 B" v! o, O% W( V+ U" w
9 Z- I+ O* r2 j5 D5 S; b/ Q        pfs=&fs;//指向& W' y* r2 ~) o% o" S; j+ B
        // Register a work area for logical drive 0: ^  E: m2 b- x. T: ~) v% z. E
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间+ D+ }! q& W9 K! U/ z1 z

/ f- A+ }4 y  t) D    // Get free clusters/ g+ T2 P) ?# b+ q" w2 b6 n
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/": p! ~/ h; I$ i; K/ ^" H- i1 u
    if ( res==FR_OK )
( Q" y0 @) w( E- e8 `5 z    {
) D! R* b0 f2 k7 S! L            // Get free space. G, g& ]2 L. q: r3 E( L( b
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",- I% t  B1 F" j+ u1 i5 z& Q
                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024) l" F6 S/ J$ {. k7 [0 P
                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10240 L3 ^- V& T. E# e; A" A- ^
        }5 g3 ?8 i5 H' a
        else die(res);//测试函数执行结果分析
6 q' ^& q0 z, c/ ^" W' z( i& T        
3 a0 n3 X( M$ |0 W7 c        // Unregister a work area before discard it2 H8 e, i* |8 l3 Z% t6 R3 Q, P
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间) }: b2 ?, m& d/ n* t8 G
}
& b! c( n' Q  l, y
; y& P6 Q- \% J& t$ Ivoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误2 i1 k' H- h% z- {: D7 K7 J
{
6 k' r& P5 R. X* B    FATFS fs;            // Work area (file system object) for logical drive
! ?/ X$ f/ ]# {0 O$ \$ [    FIL fsrc;            // file objects
- h$ d# N% ^' g/ ?    BYTE buffer[512];     // file copy buffer
' L5 s3 C9 e( u) x9 b    FRESULT res;         // FatFs function common result code$ k) L' W6 C/ [$ l- Y) i! A
    UINT br;             // File R count
* W& v1 \1 K; v        u16 i;
! H/ e6 s' R+ R& p5 }        0 h4 [7 d. X$ p# w0 U0 U

' t$ F( R' R# W/ b$ _. b) M        char path[20];
4 b- l, a/ }( O1 F2 t) W6 j" G# x- l0 ^7 \4 d
        //检测磁盘是否插好0 n: ^: L+ b- {9 v- w9 @
        if( disk_detect_OK()==FALSE ) return;8 D3 q/ k4 {( Q! {& j4 k) Y* h

5 U3 e, D# }  y5 t" `    // Register a work area for logical drive 0
- a( Y7 T8 p$ n7 m    f_mount(0, &fs);) N* m$ U; d& i( q3 k( [

- Y/ c6 L2 r" C. ^. W& X        printf("\r\nread file:>");2 R* L  k! Q( K. }/ ~$ J) o: W
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt7 ~) Q" \5 p6 M) S# m3 N- B( H

0 @& y7 [- _& i9 u; R9 U        //Open source file, M( e& B  Y5 y- C; y& V/ r4 A# Z
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误" A; [% H, z, j' u. h+ y5 H
        die(res);4 E5 D" |1 b& ?2 D5 G5 _0 A
        % Y$ w- O( x3 M0 v) E# F3 S2 j
        //buffer空间设大一点,会提高读的速度。
7 K/ K. {& r8 \6 n: g5 K        //如果文件实际大小512byte,
! \8 l! ~* i- p& i7 k0 S        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。3 D! [: ^0 E+ y- d  k
        //下面两行主要是去除1s误差。
5 t' u- l% m; L( i) N
7 N1 g3 u( d$ B5 H        for (;;) 9 y& t% }/ y  o' g7 O
        {5 q2 s# p# ]9 ]0 ?; [, b
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存; y: R( ?/ t( r$ m0 K! R3 Q8 d. n

4 @. c# U- c5 a' |; w                res = f_read(&fsrc, buffer, sizeof(buffer), &br);: ^1 x+ {, ?" E& B! o/ b( d
        if (res ||(br == 0)) break;   // error or eof        
: a, X& n  v+ E% K               
, M: t# R% ]% [4 M( y0 _- Z; q                printf("%s",buffer);        
% i4 x# }4 v( W9 n( r6 Z    }* C7 n2 h! j+ q6 |) @! u
5 b2 Z# k. M2 r- c4 T
                           
0 f, b% \& P9 b  c8 z- I    // Close all files/ Z( [0 f% |9 T1 Q, E( d
    f_close(&fsrc);
2 n7 k( t* w% u! N& w    // Unregister a work area before discard it3 B5 Y( X  n: i+ s7 o
    f_mount(0, NULL);
! ]% `0 [& \" Q, E}) l1 I5 G' e, \+ u# \& e

1 H1 g! ^  V# Y9 wvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
6 I, v: M& ~/ `{
; o# F6 w; R" Q4 a    FATFS fs;            // Work area (file system object) for logical drive8 x5 V, a" d7 x2 p/ {; W/ j2 m* c3 [
    FRESULT res;         // FatFs function common result code; ]$ X- i+ ~4 k# v; K
        FIL Make_file;
- E' N( f& Y6 q3 _5 e/ C    char file_name[20];) _' Y8 O' [% W8 Y
    char Storage_buffer[] ="0";1 E* a; _) H9 H/ e6 D2 e. E
        & j( B4 b# X: ?* v1 E) M
        UINT bw;
6 J; s- ?2 o0 c+ _        //检测磁盘是否插好3 P# l; t6 _; q% z4 S6 |2 |
        if( disk_detect_OK()==FALSE ) return;
% v9 a, F; G8 n6 x+ G. U- @' w6 l, U         printf("\r\n inaert_ok:>");
2 }! ?$ Y# Y+ b1 C" P, R    // Register a work area for logical drive 0
6 |1 f8 P3 h4 z& V3 C    f_mount(0, &fs);
& Y* f6 c" N( o
& I2 ]1 j! [$ z) [9 E+ z        printf("\r\n Make file Name:>");. r+ d# T( }2 b( w' |) ?* r
        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt. k) \- B' B8 d3 ?4 S5 E
& R! T  Q8 @% T+ O0 L( C
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 ; }$ q6 _( I7 p
         printf("\r\n open_ok:>");
6 @( P/ F. U: U         die(res);
- b- |6 F, {) C- m7 P5 b- Y3 @    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
1 }& N2 m9 X# R' e* L      printf("\r\n seek_ok:>");# T$ @: A, M& Y( s9 U
         die(res);2 p6 _; B/ W7 S1 r! X
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  $ ?5 u/ ~: c; X
     printf("\r\n write_ok:>");
( ~% \" l9 ~7 h/ h0 R0 \6 S9 [         die(res);
) F, v7 f0 g- v" y2 s" i        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
) P- d! s9 R6 k" x* W8 \' m; Z, @        f_close(&Make_file);//关闭文件
( s6 z6 K5 o; y$ k# m2 n; M  c        printf("\r\n close_ok:>");
( m" U& N3 j. A' x6 c% _9 O, ^) s4 o) O7 R3 Q% y
        printf("\r\n写文件测试OK!\r\n");' ^/ I# H: b( H8 Q  z  K

9 M8 s# s. n0 [/ C& `& T1 ?: A        // Unregister a work area before discard it. [: S- q+ a  Q! T, L2 O
    f_mount(0, NULL);
  q) S6 i7 l4 J4 h0 I) c" b}7 N7 X! N" D. g, n# g" `* J$ X
7 |' m& Z9 M% W& i: G
//The f_read function reads data from a file.
# ^4 j0 p- l0 {0 A, s* w//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
! T% b- |4 m; A% R- N//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了. D7 i& p" k% V/ t& @/ C7 p
//所以以后要特别注意这个问题。; f: v$ t9 F/ x& E7 T& y& y7 U5 ~9 _
. t/ v0 ?9 _3 o0 [6 `2 _( I
u8 StrToData(u8 * data, u8 len)2 }0 s  S+ ?4 [  u7 O
{2 y+ N. i# K4 ^; {! Y
        u8 ltemp;# L1 X1 \5 X4 n0 r
        if(len == 1)( n1 b5 G* ?" v3 Y/ |, V
        {8 Q- p! {1 E+ ~/ V/ |
                ltemp = data[0]-0x30;
6 h9 ^7 o4 h& x) O3 |9 s- x: J- s  D6 o4 C
        }
$ Z9 }1 G9 f( r- `        else if(len == 2)" P$ J& |) {) |' R5 o, z
        {
' n1 \. i# j7 w& z) C1 q' A                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);3 G3 t3 F$ C8 v

! b# N, q9 q* r& t         }
5 v0 e3 Q! G! P1 o* `- U  v3 `        //else if(len == 3)% j) z6 Z& T- o! U0 f8 h7 f
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
' E! J) T* e9 F( B2 s5 s* d: v' T+ l0 [7 ?  D* s4 s
        return ltemp;0 H4 ?! q9 [4 m3 |4 {6 m1 {0 W
        # M9 ^: Q1 F- ^
}% R, @+ P; H" E1 W! W

6 o& ]7 Z( Z( m7 D5 P4 B( ]4 K2 ?' s8 W+ v
#endif& P' ]1 U) w& s
8 ^8 X6 \$ L) v$ T0 ?

! P5 J# m- u# L; E6 {9 J/*
  Z9 o) Z; E0 f- L' I9 }int main(void)
( S) k, Y! T( B  |7 d( f6 T{
8 p; f  j7 c* _. @' M  i& U///////////////////////////////////////////////////////////
' z5 j, Z9 p/ S0 [! T$ fUART1GPIO_config();//串口IO口配置* O+ k2 b+ n# e/ T% M$ N3 Q
USART1_config();//串口初始化波特率为19200
+ W) y* S% {$ e5 G* S, k//UART1NVIC_config();//配置中断
/ H3 o7 J3 I' J( @* B///////////////////////////////////////////////////////////1 h, L7 |  c. O7 k, |
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式# A  v. y+ i7 N$ ~% g7 r
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它% l! X" J0 O( P7 F: T/ o/ ]
Test_f_getfree();//获取SD卡的容量和剩余容量
9 o: w9 Y5 F: ^3 Q) }/ P2 vTest_f_read();//SD卡读文件测试  {! {: v% s& z9 G, O  \
Test_f_write();//SD卡写文件测试! {4 d4 }& N6 y- L1 Q0 y! t3 i) F5 }3 S' {
///////////////////////////////////////////////////////////
2 x5 [: U% z; ]' m. ?% G    while (1)
0 n  M5 O% j$ U  B6 r* `& M    {+ N( P) ^8 b. w* m! e  B
        //printf("好的");. e/ e5 K! u; v2 |4 G
    }' {8 ]& l% V. T- C0 @1 O! V9 x
}*/5 M: Y) `9 L2 Q2 }. b; X
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0 h, {" J& c: w1 Z# C
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为05 I7 L% G. O' ~+ L1 n5 ]5 K. g
{
, x: S" O0 G0 _* R8 f1 x    FATFS fs;            // Work area (file system object) for logical drive5 V( ?! j: e; L  J; _/ p
    FRESULT res;         // FatFs function common result code! z6 s- g. v6 g

' D4 V6 d, U5 ?. ?9 C  ?; P( u8 c        //检测磁盘是否插好
6 I/ c+ N4 R  ^, i7 x( g2 C        //if(disk_detect_OK()==FALSE ) return ;6 g9 f; @9 p& G; q8 m
        //printf("\r\n inaert_ok:>");9 F8 R5 i2 ]& l( u7 J, q
        // Register a work area for logical drive 0
1 j; r+ K3 @3 o. ]/ J$ @7 {        f_mount(drv, &fs);" Q% I; X: S: f, W( ~
        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
& D1 }0 G0 [5 ^+ U& M+ \        //die(res);
5 m" S# M3 A# y2 i9 H        f_mount(0, NULL);% D9 l" ?4 v6 B9 Q
        return res;) I$ f! ^$ @' z/ O, {! K
}3 V+ r) z$ O& f- A  K! s. ~
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////) t+ W1 Y+ V6 w4 u9 s+ t
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录          g* I) d: T9 m/ X2 g" u. E! Q
{# U" J0 B4 ^$ G! x& }
    FATFS fs;            // Work area (file system object) for logical drive
' E# j+ O% q- E9 M' l2 [" }    FRESULT res;         // FatFs function common result code
$ G8 E5 @/ u% h4 B. u6 L4 P
" w8 y1 a/ C! P  X        //检测磁盘是否插好! K' r" S: l1 Y3 [, y
        //if(disk_detect_OK()==FALSE ) return ;% `5 }$ V% a" \  C# ^
        //printf("\r\n inaert_ok:>");6 k$ S$ P8 ~, ~+ a2 V7 T  B% a
        // Register a work area for logical drive 0
. |* v# V9 K* E) s$ ?        f_mount(0, &fs);
/ `$ H* y9 Y! K5 E5 i4 A" ^        res=f_mkdir(path);//创建一个新目录& {7 h# Z) B$ e) q* _& V3 g. b& k9 `
        //die(res);
5 o/ @1 C5 Y/ a" [. Y, n$ O( A. F4 `        f_mount(0, NULL);( C1 ?" Y2 M8 p* [( K' @
        return res;  ~3 q* F; l) Q, R6 m/ Q1 f
}
$ s# ]' {# e1 }+ D/ _( X////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
5 a4 n: f0 s. |FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        , u( D- Z( W/ @: f% }
{
+ J' [5 c9 B' n5 {5 p    FATFS fs;            // Work area (file system object) for logical drive, b6 z6 z: T4 K$ k3 B
        //DIR        dir;
; `2 V- S) c" g% K7 T    FRESULT res;         // FatFs function common result code
* Y- f) @1 Q: t" H
- ]4 c/ h4 i* d/ Y: E( v        //检测磁盘是否插好0 M$ ]2 `- O; ^- }* M
        //if(disk_detect_OK()==FALSE ) return ;! W; x( B+ P1 q& `2 ]! H0 {
        //printf("\r\n inaert_ok:>");# I" H( i; f6 D( {  d% H1 E7 n4 u8 y# n
        // Register a work area for logical drive 0) A9 C- ]; x/ K
        f_mount(0, &fs);
) O: J; `. i7 e1 G' f$ p        //f_opendir (&dir,path);- _! S2 i8 E# G8 F' \
        res=f_unlink(path);//删除一个目录
( }! b# ?7 }1 _( o% ^! W        //die(res);4 t+ l1 R8 W& P3 o8 H" c" {
        f_mount(0, NULL);2 T- |$ r- u, {
        return res;2 b. m; U8 e' ]$ S
}+ O. t- B2 h1 o" O) {- z3 r
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////' K; K! V* M( `  w$ `; h  g: I
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
. q" X2 G5 \' s8 U" }{% ]3 R4 {8 \$ g8 {2 V
    FATFS fs;            // Work area (file system object) for logical drive
; w) J( _. d0 W% D& N6 a        DIR        dir;
, H5 F9 j- \% ]0 y* `        FILINFO finf;
5 ~1 `% w4 b& V$ z. H+ _4 D    FRESULT res;         // FatFs function common result code) y' X6 T; Y# l6 ^+ |" A

$ b( |+ S; W: {, U% {; w# }9 W        //检测磁盘是否插好6 o1 l7 w. Y( p$ i, o
        //if(disk_detect_OK()==FALSE ) return ;
& k) L( N. @( {1 S        //printf("\r\n inaert_ok:>");6 F, u7 b! C; R& L9 S
        // Register a work area for logical drive 0
+ J& `2 ~6 d) K& y- b$ c& Y5 {        f_mount(0, &fs);
8 N+ v# m7 c- K. j9 f$ V        f_opendir (&dir,path);1 z+ t& h1 o% _+ Q* c
, j* @0 A# h% i6 E! c
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
$ E* t- `, a+ p) U0 l        {strcpy(*(filename++),finf.fname);
1 a) S) p  w: j) p+ E; W7 {        //printf("%s",finf.fname);
! k/ D- [. s9 w; m2 {/ x        }
) }2 x; F* d; V        //die(res);& W& F$ l& L' o
        f_mount(0, NULL);- k) c) [- s0 k' C8 }- f
        return res;
/ ]; X/ R4 B! R- E) b8 K. y}
0 H; x' F- |% r3 Y  m3 C////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 ~# `& k4 q" E9 y2 uFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名
- _( m7 d# l1 R7 O, i' ^5 v) w{8 i3 f- b5 X# t! O+ @/ w
    FATFS fs;            // Work area (file system object) for logical drive
$ h' X( _. @/ I& n( e# p5 p9 Y        FIL file;
  k0 K. L( a4 y9 G! t" k" x    FRESULT res;         // FatFs function common result code: ^1 L) K& q0 e3 v: t3 T

; d4 b% J+ a) b, `% g        //检测磁盘是否插好
5 `* u+ Z5 s% k' }! z( C        //if(disk_detect_OK()==FALSE ) return ;4 N" Z. O9 \9 m- t% j/ y. w7 V( I
        //printf("\r\n inaert_ok:>");9 n! H# l2 G) Q2 K0 Y
        // Register a work area for logical drive 0- A! Q7 @3 t8 p- w6 }
        f_mount(0, &fs);; w  y! Y5 t/ A0 T, ~
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。: s8 U* b% Z, m) H
                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
& M5 |# X9 ]7 b% Q9 w( a2 K                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
* _$ f% J, A( o        //die(res);
$ q) z. _* j) j        f_close(&file);//关闭文件. X0 y  P+ {. U0 z
        f_mount(0, NULL);
2 p3 B: N- R- }  g: u4 q6 N, [        return res;
- V* z4 f3 p  P  C}' j7 W5 Q0 n' d8 e
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6 W2 o5 P& N, l, G
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
, A, T# m& f6 `5 E# c{
- ]! G9 W4 y6 s7 {9 k. \# z    FATFS fs;            // Work area (file system object) for logical drive
' i& G" [1 L% O$ [  e        //DIR        dir;
% |1 t; p# C4 [' U( _# [3 X8 l    FRESULT res;         // FatFs function common result code
* Z5 I7 K/ J; p& {8 r* B* N
& R" v7 I! w+ t        //检测磁盘是否插好
2 e8 L) d( W2 p1 V' |0 }        //if(disk_detect_OK()==FALSE ) return ;
0 f" Y% a/ T* i* f6 h. s( \- x        //printf("\r\n inaert_ok:>");
! x: ?7 \- z0 j3 u6 T2 W; j        // Register a work area for logical drive 0
; J0 l; P" m, W+ y9 N# W" @% s4 ]        f_mount(0, &fs);4 e: q1 ~5 G% Z; A  K/ w
        //f_opendir (&dir,path);+ V" J% Y7 y7 X& Q
        res=f_unlink(path);//删除一个文件
6 U8 D5 o; [0 ^$ s# H        //die(res);; s" I* ~4 m% n2 X+ H5 f
        f_mount(0, NULL);
# k$ D' q9 d( y$ R        return res;
, r. M! \( v0 F8 K0 U3 @$ @: J}
, |% [$ y. R( Y# O. W////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% f" y& f# `# i  Z1 RFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数+ O7 {' c$ X  M; e5 |1 g
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
: O# a, N* Q# H/ \+ Y4 a- a7 {3 B    FATFS fs;            // Work area (file system object) for logical drive  w; A( y0 X* g. o) [- O7 P
    FIL file;            // file objects4 Y7 K- ?$ ~* A) I
    FRESULT res;         // FatFs function common result code( p( G8 [$ v* x. [
    UINT br;             // File R count 文件读回的字节计数  N4 N; K* R" M$ S9 q4 m! y& }
        //u16 i;& V# w' D* w6 U" }" T1 h1 o: Y
        //检测磁盘是否插好
$ ~: ^3 p  m$ J" q7 ^/ V: }% P        //if( disk_detect_OK()==FALSE ) return;9 W8 r/ g4 Y" @
    // Register a work area for logical drive 05 l# e0 o+ U  N; q" }" ^
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';5 Y" I4 ]% g5 H" E; B7 Y7 K6 U- i
    f_mount(0, &fs);# D% m1 f0 I8 ~: S9 K
        //Open source file4 Y4 w2 v2 [- t% ?6 O' E( |6 u) \
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误6 r  \. @/ w* t. y! q! J3 ~5 L" {
        //die(res);( {) q- q5 T% e: E
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
  r1 T6 @+ s" d, j        //buffer空间设大一点,会提高读的速度。; d: _6 P. z8 j, t' o
        //如果文件实际大小512byte,
, Y: B3 p* W, q5 c$ s        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。7 h( \" @: V5 m; @  z
        //for (;;)
) D. e9 Z% A0 \# T8 A1 O5 v# c6 }        {/ \, s& Q$ K  c4 [7 n
                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
" e1 _1 w/ R8 {& E& Z; p
, a* i. t7 {& k( o. l8 k4 S                res = f_read(&file, buff, strl, &br);
+ K; M) z6 D2 T        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出+ @  j8 L' k& Z7 _. L( P
               
& A- C  m  H+ A6 D                //printf("%s",buff);        1 I% y: \, o) ~7 \$ Y
    }                    
2 z: w" j; M& j! l  D$ k    // Close all files
4 x* p1 q, Y& l$ j. O$ H! C    f_close(&file);
4 U& D9 M  M8 q, f5 ?; t    // Unregister a work area before discard it
7 L9 I1 C) I3 }2 N# L6 ~0 N- t    f_mount(0, NULL);
6 t( }: b/ n5 r' H: C        return res;
, F. D2 V. E1 j8 j! ?}
' w! C1 Y6 O% t+ G0 j////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" r$ g# G) l7 hFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
/ M8 ~) i" u6 P1 a: K8 B! t3 i4 \{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));
# I' I7 X) i2 `" n  ]) `    FATFS fs;            // Work area (file system object) for logical drive8 i" Z- g, v  q8 k) A
    FRESULT res;         // FatFs function common result code$ P" i, h% m* C; u
        FIL file;
/ s/ q1 |$ |  g' F        UINT bw;             //文件写入的字节计数% }* j. D- Y& |$ \/ E
        //检测磁盘是否插好$ Q! Y# h1 ]! q- ]. U
        //if( disk_detect_OK()==FALSE ) return;
! g) \' N! L$ j5 D    // Register a work area for logical drive 0# T3 U  b3 u- _4 a# |
    f_mount(0, &fs);  t$ k- ?. x. u3 z
    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
$ q) g& }0 i4 Q# L$ U         //die(res);
% Z- m+ b- e6 l8 c# z    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
4 _) c) r+ _2 `! d' J$ t         //die(res);1 S3 O; ]3 L9 L+ \
        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符
4 k2 [. S( F% |( ~         //die(res);
: z8 o* b, E+ K& a' {        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  & s; I/ G. C, ~3 x; f6 k
        f_close(&file);//关闭文件
' J3 C: v7 M5 y/ \% @6 [        // Unregister a work area before discard it
& E# `( d/ S: N& j% g5 x' L    f_mount(0, NULL);
- q" o5 s# O5 r6 G        return res;! Q: |) j& |- D  Y& T
}# F3 {  @2 H9 E- `. ?
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 x# T: Q, H8 h) S: wFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M) e5 b& n2 k6 [5 r0 y) \
{
* N, A: h% ?" T  f( P    FATFS fs;' W2 N& R! ?! p$ I+ j) ^
        FATFS *pfs;
9 V* j" X$ ^5 i        FRESULT res;         // FatFs function common result code  a6 f3 ~( A7 l2 W, E0 R6 K: Z
        //检测磁盘是否插好
: s3 R' b7 r3 o6 n* s  O" T. [        //if( disk_detect_OK()==FALSE ) return;
3 m1 U  x  Z! f1 o8 j% M        // Register a work area for logical drive 08 i  i$ L: J  H2 j- h7 Q, w" j
        pfs=&fs;//指向: z1 \' B% ~% U& t0 N! y/ D# {
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
& u" G2 d7 `9 x2 K    // Get free clusters
; W* w" l. n$ G3 S. W& t0 m    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
7 O* U8 C' U4 E+ H( x        //die(res);. f. P( m/ K' [9 G) L
        if ( res==FR_OK )
7 _6 ]" v8 h+ Y1 O; ?    {
1 A+ h& L# s6 O) j+ K; ^, a+ v            // Get free space
( p; C9 V: m' q  _7 Q        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",3 ~  I  C6 b2 |% M
               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024* p! w! u. p; e: Y% H# l
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024, \" M( N5 Q, O) G/ ]3 C$ O
         *freem=((*freem)*pfs->csize)/2/1024;9 ~& \* ]! \% D* j- M  Y
        }+ R9 l" @! A/ O; O6 u3 R+ M! U1 S! G
        //else die(res);//测试函数执行结果分析& E4 j" L3 v  d, N$ D6 @  A
        // Unregister a work area before discard it7 I7 b! _1 f0 ~1 X2 v" f! T. s
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间8 \) D: a/ ?  I* u$ M+ e
        return res;# e* m8 Y0 `8 H0 j4 g: v( A
}& f" T9 b+ X3 z' A/ @) C
) r1 v! O. Y/ ?( k0 E7 U

! n8 A# i# y# O; ~0 B* _! Y3 O$ ^/ i4 |. s4 H* r
/ Feb 26,'06 R0.00  Prototype.
& P' F6 k- r/ ]/ H- o- ?/
) [2 n& n1 L+ t, r/ Apr 29,'06 R0.01  First stable version." F. V) V! @+ o$ e. _# H6 s8 _
/* T, R+ c8 p7 g8 N, D6 R
/ Jun 01,'06 R0.02  Added FAT12 support.. _+ h" l% [; y  I: |
/                   Removed unbuffered mode.
% o4 s' |/ Q0 r/                   Fixed a problem on small (<32M) partition.
# A8 G* j2 R* L; F/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
8 I- v3 t  U* Y; r" F. b/  z  w6 [0 U# N8 w. Q. G6 d( e
/ Sep 22,'06 R0.03  Added f_rename().
, P! W  A6 _- R' n/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.
1 }, E/ ?* b" R* j# [" ~, \2 [! i/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.- C2 [# v9 h# _/ w+ v8 n* P! c
/                   Fixed f_mkdir() creates incorrect directory on FAT32.
6 g& v' @% Z9 N! H$ ?! a/
3 J) a; A# Y8 g9 N/ ]; E6 _/ Feb 04,'07 R0.04  Supported multiple drive system.+ o7 X9 ?: X! Z+ G- g% v. ^
/                   Changed some interfaces for multiple drive system., ]" ?) H0 ^3 [* t( Z2 h; B
/                   Changed f_mountdrv() to f_mount().2 C  D7 R* V& p6 T( u1 ~) T+ O
/                   Added f_mkfs().5 Y- b0 C* z! ^9 N$ [* n% D" N
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.) M3 C- Q/ L' U
/                   Added a capability of extending file size to f_lseek().0 _0 [# j+ y+ Y3 R' a3 Z) h
/                   Added minimization level 3.
) ~. H" n5 ]6 S9 l" I( V/                   Fixed an endian sensitive code in f_mkfs().
8 V, @" x+ c0 r+ V" h( ?/ \, i/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.' q& \% R0 q' M) c3 R
/                   Added FSInfo support.
$ L( n: }; a$ z( u' x  A/                   Fixed DBCS name can result FR_INVALID_NAME.
7 e5 g. e+ U! o# D% f2 j  O& ^/                   Fixed short seek (<= csize) collapses the file object.
9 E! M2 C3 d. h# @  n1 f/
8 M8 f; L$ ?1 P) \# [/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
5 ?' c; H' p9 @2 y6 \$ r/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo., {, r6 ?& Z9 D/ j/ }
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.! W& h2 S1 V1 M, ^! ~
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
3 K0 J( F3 T  j$ s* h4 ]/                   Fixed off by one error at FAT sub-type determination.
. q) n( U8 V; P# o9 ^1 w/                   Fixed btr in f_read() can be mistruncated.4 z& p3 ]& H: j  U3 r* P3 {
/                   Fixed cached sector is not flushed when create and close without write.
2 {) G# w* p& u0 T% R/
: @" z8 Z. B2 B9 P: E/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().& V5 W7 k) Y* S& b, h
/                   Improved performance of f_lseek() on moving to the same or following cluster.
$ S: R4 r# g4 U  e# @/
& c7 v. W9 r3 @/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
4 t, w2 }) P5 g+ d& |9 |) D/                   Added long file name feature.
& c6 Q* |7 W: r' d! e$ i: Y- ?. i9 h# W/                   Added multiple code page feature.* @2 k5 A7 I% b  a$ E
/                   Added re-entrancy for multitask operation.4 n% S' k1 f2 c* I+ I+ ^9 [1 U2 S' \
/                   Added auto cluster size selection to f_mkfs().: F% v7 I0 ]" D5 a
/                   Added rewind option to f_readdir().# C- L1 B$ c: s, I) a- A
/                   Changed result code of critical errors.1 m2 c3 y7 C2 d/ P( Z7 S
/                   Renamed string functions to avoid name collision.
, f% j3 K3 M! k: q$ Z9 l/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
1 j0 [. o1 o( j( R. p/                   Added multiple sector size feature.
- D- s0 j' L. j# U- Y& z  \9 m/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
* b4 [2 f9 `0 E& `# s/                   Fixed wrong cache control in f_lseek().
& ], f# x0 D' W+ O: q3 b, n1 d/                   Added relative path feature.
! L8 |9 w- K- e- |* I  c  x/                   Added f_chdir() and f_chdrive().
7 B# g: ?/ S( X& B" z5 v2 u/                   Added proper case conversion to extended char.
3 U$ ?7 `& e$ X" ~1 p. j/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
$ \7 Q$ ~) E, X% d! Y/ a; @/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
5 U9 ]% Y* B- K4 ?& F5 E, w/                   Fixed name matching error on the 13 char boundary.
5 ^/ y, Z" K; S1 q" S6 A$ W/ A/                   Added a configuration option, _LFN_UNICODE.# f( v3 E" `% X! ~' |& _
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
0 ~$ W) \" S3 c/5 @% N  ^$ O( o) U' d( i
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)
. k# F1 U# H' {3 R, H- Z1 q  ^# F/                   Added file lock feature. (_FS_SHARE)/ D6 q3 p( ~& g. t+ l% m* x
/                   Added fast seek feature. (_USE_FASTSEEK)2 q: d2 Z# H2 C' t
/                   Changed some types on the API, XCHAR->TCHAR.
& ^: n  f% i' D( g/                   Changed fname member in the FILINFO structure on Unicode cfg.9 @) x# v& u5 \$ s3 s. C, R+ ~
/                   String functions support UTF-8 encoding files on Unicode cfg.
7 n+ }! J$ V4 D/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
4 L( J" @# J- O4 S3 i/                   Added sector erase feature. (_USE_ERASE); g+ o1 I6 n" P4 |6 u
/                   Moved file lock semaphore table from fs object to the bss.& T6 w* H0 F( v( R) h3 Z! N8 o
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.* Z; ~9 J" f1 l- v( \
/                   Fixed f_mkfs() creates wrong FAT32 volume.( G$ {1 C5 B  `
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
" p) W( a9 A- a/                   f_lseek() reports required table size on creating CLMP./ k' X" O4 Z* j# K
/                   Extended format syntax of f_printf function.
$ @6 \! m! b* r2 i$ t/                   Ignores duplicated directory separators in given path names.) U! i! ~9 M, V. ^4 i7 C
/
$ _, r/ n+ @2 D# U/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
1 g. D8 Q' Y6 _* i$ Z% F$ a6 J% `: X3 X/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
. y9 [& z' a& N) w$ R/---------------------------------------------------------------------------*/
* K5 P# U1 J8 m. o9 Z4 U
+ G% u& e- q- B* }; _- M1 Y# H- X

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-19 09:31 , Processed in 0.094426 second(s), 35 queries , Gzip On.

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

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

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