找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1384|回复: 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工程。下载即可使用。& F' T/ ]" a' ~2 {) [
/*----------------------------------------------------------------------------/
; d6 A& F1 d) `% V. v) J) Y4 }/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011) U0 B5 S0 t6 s3 N& {
/-----------------------------------------------------------------------------/
! R& \8 V* a0 z" U- B0 L8 @/ FatFs module is a generic FAT file system module for small embedded systems.7 j% u' n4 s+ ]: v, s: l/ R8 w
/ This is a free software that opened for education, research and commercial3 W' c' B4 H9 s' z, e
/ developments under license policy of following terms.
. b% Y* M; I' p0 E/ w  S/
8 f$ ~% R9 y* f5 B3 r/ B/  Copyright (C) 2011, ChaN, all right reserved.) }! K* ]" o5 L! Y9 a2 B# W/ c
/
& ~8 w4 H- x, R3 E/ * The FatFs module is a free software and there is NO WARRANTY.
* h* w, J' t5 z) x+ ?7 [9 C) j/ * No restriction on use. You can use, modify and redistribute it for8 \2 o( ]1 w) P8 o- z5 J/ ]
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.
" I5 E, M, B: ?0 s1 t2 `/ * Redistributions of source code must retain the above copyright notice.
& K9 u- Y, i: b0 i/# W2 g) u( F+ |3 i5 l# k8 Z4 T
/-----------------------------------------------------------------------------/7 F. R' F. }' L4 U3 \9 [- d' L8 P4 |
/ @& J* ^. Z% V% b
, n3 Y' r- V, m) Q6 x* F
/*--------------File Info-------------------------------------------------------* [. P5 Q% u1 ]$ w( b
** 文   件   名:  FATFS_Function.c' S7 H% M9 e, s) w0 U
** 作        者:~风中的叶~    整理$ a3 k: n, f# S  Y$ w- w1 a! }
** 最后修改日期:  2012.01.18/ @* s* E* V" C$ G& b; l0 Y
** 版        本:  V1.0
% C- K% |: q, s" V/ p& L. a** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出+ O. _: N# i: |- V; }
**------------------------------------------------------------------------------
4 |  }3 M% a- k, o** Created   by:  Dt.
0 {$ Q" {# Q2 c) u1 r** Created date:  
. {8 h* ?+ q* p0 f( R*******************************************************************************/
. G' Q1 B9 `7 g( A9 N" G7 C( |7 p#include "TEST_FATFS.h"4 F9 m$ D5 [( e
#include "string.h"1 U8 @8 ?0 {& ~8 E& X& Z
$ j, W  z  d6 Q- A; W
#ifdef TEST_FATFS_EN
  r% v( I( }8 n, U0 g6 @9 O4 _. K
0 z  O2 C0 i1 i( f; |1 i4 T

. }# Y3 M, @) g3 [. n; ^//检测磁盘是否插好+ [# Z% t! M4 X. ~/ u& C5 h% X
BOOL disk_detect_OK(void)
2 x3 V- I: a5 _  p* M, L) ~" w7 M{8 S# L) r3 e* r# o+ |+ T
    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
# E( s& `0 h& d$ I- x. N0 t        {
  r4 O4 Z& C) [: z* N            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
% J: O3 n) h) m5 k. q4 f* K3 M                return FALSE;8 Z, e. z# B7 u; H9 L5 C: @
        }  [% l' `; x! S2 _4 `) I. @7 M8 z
        return TRUE;: e+ |- z" W3 \; C
}
3 B4 o7 H/ w! {( u4 p* l& t4 E9 u+ D; H

. m5 g; [# G; K% G3 [# h! ^8 v
- N' v: L8 C( |//测试函数执行结果分析- v" F6 |/ q3 e2 r( _, W
void die(FRESULT res)& j0 A- b% w! x6 V8 e
{
) V5 |3 x% T. @3 P    switch(res), [8 M5 S4 M! G- m- H7 h8 d
        {+ n7 \4 Y0 g  x( K
            case FR_OK:        //The function succeeded.
; G+ N4 g% D# a4 z                {
: t! k/ z; m+ {0 B( u                    printf("\r\nThe function succeeded!\r\n");
- g8 |  o) O" G0 ~7 @$ u# |                        break;
$ `" b& p7 A' J: O" B                }
5 T3 U$ u) A$ e" W5 R  T                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
$ {" P: A+ O) z, j# k1 F  b+ B( w/ ?                {, i" Z8 `/ ~. E% S8 T
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");' `8 P3 Q+ t# e8 u/ V% _
                        break;3 ?" o- h% r; e' o3 t
                }2 Q; g$ e$ }& A2 P1 A! q
                case FR_NO_FILE://Could not find the file.# z3 R# r: ?' o! d% `8 V% B! N; y
                {4 t6 u6 R/ J0 k6 q$ m5 `# w
                    printf("\r\nCould not find the file!\r\n");3 T6 w1 r3 q/ Q+ h
                        break;; F: f+ m- K; i1 A- z4 g* g
                }! d( I6 o/ `' p( j. E3 m8 o; @
                case FR_NO_PATH://Could not find the path$ K; x+ m8 z; r+ u7 i
                {
9 Q6 Q. e/ k) \3 U4 y' j# _( r& v" F                    printf("\r\nCould not find the path!\r\n");
+ p- @$ H9 k2 C- g                        break;+ O. X& [4 W5 T2 Y! J/ r
                }5 H& Q" _3 @6 T5 n% t8 o" y6 y
                case FR_INVALID_NAME://The path name is invalid
9 v) d) J9 u- c2 z                {9 o( \% |! }' Y
                    printf("\r\nThe path name is invalid!\r\n");! ?: b% T; O. V2 X& E* k9 m* I. k0 K
                        break;
6 B0 E. a5 n' N0 O0 t$ ?% k                }; Q! ?. O4 N8 _9 I0 ]- s
                case FR_INVALID_DRIVE://The drive number is invalid
/ }8 O$ e& K) C5 n. y. V                {4 j8 q1 Q& @  Q% D
                    printf("\r\nThe drive number is invalid!\r\n");
* \* v, X, A* o                        break;
' [. o; g6 L5 o& v                }8 u* r: F0 {& J( s- |
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. " D: n- Z9 t% o6 G9 M" ^+ W
                {
7 y5 [  A4 p, i( X# c                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
3 T/ C+ q/ T# {3 N1 A                        break;
) t( V, E* G0 R% ?$ J                }
) j0 W4 r4 l: {! P" x                case FR_EXIST://A file or directory that has same name is already existing: V# T- |9 j4 x+ m) [6 [2 K4 k) c
                {; z" j& E& Y, q' E6 Q5 v* N' _
                    printf("\r\nA file or directory that has same name is already existing!\r\n");
  @; D# m% C' Q3 c/ F" s                        break;
$ x% g/ G# _2 x) x, c! K                }
3 w3 ]# P  ~9 \$ K//                case FR_RW_ERROR://The function failed due to a disk error or an internal error
7 S' f% E/ A& Q6 U5 B0 l8 `4 ]/*8 ^; ^; j6 ]/ r0 K; ]3 _, w: u6 w
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
* z6 Y: B# H. S# N                {
1 Z& S6 h, Z$ d: ?2 V                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
! _; T4 M. Q0 q9 Z) q                        break;0 t. P! Y, ^8 G
                }
  \: Q% g. q6 g% ~5 j% F$ ?*/
% b- ?: N8 E' ?  ?% n5 J1 |                case FR_WRITE_PROTECTED://The medium is write protected) R7 p# g# D3 x- w; [9 ~  H; [
                {
  [+ R2 P7 D2 S8 ^  x                    printf("\r\nThe medium is write protected!\r\n");) A3 S7 ^: A1 ~, [' ^' _4 @
                        break;0 D  R% u0 o# E& ^
                }
7 L% I& [" m( J8 f, X                case FR_NOT_ENABLED://The logical drive has no work area) `# t8 @5 Z: x+ ?+ v, J; ~; _
                {
" x3 D) p' d: W/ Z9 ]" G                    printf("\r\nThe logical drive has no work area!\r\n");
; u5 j6 @- `, E                        break;5 h7 Y+ P9 m% E* R4 [, Q4 K# z
                }
; @$ C0 h7 _2 E6 m' g' _& q                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk2 }0 s$ T4 X1 u8 v1 H0 }) }" s& @4 E
                {7 f) B$ M3 }* u$ O. B2 I
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");7 W$ P/ W4 y0 K. P3 Q
                        break;
! x- t6 }" |) B6 B2 b                }
, \) q( y, k' R+ x; `- ?" w& a$ M                case FR_INVALID_OBJECT://The file object is invalid
/ |; h. l! @' m) O$ L                {
. ?& T: y# T% i                    printf("\r\nThe file object is invalid!\r\n");
. D' p& W+ H2 r3 J                        break;
+ }# b" K  |: j. j2 ]9 Y% d                }
( H( P- t' ]4 E+ T' c5 [8 Q5 V0 n
1 M, N) J) X( L  O4 _$ p            //The function aborted before start in format due to a reason as follows.
+ _' J' C1 m2 K" m5 `( \        //The disk size is too small.
+ Q5 z" \+ u  [: c% y- a        //Invalid parameter was given to any parameter.
# ?- C# u4 i8 p  Y) h0 `        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
( G$ T4 T. \, s: A* t; D                case FR_MKFS_ABORTED://
1 D- [9 P" D  Y. U8 t. R+ W                {
8 @' ^3 p* k' R; x- n                    printf("\r\nThe function aborted before start in format!\r\n");  y- r- g$ Z4 M4 M( C" s
                        break;
; t! z! n2 {7 `" F. W. X7 O                }. {. g7 d! w& K  R6 g
                : c) ?1 j9 @/ W5 S
                default:
3 t4 l) r$ i; X0 {5 |                {6 {0 _/ D8 L/ ]
                    printf("\r\nerror!\r\n");
* t2 U' y2 _8 P' z$ [                        break;2 c% F% N8 l8 r- k; ~
                }        % Z; z7 J' K" J! t  `9 T; R
        }7 j  C' C3 K1 ^1 T% u
        return;
2 q; Z6 `; X0 a, u. T, `}) L2 ]: i$ h- `6 d: O- S+ w1 ]' T
void Test_f_getfree(void)//获取卡的总容量及剩余容量
. \6 V) o& g9 y+ W9 x- B" Y& @6 Q. g{
+ e) N- G% k3 k    FATFS fs;, A7 F0 x2 A. k. v3 H
        FATFS *pfs;' n, I* a& y  g
    DWORD clust;
6 C) t; ~; M$ ~. X- H        FRESULT res;         // FatFs function common result code
6 `) m: ^  k2 M( t8 E" y8 i5 d9 x+ Y
; N" _" k' _& X" D# r7 T' o8 Y        //检测磁盘是否插好" {- @7 w/ w' J- H/ i
        if( disk_detect_OK()==FALSE ) return;
! ]9 T4 S! v+ T- G8 o& U6 S2 B7 d% y8 u" g3 v, z+ N* r
        pfs=&fs;//指向8 B( M8 t% V3 O, b$ m, H# a
        // Register a work area for logical drive 0
; I9 q; d4 e+ H3 }    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间" ], k! v+ ]0 s1 J9 K
$ Z7 O, I3 W. a' N+ L8 i
    // Get free clusters
( l- F5 T' F3 J4 d5 ?0 M    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"; F  }" h7 a: F
    if ( res==FR_OK ) * O* H/ s$ ^, Z/ g1 S, N
    {
% _# Y8 C, J1 p- S" L9 ]2 c            // Get free space& @. ]" R% @  K$ y; o% |% L
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
8 n$ b* d' e0 G. W                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
8 A5 _% x" k8 S9 p                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024( Z7 ]# ]: F3 g# e
        }4 }- Z8 m) g7 N8 V5 ^
        else die(res);//测试函数执行结果分析
/ H- l# J  l$ N! V% {( z3 V5 J+ M        
1 k$ i$ u8 _6 S' E; V' g; v        // Unregister a work area before discard it, J& P3 u0 L2 d: g& _
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
; j% {1 \! q0 B}
* L! f: O6 y4 I$ \, v  E0 T
$ Z- T* f+ e7 S' [1 J6 c8 `void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
5 |9 [8 d$ k2 w5 h8 ]$ e{- Q- r6 u, P4 I' I$ a" A
    FATFS fs;            // Work area (file system object) for logical drive, u; `, S( u3 Q& s, {# D7 D
    FIL fsrc;            // file objects
+ g, o9 i: q0 G7 b/ u  E    BYTE buffer[512];     // file copy buffer9 @. x, m& @& e/ {+ d
    FRESULT res;         // FatFs function common result code$ t4 B  n* O6 Z) s' q- p# ?
    UINT br;             // File R count
  i8 z" k# c+ S0 g% r6 W* h        u16 i;
) o. O8 A- y4 q1 i$ f, g5 |! s        
; ^! s, V$ G1 B7 y$ M5 z
. q- {' J7 i$ C3 q( l        char path[20];0 ?9 v# f7 k- p+ b2 S

/ f2 [! m1 u( W3 V/ g        //检测磁盘是否插好8 j! b% r  ^( f
        if( disk_detect_OK()==FALSE ) return;
- G; Q* W' X/ p4 `; f; s: F0 r7 A- _$ M8 u
    // Register a work area for logical drive 0  c5 Y: n; G  {( C" Q
    f_mount(0, &fs);
3 I1 Z% ]0 {( k1 D3 o5 T7 f9 }( P" a2 [1 @7 f' O* C5 \: p4 l
        printf("\r\nread file:>");
" V0 z+ P- U% K        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
$ s5 u* r# h6 O- }7 i4 e/ M( p2 U- H! z$ X- k/ J! @3 e
        //Open source file& m1 X! U+ ~4 `8 [9 N
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误8 K# z- C) c+ Y- ~: M9 u8 m
        die(res);
/ d, j) S- m8 s& G* `/ e% C        
: M) d8 O. J5 l$ M6 G/ {; }8 l        //buffer空间设大一点,会提高读的速度。$ ~! ?3 h( p5 d6 f* j+ p
        //如果文件实际大小512byte,- V. u+ `" V) K* s! M, P* s, V
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
0 \7 T2 h' a, V/ |* F4 Y8 M        //下面两行主要是去除1s误差。+ d' i' _" K. E6 `+ V

' B  ?, \5 S/ d- E4 s6 i        for (;;)
, R7 M5 X# J/ ?; ~7 W. K- ]        {/ ^! ^. E/ a& b1 {. D; H3 V
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存
  x! s6 |$ p/ \1 W2 [+ M; P2 D
5 ^3 F$ `4 R! \% K0 A                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
& c( J7 q4 y* G( V# F5 z' t- [        if (res ||(br == 0)) break;   // error or eof        # h' [9 @" O" N0 h" n
               
! ^5 e* A. M! S% {* k                printf("%s",buffer);        ; [  \2 g% c3 t. @3 \! e, d. y( |  |
    }
! g0 W' v' j# y3 G( z0 t; p* E0 _5 a5 m, o4 b" s; T
                           
% b; r& `; d. k  \* ~" z    // Close all files
9 v( i: h5 P  _' a$ v. O5 L    f_close(&fsrc);
! Q% ], D  I; l9 H  O# m9 _    // Unregister a work area before discard it' |3 x# A9 @- [2 _
    f_mount(0, NULL);
. P3 V5 v! J1 [}1 p  P$ V- ?4 E9 o
& ~9 v8 r% @* ]7 _9 B* u+ W
void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件7 Z2 ]4 q) B+ `' n& G5 c
{- X* _0 [3 x. i/ U( |8 G
    FATFS fs;            // Work area (file system object) for logical drive! C; t) q4 U3 U- ~0 w5 g
    FRESULT res;         // FatFs function common result code% z2 ?0 |* t5 b9 Z- O: l
        FIL Make_file;, Y0 [' ^& x& B( M
    char file_name[20];
0 e+ M! \6 T0 L6 [    char Storage_buffer[] ="0";
' X1 y+ a: ^. w2 |        
& Y! Q& L9 P& A/ v        UINT bw;3 m# F, x0 W8 ~0 s2 G) s  c1 @
        //检测磁盘是否插好2 L: _7 s/ `2 y" u8 r! ]: r
        if( disk_detect_OK()==FALSE ) return;
2 d( P6 {2 a4 O9 y' M$ @         printf("\r\n inaert_ok:>");
  y3 B0 R/ j- r    // Register a work area for logical drive 0
# ]$ |* L. P  r  Z3 U- C    f_mount(0, &fs);! G0 B- }) ^3 N: x

) _8 Y8 R1 S" o2 \        printf("\r\n Make file Name:>");
: i& ~8 Q% G( t0 [: K4 y        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt& F/ ?' P, r, M: p) Q! b" G" ^5 G

5 M2 |4 [: ~" n" [7 Z    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 " L. N! m% y. B, u4 s9 c; l# ]
         printf("\r\n open_ok:>");8 u0 n, y2 i* x5 E5 N! d
         die(res);
8 m; n5 [( [% r8 u    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
  S% _2 b+ A8 J. g      printf("\r\n seek_ok:>");
0 e6 n/ r  Q  ~9 @0 R( j: L         die(res);9 u0 S- o7 T2 o2 A' e
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  1 u2 d4 F2 G0 L* @
     printf("\r\n write_ok:>");
6 e' y% }8 e1 W. V- l         die(res);
+ o- e; R& G* C1 W/ p; T. |2 S        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
, ^( b1 C; R6 O  @        f_close(&Make_file);//关闭文件
! h% S  K. J' ?- l        printf("\r\n close_ok:>");
+ G8 [/ Z' x( W2 V2 M  Z/ p$ w' e% Q% I2 b
        printf("\r\n写文件测试OK!\r\n");: q* _9 c$ ?  j$ w& k0 }  w0 |

  ^4 S0 J4 Z  n$ n8 m, |# w: i        // Unregister a work area before discard it
) A$ X; G$ o; V1 h2 N( f7 ]! d    f_mount(0, NULL);( u) ]# E' O( D& d
}
. ~% Z& l1 H. `+ h4 \; i+ f4 O# S. d4 q6 n) {
//The f_read function reads data from a file.- c5 g; V8 l4 e
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
' x0 n7 n  V' h0 l+ N( T//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了
' Y( p3 ~/ s8 g' T, B5 N//所以以后要特别注意这个问题。) ]% Q9 b' Q; D/ x% I: I% u/ ]
* o( `# g9 A4 i6 p; Z$ y
u8 StrToData(u8 * data, u8 len)3 t. ^; N* S- o
{
( g0 M- e4 e, U: a; ~9 e        u8 ltemp;
- F! m  o2 f: [' R: o0 B        if(len == 1)/ E) @& o* @% {7 k. ^
        {
3 X4 u1 \! h. x* n                ltemp = data[0]-0x30;( A% n8 D5 `6 v" E2 d  t* ]

+ I. z. x4 L2 A, L3 k        }
% A1 {3 \: @+ R3 M9 y* E' C! ]8 R        else if(len == 2)2 `+ C8 t" v  p1 Q! G- k8 U
        {
3 s: J* y! n& ]( R" ^6 ?1 k9 A3 |                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);! d2 k$ t# x3 X- Z8 p" G
% h! b( N' H6 H1 @6 f' \
         }/ z3 j7 E. j% m" m, L, o9 H
        //else if(len == 3)
( ]/ f0 B3 W6 x! N6 ]                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];+ a& }4 x$ j. v' y( J( _$ }

; z* e) |& H0 E" o! v        return ltemp;' b7 `5 ^) M1 a( S# g6 h
        
7 B3 _- ~* @8 {}4 e: b! V* ^; k: N6 V# J
* {* j2 }8 K- o

: q% N1 Q4 ^" ^3 ~4 m#endif- E+ T# ~* @0 F3 b8 e" f: R& B; e

7 c" q3 l6 K5 M& |# ~. j; |/ H  T- V2 |5 W2 ]% ]! o
/*
3 c( T4 y/ @  C; B/ yint main(void)$ X: L% G! {5 s5 H# G- h! S. }
{
7 w: w4 |  U" E) a///////////////////////////////////////////////////////////
/ S6 ?( T+ J# T7 P" f$ l2 G9 JUART1GPIO_config();//串口IO口配置
: C" P6 X5 D7 u3 B5 r5 U0 H# EUSART1_config();//串口初始化波特率为19200
* T0 L% l, w. k//UART1NVIC_config();//配置中断
0 m7 _# L4 a( u# v% k' y///////////////////////////////////////////////////////////
4 c$ M) C! a, J9 YSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式0 j( r' m' {. J5 t
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
% g; Y3 ~7 _9 o* HTest_f_getfree();//获取SD卡的容量和剩余容量. _  U4 I) Z9 Z4 I$ r
Test_f_read();//SD卡读文件测试% l" ^2 b- `" F3 y1 `* m
Test_f_write();//SD卡写文件测试2 G4 d& Q$ Y4 e* r' ~
/////////////////////////////////////////////////////////// ' V" Z/ [. N# v  z* c4 ~( _+ o
    while (1)  V1 O5 R, J. D- c3 [, f
    {
" ~, c) y) U! d- ]9 d( k. Y# g        //printf("好的");- W( e3 a5 w: {; M7 p$ \  K
    }! O, G% k9 C; e, d
}*// G; \. ~' s3 n
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
# `* V1 H, h7 I. UFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
) ?/ O! a- ^" u0 O% f. Z- x{
8 G' c  G4 b  |" n    FATFS fs;            // Work area (file system object) for logical drive
% \. }! I4 Y3 X# n& `0 c    FRESULT res;         // FatFs function common result code; n; Y" G: z/ ?9 ?+ Z9 {2 L
% O" G4 Y% e6 s' B2 G3 U
        //检测磁盘是否插好& B8 t6 s2 d8 d
        //if(disk_detect_OK()==FALSE ) return ;
, ^: N5 w5 Q5 Y# V) R* w& H: E        //printf("\r\n inaert_ok:>");
" \7 q# t" N8 _+ n  D; y/ f3 B        // Register a work area for logical drive 08 f3 v8 S) Z9 W6 B
        f_mount(drv, &fs);
5 n0 g& p+ j) Q: N: u* {, z        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
% C6 ~! J5 L% `$ k2 k        //die(res);$ s$ L3 _5 Z0 a( v. B; B# Q4 H& I
        f_mount(0, NULL);
# R" Z& _  L3 [4 B! I! x        return res;1 O/ J+ e5 S% ^' ^( n
}
5 J1 Z8 d8 v: ~////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////: L' y) b% U6 x( c, K
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        + t" N! u# k9 ~. j
{
% J% y1 e: Z- P    FATFS fs;            // Work area (file system object) for logical drive3 q$ h1 }  |" J( v! K9 w
    FRESULT res;         // FatFs function common result code0 l" N, U! s2 ~6 @1 D+ I) x
, m' S& k! H% i" Q9 Z
        //检测磁盘是否插好
; }$ @. y9 f& ?& N$ B) @2 a9 [        //if(disk_detect_OK()==FALSE ) return ;2 f" X3 K" k' h+ ~, G3 b
        //printf("\r\n inaert_ok:>");
( z4 k5 j- O; b$ D! f9 b        // Register a work area for logical drive 0
8 G1 y, Z  L$ j, O5 d0 I6 A* D        f_mount(0, &fs);: `% Y; W- P/ d+ J5 s4 ~. N& m
        res=f_mkdir(path);//创建一个新目录
7 x; ^- w+ M5 @8 A  o        //die(res);. P5 @' P4 l& V% L" l' A
        f_mount(0, NULL);+ H& e  o1 O1 o# w
        return res;# |: M7 ?$ e! R
}! R5 Z7 {8 U- M; K3 ^
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////- h6 B$ R/ \/ h. ]2 q- f
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        " v, F+ G  v. q2 ?, E+ z
{+ a/ G: {) q5 `; F
    FATFS fs;            // Work area (file system object) for logical drive0 B" [" }) L9 j0 S+ l7 c
        //DIR        dir;* c5 n# U4 |1 V, P# g9 ]
    FRESULT res;         // FatFs function common result code
/ C" \# T- O3 C& H* a% ^; T3 |# f
        //检测磁盘是否插好
$ L$ s! W5 ^" {. v! K/ k$ G- _        //if(disk_detect_OK()==FALSE ) return ;) d6 L0 j! J# `
        //printf("\r\n inaert_ok:>");. I! R: q2 r. N3 Y
        // Register a work area for logical drive 0
+ E, s0 ?0 O, }+ _; c        f_mount(0, &fs);
8 l: ?- s4 E0 ]& Q        //f_opendir (&dir,path);
& i7 G4 ^1 }. Z        res=f_unlink(path);//删除一个目录
6 {! X$ f5 k" n4 y4 j  E! H        //die(res);0 j& c8 y5 c: y
        f_mount(0, NULL);
: J6 L0 m3 l( a0 {3 z% q        return res;
8 C0 R7 ?9 Z4 w0 L}3 H- j3 ]& u2 \
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4 x4 ], O! _, F* k
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
3 F% o; S7 A( X: E5 {3 Q& [, G& L{# v/ d" u) `8 l9 o; q/ c
    FATFS fs;            // Work area (file system object) for logical drive" w8 p; v: i6 }% Y) }
        DIR        dir;: j# l' ~- `3 _2 L
        FILINFO finf;
& q% C' |; ~3 e    FRESULT res;         // FatFs function common result code$ o# C$ L; K, K- C, h7 b

# b8 L* a! ^. A& T, S! v        //检测磁盘是否插好% r8 X; }, h& Z4 b' D2 [3 Y/ A
        //if(disk_detect_OK()==FALSE ) return ;
: A6 r* j$ _- k5 r- ^# w- O3 |        //printf("\r\n inaert_ok:>");
1 d; E- K3 @) K5 D. ]" Q$ [        // Register a work area for logical drive 0
) H- }8 I: [: f- K5 w        f_mount(0, &fs);
! w/ _7 K/ a! B1 I# j- c9 T        f_opendir (&dir,path);
% m% A! m: D" K$ Y
) e: {5 R( `% D% {: N* X        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
; l/ c; v9 @# M        {strcpy(*(filename++),finf.fname);8 P# L5 Z* B0 h0 E+ h; W9 |7 k
        //printf("%s",finf.fname);
2 C& S* G3 \$ n% |        }$ X- {9 d& b9 S7 m
        //die(res);
. P  k8 Q- f2 A$ j/ G        f_mount(0, NULL);3 Q# y4 |* j# G7 M  a" i
        return res;
) S2 T- r) g! c9 @9 s' O}
7 @- m, w$ X  i3 s2 _6 U& U////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- d, c+ c7 n3 zFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名" t* f9 S" q( M
{7 J7 ]& h/ m: h1 a2 S- v* I
    FATFS fs;            // Work area (file system object) for logical drive
7 U3 r7 a* T' W# }, j        FIL file;! W* T0 ]* x; N2 l& b/ U* r
    FRESULT res;         // FatFs function common result code2 a* }$ k2 O) i5 w- g" y* d' N  ?

: m! a- A6 m4 }: I/ e& ]0 k3 G8 R' X: J        //检测磁盘是否插好7 S) n& G& v' T! x( _2 T, H# U) |$ m& H
        //if(disk_detect_OK()==FALSE ) return ;
+ S8 {* V- y  c' Y        //printf("\r\n inaert_ok:>");
2 C* Q* Z' R0 }0 ~( b        // Register a work area for logical drive 0
+ Y& E7 l: ]( k        f_mount(0, &fs);
- F2 i; u) |" }% ]3 _2 a2 I  }0 g& [        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
  u- N8 K) {$ r                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
% J$ j: {( M* Q* L                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
& \, k1 E" k; ~        //die(res);
( P# t$ f% h- c        f_close(&file);//关闭文件
/ A  S# p& |: ?: T# a        f_mount(0, NULL);
- q0 r8 O0 U, P8 o0 R4 u        return res;3 L: m0 J* j; Z( `0 k
}
% c9 @( k+ @, _% W  y/ b( H////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////' p+ Z$ H* p  u2 S( q( R4 L
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        7 c& H* m2 h8 A% B, d
{
5 i/ L- Q* Y+ m. k7 t- _    FATFS fs;            // Work area (file system object) for logical drive
- b6 F: u4 q, {' {) P" M        //DIR        dir;% R8 z; g  x3 T, \! t; L  [) t7 a- V
    FRESULT res;         // FatFs function common result code+ y- W- F% V+ c
. Y2 E- r2 y' Q9 M, j
        //检测磁盘是否插好
8 T. C. m+ F6 M1 A* P1 `        //if(disk_detect_OK()==FALSE ) return ;
/ h8 v" g) F" t" A9 I/ w        //printf("\r\n inaert_ok:>");7 |/ o8 O0 H. `" [/ r
        // Register a work area for logical drive 0
; R) f- B9 x7 {, X) F        f_mount(0, &fs);
* f7 g0 r9 B, Y. A7 m, t* j        //f_opendir (&dir,path);5 M8 P3 y3 o7 Z+ X$ k
        res=f_unlink(path);//删除一个文件5 G/ y) V9 s4 ?: u2 d& a
        //die(res);2 r0 c, x- k6 w$ P7 V
        f_mount(0, NULL);7 o- m2 }4 R$ A3 c
        return res;
7 C! Q8 ~3 S. U8 h}
6 s) f) v& W7 }0 T& b; W7 @0 q////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 H) E* p  Z- j* gFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数8 h0 i4 ~  Q  s+ z. J/ i
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));7 A  S. I7 R* l8 g
    FATFS fs;            // Work area (file system object) for logical drive
1 i! {  [, `- e    FIL file;            // file objects
! w' a0 o4 X- U1 A6 o    FRESULT res;         // FatFs function common result code8 i+ f* P7 Q, J, O( f3 ]
    UINT br;             // File R count 文件读回的字节计数
) G7 R- R5 o: Z$ k- K: b0 G# U        //u16 i;
; A: w( i. y& c% m+ d  T: a        //检测磁盘是否插好
; S. H4 ~5 Z& ?% L8 `% _5 O8 @$ p8 S        //if( disk_detect_OK()==FALSE ) return;0 X% K2 b/ i* ]$ X5 c* }' i& Y
    // Register a work area for logical drive 05 W  X1 c" x; G; G
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';- O/ g+ n6 I2 d7 Y6 o0 E
    f_mount(0, &fs);3 Y3 V0 {: m0 X
        //Open source file
( X4 m" m  ]- V( G% x    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误1 H; r& N3 o4 Y
        //die(res);6 s8 D% i; [) N( R+ ]- X3 h
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
& E6 `% J) q, G% c        //buffer空间设大一点,会提高读的速度。
5 m( k$ {8 V- ?& O! Y6 {2 r  D+ ?( u) m        //如果文件实际大小512byte,
  c6 q: n8 [9 w8 o  E& \        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。2 ]3 A/ R5 G3 g" g3 D3 I# `
        //for (;;) % ~# F1 L- q& W- j$ o
        {. R: N2 P* ?0 n: {" k) }# D* L4 `
                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存- A5 q* l! L, U: g$ W& L
6 R! C; G" U: Q/ T6 E6 }0 U2 L2 w+ m
                res = f_read(&file, buff, strl, &br);. j4 T' S6 r# {3 O4 B3 H7 i
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出! O5 J$ G0 I; s
                * ^9 a& `) N4 T! t! J: R! L4 F
                //printf("%s",buff);        
* ^/ u( e9 ~6 o% J    }                    7 A! N9 k* C# L! i& L5 J% I% R
    // Close all files
* x5 B1 |+ s' c& C3 \    f_close(&file);
4 w, Y; c/ l" H9 o5 S    // Unregister a work area before discard it' G% F7 q/ C9 o$ ?; |6 R6 E1 y
    f_mount(0, NULL);, Z' u9 b( g& b. W
        return res;
# J$ [. ?9 d% x, i2 A, F6 y. S}
- z: i! w+ T" ]8 Q: S$ E/ H////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////. }" c, h) A0 B2 _* |6 K- C
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数7 ]8 u6 @4 U" E: l
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));" A) r; ]8 ~4 h0 s1 D
    FATFS fs;            // Work area (file system object) for logical drive# h$ _: T9 y9 T. i( _
    FRESULT res;         // FatFs function common result code
* o7 B) X2 T9 v. p+ r7 z* G' l        FIL file;
  ~9 _! m4 R& u        UINT bw;             //文件写入的字节计数
( y2 w$ |5 ?) @1 g/ N. }0 C0 {        //检测磁盘是否插好7 \4 u6 H1 l& ^; l  [; u3 W
        //if( disk_detect_OK()==FALSE ) return;' l, S8 z0 p( _4 B1 [5 m' `
    // Register a work area for logical drive 0
/ l0 ], ^& ~6 k$ a0 J    f_mount(0, &fs);
7 z7 P+ u5 w0 \! P    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 6 u' {& z( l- }! N3 k. E9 P7 F
         //die(res);  E5 _* _* U/ _% \  e$ d
    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
6 p8 D7 }, E) y- n* c* w2 d( ^         //die(res);
$ _% V1 w, x0 {% x        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符: c5 e% R( G) r; K, |) R
         //die(res);
! F& ]1 i& H8 E1 U% F        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
6 t+ ~6 v, r2 E% o        f_close(&file);//关闭文件6 z) W# c3 O( d- U& S0 a
        // Unregister a work area before discard it
9 I4 Z6 Q( h1 d' E) l/ k* b, B' x    f_mount(0, NULL);
& k% F( j& ^0 k/ T+ ]( \0 j  o        return res;5 P% G( k; E$ Q% i! H
}
4 X1 g9 n8 M! B- _) |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
) Z3 c* y+ C) y6 kFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M9 ]$ ^: I* M# v  P' T  f2 ^* ?; i" B
{
8 M4 u  J: k+ c    FATFS fs;
$ Z& F0 l/ ~0 K/ O# L' e0 q2 o! N        FATFS *pfs;
1 Q" R  [/ E& t3 z        FRESULT res;         // FatFs function common result code9 C/ {0 ]9 {& d: l
        //检测磁盘是否插好- a7 K# R) `% S3 ]2 Q7 F
        //if( disk_detect_OK()==FALSE ) return;# {  {! \5 n" \0 T, d  Z
        // Register a work area for logical drive 0( ^+ q% Z9 c6 S: E
        pfs=&fs;//指向
5 ~) r* `9 o" G: C    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
+ C9 ]9 O% q; Q    // Get free clusters5 @% w/ v1 O9 F4 N) T' a
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
( v3 ?1 B& y$ v. q9 n" {8 c        //die(res);& s" G) S1 g/ a& ?" l# c9 B+ b
        if ( res==FR_OK )
- i# z5 }  c' v: J/ p( j2 X    {
# m4 `& E  a* K& E( J            // Get free space4 H+ l# a0 r0 B) Z/ X4 \. P9 F! P+ Y
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
- D! H+ ?- t) M* [               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024* R! ~) U$ a7 q+ j9 Y7 z, u
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10242 z% \" Z! A9 W' d! V  v6 C6 F
         *freem=((*freem)*pfs->csize)/2/1024;
  U6 ?! A+ f/ d1 Y3 f% C        }* n4 \* y! e1 {  ?  y
        //else die(res);//测试函数执行结果分析  F3 d( ]9 E* d+ s, Z9 G- K8 w5 a  W
        // Unregister a work area before discard it
# T4 i0 [0 n8 w0 _    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间. M- v/ N4 j/ f. r4 O! h+ S
        return res;8 C) N5 K$ L) Z/ q- K) K4 E
}1 a8 c& M- c! M8 e5 ~
) B+ O) Q% W) F3 z

' w2 {6 C8 n5 Q; _& l6 n' J) N. N9 V
0 `" T" N( h6 X  k$ b! x7 l* K$ _" u/ Feb 26,'06 R0.00  Prototype.8 m+ \. J3 _' P/ s( h) J
/8 {1 ~& v5 z# @  w  G  [' C$ ?
/ Apr 29,'06 R0.01  First stable version.) f+ B; P8 t% e* {
/
) ^6 G  @$ E! S4 b; A5 m9 ^/ Jun 01,'06 R0.02  Added FAT12 support.
7 e8 e, Z4 W5 h: O( J- |2 X, J/                   Removed unbuffered mode.( Y2 H9 {" |% R2 {
/                   Fixed a problem on small (<32M) partition.0 e/ Z' X# v" d) |  J- q, \+ O5 `
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).* ^% K- l; c% \7 ^1 `" a0 i
/' ?) p0 Q/ s3 ^# o
/ Sep 22,'06 R0.03  Added f_rename().- P) `; |0 v; x4 G0 K
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.$ P+ J) K: y( `2 {- }7 z
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
/ x! @0 v2 R' O* n8 p/                   Fixed f_mkdir() creates incorrect directory on FAT32.
& C7 ?* x3 @8 I0 N$ }5 F+ o. S6 u/! N7 K; t$ g2 f: t1 S5 l3 k4 U* A/ W
/ Feb 04,'07 R0.04  Supported multiple drive system.
# `- Y' B3 N! J, y/                   Changed some interfaces for multiple drive system.
7 o7 [; U7 t2 X; L7 u" g$ ~  G% w% z/                   Changed f_mountdrv() to f_mount().
3 Y6 W1 J8 X; U1 N3 [/                   Added f_mkfs().' H% A+ E  U1 Q2 P7 k8 w( n) l
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.0 K: d4 z! `. X  v7 r
/                   Added a capability of extending file size to f_lseek().
4 g) n& A, o* O/                   Added minimization level 3.
% x  W) U$ t- A0 M& n4 w/                   Fixed an endian sensitive code in f_mkfs().$ v" K. N, b. I# `- ~% \
/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.4 l0 O$ h& F: d8 `1 N
/                   Added FSInfo support.
$ T( ], {) {6 }/                   Fixed DBCS name can result FR_INVALID_NAME.
9 k  O7 i. L' Y/                   Fixed short seek (<= csize) collapses the file object.
4 }! u( f8 ]  M; m! Q// p2 Q  b. y$ }2 b" d# t
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().1 d5 `+ Q; c  `  J5 D
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
, z: K0 ^4 ~' a; P. n# K/                   Fixed f_mkdir() on FAT32 creates incorrect directory.' G0 n, T- w2 G! Z
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
" e! Q; C* x/ j) O0 q% ?5 A1 _/                   Fixed off by one error at FAT sub-type determination.2 P1 r; B0 {1 W' ^1 P: S; u) V
/                   Fixed btr in f_read() can be mistruncated.
1 ~5 \' U6 ]' d+ Y4 Z! r/                   Fixed cached sector is not flushed when create and close without write.
# E# [# n$ P% |6 ]/
" u# \& \$ x$ e7 S/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().
' z2 G4 |( C+ X/                   Improved performance of f_lseek() on moving to the same or following cluster.0 l, M8 g6 B+ ^) O1 [! f! y
/9 `# j$ X9 a0 P7 v9 ]. z
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
/ D7 }, k/ {6 s, h  y. d& f/                   Added long file name feature.; S/ h7 C$ \- c! i9 J
/                   Added multiple code page feature.
/ ~) b* v- e& k/                   Added re-entrancy for multitask operation.4 @+ m7 L( \) ~; B: L, B3 U- {3 G+ g5 F
/                   Added auto cluster size selection to f_mkfs().
$ R/ P' g) q( X$ i- f/                   Added rewind option to f_readdir().% b. D& r- a+ W( {* `0 a+ \
/                   Changed result code of critical errors.' k# K0 M9 B& K3 l8 H
/                   Renamed string functions to avoid name collision.
* M- |- v: G$ `; K: \/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.# O. N; T. C9 q  R% g/ ^
/                   Added multiple sector size feature.  i- g3 j* a3 z/ N' |6 \
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
% H! l7 Q) R' Z9 Y$ o% d/                   Fixed wrong cache control in f_lseek().
9 o# d$ g% F; H2 H0 P/                   Added relative path feature.( l8 ]1 R6 J% k* |
/                   Added f_chdir() and f_chdrive().
9 k( B3 y0 N. g3 E) H/                   Added proper case conversion to extended char.; Y  p$ D2 u: t3 L1 {
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.- V+ l0 l! y7 K; z; z3 l
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.9 K" \+ `% ^4 c4 v
/                   Fixed name matching error on the 13 char boundary.# L6 \" d/ J- d7 f: O0 Y
/                   Added a configuration option, _LFN_UNICODE.* x7 P  A" [* h( Y. u$ p: h
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.# i5 ?2 E8 g9 e$ V- o) G9 s
/* O% K. v6 p6 ~9 M: h
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)
  \0 E1 @9 E$ |$ V% ]4 i/                   Added file lock feature. (_FS_SHARE)
0 a  W7 J" x9 W2 Y/                   Added fast seek feature. (_USE_FASTSEEK)& ^$ ~1 C& o5 E# w) P; I
/                   Changed some types on the API, XCHAR->TCHAR.
1 P2 i9 @; }5 H! e/                   Changed fname member in the FILINFO structure on Unicode cfg.
5 [% E+ }1 h9 `$ g& ]( Z  Z/                   String functions support UTF-8 encoding files on Unicode cfg.
0 `! v5 j& B. e/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
1 q: K: j6 g! g$ |/                   Added sector erase feature. (_USE_ERASE)
* D' p4 y0 _  V) n/                   Moved file lock semaphore table from fs object to the bss./ a3 N3 |. C+ R: x
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
! U5 A: Z% A5 n# t/                   Fixed f_mkfs() creates wrong FAT32 volume.
/ T/ S' H& W; J# ?1 e2 E4 _1 }8 V% b/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
( t  p" n4 e& K, j5 q/                   f_lseek() reports required table size on creating CLMP.* e5 P" N6 E, S2 x
/                   Extended format syntax of f_printf function.
: \. v! `9 ^4 g, \! E1 ]/                   Ignores duplicated directory separators in given path names.
5 T0 s7 d# X+ ], n- x+ l/
  k/ C  s/ {, n9 _& l" g0 n$ m4 C/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
( G1 `1 l3 P# R/                   Added f_fdisk(). (_MULTI_PARTITION = 2)+ T) F* L2 f! \- i; d' m
/---------------------------------------------------------------------------*/
) w8 J+ n  O* i% ?& Y/ O
- ^' y+ h5 J# t& S0 P; q  M( A8 Z

STM32的SD卡FATFS.rar

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

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

211

主题

652

帖子

1507

积分

四级会员(40)

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

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

本版积分规则

关闭

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

巢课

技术风云榜

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

GMT+8, 2025-2-17 16:34 , Processed in 0.070397 second(s), 34 queries , Gzip On.

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

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

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