找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1390|回复: 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工程。下载即可使用。+ ]# S; {8 _& J& @
/*----------------------------------------------------------------------------/. n9 |1 e4 l7 E4 H7 q9 w: R- T
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 20118 G) D! G2 q! e0 E% `; O5 K
/-----------------------------------------------------------------------------/$ Y# U$ ?* O2 v) i9 z
/ FatFs module is a generic FAT file system module for small embedded systems.% l8 `" j% b0 F+ h
/ This is a free software that opened for education, research and commercial7 J/ Q2 ]  E. r7 J1 _- W, x' A
/ developments under license policy of following terms.
3 Y) j/ ^, U! `6 L# c" r& Q/
. ?/ F2 w! q, Z/ ~/  Copyright (C) 2011, ChaN, all right reserved.
* C, k4 u5 N+ e$ f/8 J7 }% [* m2 e2 a( n0 G
/ * The FatFs module is a free software and there is NO WARRANTY.
1 S/ `/ `. E% a/ {/ * No restriction on use. You can use, modify and redistribute it for. |- r7 I  O0 S! J( @& g! k0 E
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.* w! T* ^3 v/ y8 W" @. H
/ * Redistributions of source code must retain the above copyright notice.
$ n: G$ C7 U" I% {: ]/3 A; R/ I+ p- F* g5 y
/-----------------------------------------------------------------------------/
2 M5 u# U) Y! L' C' R4 ~0 [- I' j. Q/ ]- a+ i: s8 q
+ v/ g8 A' M5 `, `! b) l
/*--------------File Info-------------------------------------------------------+ m5 W8 `8 j+ a* Y# _/ X  U: z6 m4 ?
** 文   件   名:  FATFS_Function.c
4 E3 [/ V0 c2 N4 t( e& K** 作        者:~风中的叶~    整理- X3 d# v+ K; x0 f$ b
** 最后修改日期:  2012.01.18
! k6 x; {2 C  Y# R5 u# N** 版        本:  V1.0+ u1 A# S7 d0 U. L# Q
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出# x2 k3 B2 ]7 ^5 f5 h4 Z" s) W) P
**------------------------------------------------------------------------------; G  g8 P- L; q5 }
** Created   by:  Dt.4 m/ t. f4 q( e  k
** Created date:  
7 y( n: ~1 z8 V6 \*******************************************************************************/
; _! _0 l) @" C5 E( l. _! x* s#include "TEST_FATFS.h"& c0 i  A. _& _! d, [+ h. O
#include "string.h". i5 `  D1 y4 n* W( L  e
* o  [3 d- a% T* |! ^9 B
#ifdef TEST_FATFS_EN% h% w/ b) A  Z5 q

. Q2 |5 r& q/ }9 ~' a6 |" ]  T# w7 q0 {' z( {+ s3 d
; |( o# N; X. J6 G: M, n6 ^' X2 ^
//检测磁盘是否插好
$ p9 @+ W2 y3 r! S7 x3 L* f6 x0 ?' iBOOL disk_detect_OK(void)
7 D5 a5 g# t5 J- ]* X- ?{& k! ~# K: H5 n/ ?% M1 d6 v
    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
, M. e; h4 r4 K7 @        {# O0 q( m! n0 v5 b6 q
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");# ?, ^2 }5 I8 h: T+ {
                return FALSE;, n" j: Z" Q) Y7 g
        }
3 C4 N/ s" {2 a4 k7 N' g        return TRUE;
; U+ B( t! ~+ m9 `}
7 V: A/ E' f* F  ^* ?) t2 h& G( B* h1 Q& d3 C5 q( K

8 ~/ l5 _1 m* _' a  s  ]+ ]' y# c, @- n/ i
//测试函数执行结果分析; o: R- n2 ^: G; i
void die(FRESULT res)* r  J7 x6 ]! L' M2 l/ Y3 M# e& _
{" r! \3 q3 C: }
    switch(res)- h  ^8 p, r4 L5 q6 i
        {; e" k+ r: W; [4 R: h% L
            case FR_OK:        //The function succeeded.
" H( C  M6 l& J3 Z$ V" {: F                {5 E- u  k& s+ y, A
                    printf("\r\nThe function succeeded!\r\n");; ^( {1 r+ g- M5 ]: R2 U: [
                        break;2 q& c0 Y' x$ f' ^" n$ i2 L* b
                }
0 `$ D- M$ Z% X: Q3 R5 O7 q                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
  q/ {) ]! ?7 ?8 [                {
! S2 \$ E4 G' l* S6 n                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");  Q$ P/ l5 [+ T* y0 k
                        break;8 F0 h+ x# G, K7 [# D
                }% ~2 H3 d+ h! i# m) w. y
                case FR_NO_FILE://Could not find the file.
# a% N8 D# Y- N2 s, u# F7 T                {
* t/ U! J: I! S! V                    printf("\r\nCould not find the file!\r\n");
8 G) u! G  m- t* O: w2 k/ k: ?                        break;
5 F' f9 o; }+ J0 y/ [' c6 H1 {                }" t0 o) [- N  a3 }+ m) c2 ]% E
                case FR_NO_PATH://Could not find the path" Y' z0 ]; h: Y' q7 W
                {( U/ H7 m8 {8 c" J1 A* p
                    printf("\r\nCould not find the path!\r\n");6 V6 W! {; M; r7 z6 C, U/ i; i9 S1 K
                        break;* {0 v5 y( y. A3 s
                }
% b8 t, W8 ?$ c1 Y7 V                case FR_INVALID_NAME://The path name is invalid, q7 ^9 |6 |  B: N. m! X
                {
4 h" _0 P1 x/ N% S5 f3 y                    printf("\r\nThe path name is invalid!\r\n");
+ T0 F" g* `. z$ `! e% k                        break;! t' a8 `, h' I: P" u
                }
  T" N9 |5 o$ Q, d& c" p                case FR_INVALID_DRIVE://The drive number is invalid! X- o& p+ d: ?1 F; ~7 b
                {
, b2 \# h/ ]& _* r                    printf("\r\nThe drive number is invalid!\r\n");% i* _1 k6 }* Y7 Y
                        break;) F) \# |* }9 I7 s
                }
# r: r  o* i: b3 {4 Q1 w4 t9 _                case FR_DENIED://The directory cannot be created due to directory table or disk is full. " W5 ~  t9 ^# {9 n  t* i
                {
  b* u/ k1 @" B                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
3 C  k" G) i% U4 h) ]' Q4 z+ J                        break;3 g( c0 B, C( K# f1 I
                }$ ?+ C7 W% F9 I) E- G5 e
                case FR_EXIST://A file or directory that has same name is already existing
* H# I" r2 y$ n/ W" [* r+ D                {: [5 w: l; R& |, l) U/ N
                    printf("\r\nA file or directory that has same name is already existing!\r\n");
* @! d, i4 A, T! [: {% h' }                        break;
+ Z* g& O" M+ D" ~. G/ y2 {                }
' m# C" I( o' M7 h3 D//                case FR_RW_ERROR://The function failed due to a disk error or an internal error( U2 q, T* `. x, q/ o; \( F) ]
/*4 K* S% u6 c5 d3 ?& I/ v. F
                case FR_RW_ERROR://The function failed due to a disk error or an internal error2 o- z: V% d5 s: X
                {
* l; X, @/ V' @2 S                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");: T. G; |+ W+ F8 A* Q9 e' B* P+ N) y
                        break;
$ O& E$ {# I  q; t  G* b" w                }) g* P- R. d* i. z/ _  K( m' m
*/
& y; v" I; V0 \0 c  s9 j. ^                case FR_WRITE_PROTECTED://The medium is write protected3 ]2 m5 Z2 _! ~) Q
                {5 u% R# U; T, N* J; U
                    printf("\r\nThe medium is write protected!\r\n");( C0 o/ D; b5 X* Q" f6 t
                        break;
: ^9 K, Z8 H7 h0 U& @  r$ q                }: L0 S8 Y6 @# y9 ^
                case FR_NOT_ENABLED://The logical drive has no work area7 |$ @) F+ I9 e
                {' L& `2 J$ ?7 n1 t1 T1 p; |; A
                    printf("\r\nThe logical drive has no work area!\r\n");
; [! F! I& M! t2 W                        break;3 u+ @; f: [. ^. {9 C
                }% E0 a+ U" s& O" Q: m+ J* F6 M
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk4 u- k1 \' P9 _2 u6 ?4 u3 v) j  M
                {. ~# A1 j0 c* g! _' S
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");6 U+ R7 d5 Q: ^) K8 L
                        break;
3 X1 {# ~, e9 l# C2 F                }( i4 G2 n8 z+ `; {9 ?$ r
                case FR_INVALID_OBJECT://The file object is invalid% p- z: n- h3 S7 N
                {9 d( l  {! ]8 P5 b
                    printf("\r\nThe file object is invalid!\r\n");
; \0 c* X) m+ h                        break;8 G! i$ Y/ ~/ T+ d4 M& T! r
                }& B1 ~* `2 m* \5 v1 _

& j* t  f( J3 v: Y0 J, |9 J+ B) u            //The function aborted before start in format due to a reason as follows.
3 b& A0 ]/ G) p) F( ~  c% _5 h9 |: e        //The disk size is too small. 5 X' U* g* n, w& u% ]
        //Invalid parameter was given to any parameter. 8 F- F5 F% `9 v* y7 ~6 W
        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7. 8 t# a, [8 h7 U  ^: h! O
                case FR_MKFS_ABORTED://
% m- H& z2 [* A$ r# r. ^                {6 ?3 v* F5 e1 o
                    printf("\r\nThe function aborted before start in format!\r\n");
% |. B7 u$ e- f/ G% }                        break;9 T9 N% K2 m, o6 f! R
                }
  q0 u. d  w% k7 g                ! E" b$ K5 R/ r- ]9 o2 A0 \  I
                default:# n0 L1 U% T" h' l- j/ O$ U
                {
+ g1 c/ j3 a9 E# i- Q, v# F                    printf("\r\nerror!\r\n");8 g% m" J3 h% c1 v5 P
                        break;" x; R7 d9 c3 N
                }        
7 H  W7 Y0 Q& d3 F, F4 b        }. r" v9 S& m" j4 x5 r
        return;
; m- `+ o1 l  L/ E4 V; D}( b  d6 {6 `4 h+ {3 P# k$ u
void Test_f_getfree(void)//获取卡的总容量及剩余容量
1 P9 b/ D: W9 c( t{
5 f1 e8 Q+ F4 x" Y1 e) M* d% P    FATFS fs;3 |7 S( A: F" H5 n1 P% H. d
        FATFS *pfs;
/ D9 Y' \7 p  f$ ~3 Y    DWORD clust;; n5 i- F8 V" P! c
        FRESULT res;         // FatFs function common result code2 o3 g( w3 Z" {
5 y3 v$ I8 i0 k' K* T" M
        //检测磁盘是否插好
: k" i3 n3 }2 Q1 r        if( disk_detect_OK()==FALSE ) return;
0 ]. T8 ?5 \; c& }$ H) \- [8 ^- Y, C- [
        pfs=&fs;//指向4 `' P6 U% [$ E! x( F, P: b+ n
        // Register a work area for logical drive 0
0 @; w0 Z/ |: U2 S2 Q. e    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
' R: X* D% [: }; Y1 o, G. m( n1 o% |# J. b. D6 J& T1 B& }; i3 Q* k
    // Get free clusters7 S/ B" ]2 v# S$ o! Z
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
0 P5 [: f" e" d* ^  z    if ( res==FR_OK )
$ I( y7 h& A- ?  I/ ~9 W    {
. R9 m" G" h6 ~. C  f4 c1 y            // Get free space7 X0 I4 |* f3 M" h4 u& |
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",, \2 Y! y6 i3 W
                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
& [8 k8 g* v5 |                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
# W3 k6 d" k; o% q0 _8 r8 k        }
' Z  z& z! i0 @6 i        else die(res);//测试函数执行结果分析4 l4 T( n3 q  N; D
        
, r& I7 @7 B: _        // Unregister a work area before discard it
# O3 u2 u1 v% _    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间& Z7 l( ]1 w3 C' `& ^) b
}
0 [' D" ^# N" M$ V  ^" L' K
* A! L# ~, b, `. {void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
! H4 n: X1 M( z& L% N/ ]{
2 L" V; `" J0 _% ]( j& ~    FATFS fs;            // Work area (file system object) for logical drive* v! n% L( V) E: D) j- Y; S/ o
    FIL fsrc;            // file objects: I  f5 G: i5 |) |" N* ~
    BYTE buffer[512];     // file copy buffer
; c' ~& B' S( b. i- ?    FRESULT res;         // FatFs function common result code9 X2 Q2 Q# \! J" I& b
    UINT br;             // File R count
4 T. e3 {# [" M& Z  U        u16 i;
* z+ N' n4 S6 g! b* @        
4 f8 [7 ^' P' g4 s7 L) ^3 g3 S$ ~8 p+ U8 f' b. S! ?5 X
        char path[20];) d: Q( k+ [# F- e' x2 N

4 g$ [6 o1 V( }9 w        //检测磁盘是否插好
& I0 ]/ v: j# g& z        if( disk_detect_OK()==FALSE ) return;5 P  x8 O+ N9 M

9 t0 I. H7 G# u% L/ f; V    // Register a work area for logical drive 0, U: ]( @. n, f- h, [; v
    f_mount(0, &fs);
7 k2 J$ A. R1 ]" S1 p
# v  L+ H- Z0 v! }' J        printf("\r\nread file:>");
5 x6 X7 x% z  k, ^2 o        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
9 t+ }. K- f# W2 }  y6 F) \) e% j3 [) u
        //Open source file+ }6 q+ J' D; T6 Q) _& W" [
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误% I- }# x% A) L+ Y8 f
        die(res);
) q) K) }1 Y. ?' B' ?/ m        ' a+ m  ]$ g% C; n
        //buffer空间设大一点,会提高读的速度。
) J6 c7 I, \, C# K3 G: F; l        //如果文件实际大小512byte,5 k" {9 K; v9 K* _1 b$ Z  e
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。5 a5 ~! L! k$ e0 ]
        //下面两行主要是去除1s误差。
! X1 B3 q" Q5 V" [# I; Z) K! r# y
  S& p$ z4 F) T( r& {& X        for (;;)
2 f6 C: s1 }5 J8 v8 r        {0 M; w! q' f: I3 H5 \
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存, e4 \- {  n, b  i7 j

1 ~; y( Q9 r- O6 T" e) S8 E- O                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
7 e1 f: c/ F! d: b, W6 @7 m! k& J$ j        if (res ||(br == 0)) break;   // error or eof        
3 W' N& t6 n6 G6 x- R! y6 Y                8 V; ~- O! ?1 g
                printf("%s",buffer);        
3 O$ v2 x0 V/ Y+ `+ ?& q    }
/ g. C' i3 A  `7 r6 Y6 l
( ~/ `- e0 u2 K% r0 i                            ! P. ~+ t4 q: c# X  R
    // Close all files
9 }# f3 Q0 B6 p& s    f_close(&fsrc);- K6 t* i* [3 `$ q
    // Unregister a work area before discard it
8 R" m' @5 U& p. R  S9 l- n    f_mount(0, NULL);& y. l8 M+ c* l* M
}
$ B2 x' c  q  e2 Q2 e
) f  W3 L) P" G0 S( A  ?0 L& Gvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
. i' g* B6 S6 a) X/ ]* M2 l{
' c; I" U) ]2 _, a4 w+ R# ^    FATFS fs;            // Work area (file system object) for logical drive# `1 Z* V: _. e3 F, L2 w
    FRESULT res;         // FatFs function common result code& Q7 x: w0 B: k% M: x# m2 X4 g# @
        FIL Make_file;# S2 y/ Y2 k2 `; N
    char file_name[20];0 M, F" Z7 E8 R$ @/ s7 [
    char Storage_buffer[] ="0";8 F. h2 U8 M- [1 _- R
        & O% c8 b8 C! k
        UINT bw;
4 S1 S8 ^$ K5 V2 _& A        //检测磁盘是否插好+ N, ?" {8 K. \3 w1 d" P
        if( disk_detect_OK()==FALSE ) return;
" y% l. W% f5 U2 {0 ?3 x9 T) q5 j         printf("\r\n inaert_ok:>");7 O) R2 W# W* J6 P( R% g# k
    // Register a work area for logical drive 06 `" _. ^1 }* j$ _6 s3 E7 ?+ L
    f_mount(0, &fs);
" w, D, f) m9 n2 l, ~
- S) U3 x' W, C% A1 ~* [        printf("\r\n Make file Name:>");8 o' x3 J$ K8 g
        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
/ v; \' N2 n0 |4 h% s" z) ?1 b6 H! T3 H
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
  X" G) \' F+ v2 l0 `         printf("\r\n open_ok:>");+ N  J9 ^% h) Y  c/ N8 o0 L1 d
         die(res);0 A# m+ X( W7 [* @& Q; U
    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  2 `- h6 f2 X1 w( I
      printf("\r\n seek_ok:>");
' g( M3 F! P) N         die(res);
1 o/ i6 F+ y# p2 y: q2 L        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
; O, \7 J& p$ |0 p6 |6 b5 m$ C     printf("\r\n write_ok:>");- t4 m, J' m5 L" V
         die(res);6 |6 z! |+ G2 u1 F
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
8 {4 u, _& d8 `" e% E        f_close(&Make_file);//关闭文件
0 E. }4 c3 a7 Y        printf("\r\n close_ok:>");
) @. n+ ~3 m) c2 |
, c/ _1 |2 S" o; K. K% z( ], Q        printf("\r\n写文件测试OK!\r\n");  N# j9 b% S+ n  ~7 O' c
9 R1 [* {* W5 ?3 G
        // Unregister a work area before discard it
5 n% I7 {8 A3 ~$ m- z% R& X2 v    f_mount(0, NULL);, x$ ?" V$ J2 a  I! e
}
: _( {1 ]+ C1 H9 T1 O0 k
- R( `+ S- `4 f' l- `//The f_read function reads data from a file.
! S% A3 c* V. t! i/ b//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样* I" l# V2 r, u/ Q
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了
5 y5 S: X: V. r+ l% F% o8 N  W//所以以后要特别注意这个问题。
8 n+ [4 y* A/ x( ]5 h# f& T9 R4 q; d, N) L- E  d& L/ R. r  f
u8 StrToData(u8 * data, u8 len)7 O: y* r6 o% |3 }
{
# w- S/ u$ o: W$ q" G+ l  t        u8 ltemp;
( f& v' l' \+ _1 d0 _9 v3 f1 e: l        if(len == 1)
9 K/ ]) p0 s/ N5 @. d" s        {: Q! Q6 o6 l: x/ a' T9 Z% e/ {
                ltemp = data[0]-0x30;
! e) F6 s7 ~' O- D; u4 Z' E, q8 G
        }5 v8 b: o4 W1 [3 [, U7 n  r. g* c
        else if(len == 2)
& b2 A/ m( u# f6 a+ C& Y        {
  g$ O. x, g9 w& P  Q5 ~                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
5 C  O$ o# @3 z
' Q- t( _2 m5 L0 Z0 B         }/ M( [( c, |$ M/ ^- S, [* B. ^) b
        //else if(len == 3)# j4 \4 v5 s* r; M
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];) n2 M  f$ S$ S+ J* P

3 t& o3 P3 t- v$ R6 `        return ltemp;
: e% A' V- c8 n$ _! d, {, }        
" v7 V- G7 w! O- |$ F( i( `}3 o1 S7 \9 j/ ~" \3 G
7 l$ \6 \% F9 [( D2 ?

9 X. y2 y- O0 F#endif
3 a- h4 S' R+ |9 E5 j7 P$ p" F, [4 ?6 O

' l( `% C) C, D' E/ ~/ z! Q/*
; C4 U: E0 _4 qint main(void)
- g) s' D" P9 g; P7 \, l( j: G5 h{. l4 d6 ?8 F0 k0 h
///////////////////////////////////////////////////////////. y. Q% s5 N! G6 Y, U& {. w
UART1GPIO_config();//串口IO口配置( E0 @* G9 M9 W5 w/ {5 O% B2 S2 M
USART1_config();//串口初始化波特率为19200
) M. Z% x: S2 j3 q# b% u; _! H//UART1NVIC_config();//配置中断
/ ?4 r0 d3 r2 X0 ~% H2 r5 y: n//////////////////////////////////////////////////////////// [6 D+ Q8 G: f- T  t% X8 Z6 N1 ~
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式3 P9 @3 l1 _# E) j
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
) h! i" j. k$ I( v1 VTest_f_getfree();//获取SD卡的容量和剩余容量
. I0 O& @  j8 [' s8 ATest_f_read();//SD卡读文件测试
, D+ K* ?/ L7 `" X" x! A* U4 H4 aTest_f_write();//SD卡写文件测试2 U0 C- h* ]7 k$ |8 O7 ^
///////////////////////////////////////////////////////////
" h" e, A# u- ]+ s& Y2 V8 N    while (1)  f' d5 t5 S- F) H, W% [, _7 D
    {& o0 Z3 J$ m- x/ B) ^2 W! A1 @9 B
        //printf("好的");: _" p' H  k( e3 m, ?
    }
8 o0 v; F$ @/ b5 t}*/$ q6 c& H& H+ u0 H! A. L
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
. f& V: s2 g: b/ F; E! }- ^FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
3 A  D/ O* H, x8 T( r{$ P/ u/ c; q# S2 c& Q
    FATFS fs;            // Work area (file system object) for logical drive
0 S& _7 ?5 o% w  `  R" n( \2 l! d    FRESULT res;         // FatFs function common result code) |" J7 i. J7 P& Y
: h$ @0 y/ b; W8 K
        //检测磁盘是否插好
/ Z- F8 \' t: F. Y        //if(disk_detect_OK()==FALSE ) return ;+ H0 n3 w1 `/ O( _7 q2 L
        //printf("\r\n inaert_ok:>");
1 h, z7 j6 q6 n+ Y        // Register a work area for logical drive 07 c. I( M  L1 t7 i
        f_mount(drv, &fs);5 x  @# r$ Q5 f) ^* V0 C
        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/  X8 E2 O) n2 L8 @4 F  l5 c
        //die(res);
( F+ c6 c; l5 p8 M        f_mount(0, NULL);3 e' Y  _. p& m: C% ]
        return res;2 r% E( e7 ~( m$ e+ D
}* |1 J; ~* F; \
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////0 U1 y5 Q9 M% I. g9 E2 q! T
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
; u6 Z: t+ b6 Z6 [{
# z7 N8 ^. y8 R# \# _7 J    FATFS fs;            // Work area (file system object) for logical drive
/ I. a1 x' T& A  h1 f- e9 k    FRESULT res;         // FatFs function common result code2 _! m4 C$ P- U; s, I& i

0 r1 E. u. b. O! {, K9 V        //检测磁盘是否插好- w3 m  g" r% y; `! Q2 @
        //if(disk_detect_OK()==FALSE ) return ;# E& X) `. u% `4 L+ l
        //printf("\r\n inaert_ok:>");5 X3 E$ l( r+ @0 R5 n+ N; e' J; l3 q
        // Register a work area for logical drive 0! v" b1 o1 w2 k- ?
        f_mount(0, &fs);
- W: D' M% }; Y8 _; x        res=f_mkdir(path);//创建一个新目录) p9 d0 F3 E1 Y9 G# o
        //die(res);* @0 D! M8 p- }) y; z  G6 m' v
        f_mount(0, NULL);. v. {$ R3 ~/ g0 H3 ~& d
        return res;* U& K( m4 W, P4 a3 H
}
8 V. \- Y" Q2 Z  k7 a9 D////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////# _9 g$ T) C+ Z5 U2 c  |, }+ y
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        6 l# O3 _, ^1 L' ~9 }& y3 P
{% V4 W# D  ]' p0 M* E2 u
    FATFS fs;            // Work area (file system object) for logical drive
# M7 f6 o/ L. ^7 @' B; r# I        //DIR        dir;
4 U/ Y' r! @* s: [$ F1 I    FRESULT res;         // FatFs function common result code
, {7 k* r) r3 m0 T) Y% U/ \' e& f5 s3 x* ]
        //检测磁盘是否插好
* Z" y7 C+ c6 |1 u) N& H        //if(disk_detect_OK()==FALSE ) return ;- W, q* ?/ b2 |, L
        //printf("\r\n inaert_ok:>");% g+ |& s' F- e1 e
        // Register a work area for logical drive 0  i, u; e; Q  @" _  P% g. s$ L7 ?
        f_mount(0, &fs);- m: U* {2 ~8 H9 ?7 r" g
        //f_opendir (&dir,path);- _" x' u- ]' O- y: s$ F
        res=f_unlink(path);//删除一个目录
* Z5 S: V$ c1 Z0 o& z. u  P) g0 a        //die(res);  k* [) z( V' h/ Q2 B
        f_mount(0, NULL);
3 C) Y7 N, t$ B/ T* y5 [; g        return res;- A7 L3 t$ H9 I
}
' \6 l2 O% w5 K( j$ _. g////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5 [" M$ ?: h" |5 V) V5 \7 T; r" {6 R
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        ( v' k* Y, h* Q$ D" [, A9 b
{7 C  }5 T3 X( d& M, G
    FATFS fs;            // Work area (file system object) for logical drive0 U. F9 v# u8 [: U4 m' \" S8 ^
        DIR        dir;
3 r+ l- D" R4 l$ w1 f/ g! o3 f        FILINFO finf;* _5 l$ j( X# T# U# {) |
    FRESULT res;         // FatFs function common result code) }# u+ ?- a9 e+ k1 \

3 {& i4 m6 z5 k        //检测磁盘是否插好2 s+ V, j+ E! b
        //if(disk_detect_OK()==FALSE ) return ;6 L5 Z1 p* D' V
        //printf("\r\n inaert_ok:>");
' A. c0 v$ ?! a1 }% \$ |. C+ l6 h        // Register a work area for logical drive 0% A& D3 j8 {7 `) A. u1 W3 N
        f_mount(0, &fs);
0 j* m+ W4 h/ k( F/ f        f_opendir (&dir,path);" Z) i  _2 N9 j
& t8 c. T7 x6 x, f% O* X' L
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
: D, a1 I  w$ _1 l        {strcpy(*(filename++),finf.fname);& Q# n) Y6 N8 z( \
        //printf("%s",finf.fname);) r2 z9 {( b5 l$ V$ F% E
        }
; [' U/ O  P" z4 @        //die(res);! B* \5 h# r0 ]
        f_mount(0, NULL);
& p7 o$ c! R4 i  {- s        return res;
4 I" A) B2 [/ D! U$ ^7 Z}
: U- m5 e9 t: X////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
8 Y' B5 N$ o, b5 f" O9 O) ]FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名; j% O; j" F- @* u5 T
{' K( U4 F# H5 ]' |* ~
    FATFS fs;            // Work area (file system object) for logical drive
# e" D8 s9 j$ U* A3 c% d$ v        FIL file;0 T* p4 F0 I7 H+ b- D' D
    FRESULT res;         // FatFs function common result code! [6 p2 V4 E5 H; c% A4 H

! Q  K2 G0 k4 X4 d, K        //检测磁盘是否插好
8 |" J- ^& @- e% t$ l        //if(disk_detect_OK()==FALSE ) return ;
2 ^/ y/ D: l$ t3 o7 o+ g        //printf("\r\n inaert_ok:>");
  o" r$ E4 y4 k! M( u  V" g        // Register a work area for logical drive 0
  w8 Z8 Q* b- @" G1 b        f_mount(0, &fs);
1 J, @% }& N" P" y. P. \* D; G3 A        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
+ [) T' W+ |; j$ _" y$ ~2 M                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
& L) p4 q$ n! A                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
9 ?8 N- y& s9 f, E( R        //die(res);) ]0 Z; w' v' Z! x) H+ M
        f_close(&file);//关闭文件/ L1 e/ s1 j* T' y
        f_mount(0, NULL);7 @5 D3 Z$ P2 g  t+ g3 `8 K" f
        return res;% z5 T$ ?: {6 i& t7 |" }" R& F8 N" G
}9 F" r' e6 j1 d# B( ?; w- y
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
+ ?! P) w( k: C5 GFRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
- ^$ F" _; X+ o  Y% q# n' L+ A8 J{0 \9 k# r9 G3 N3 C  v5 ]
    FATFS fs;            // Work area (file system object) for logical drive% D/ J5 s4 Q: w1 `2 L6 F1 x
        //DIR        dir;
; ]) n, N  {; w# @$ q% I) n    FRESULT res;         // FatFs function common result code5 {* \1 s/ Z& _$ g5 A. m9 A1 {
+ G- L* ^. x6 ~! q) I
        //检测磁盘是否插好
% ]0 N+ K% x4 P. X9 B        //if(disk_detect_OK()==FALSE ) return ;
9 p8 N8 z% G4 S" e  y. P" Q0 s4 ?        //printf("\r\n inaert_ok:>");9 E3 Q* ^& K# }5 i" @/ \
        // Register a work area for logical drive 0! |2 _7 C2 P, Z
        f_mount(0, &fs);
: X; C, e$ N% Z# }- C$ l        //f_opendir (&dir,path);
1 T8 t: @; r& B& o$ }        res=f_unlink(path);//删除一个文件; ?5 \; e, z* K8 p  a8 H
        //die(res);
3 K' W+ c' U4 j5 y2 Z5 y        f_mount(0, NULL);
* v' O& x5 D/ m  K        return res;( z( N; b, J4 E9 v' S. r7 M
}' J$ Z6 w+ D' [9 d- B  Z( V3 @
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
3 m# z& v4 W" ~9 R) K" iFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数+ n1 D* |- t% B4 u1 {2 b# w
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));* y0 B+ U' F* G  w
    FATFS fs;            // Work area (file system object) for logical drive
2 r( J" }! T' m. d: n; d    FIL file;            // file objects
2 I9 s( o) k# a. Q0 n    FRESULT res;         // FatFs function common result code
3 x9 x% e+ H6 P4 G8 t7 u6 u" u    UINT br;             // File R count 文件读回的字节计数
$ d3 e3 q& U. D* u/ a6 }        //u16 i;" R# Y! R. I8 }. }- i* N( _
        //检测磁盘是否插好
; P. h. G- B6 E& w8 d        //if( disk_detect_OK()==FALSE ) return;' a/ A: Z; b( a" i
    // Register a work area for logical drive 0
; ~9 X4 X& c% K- ~: p        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';/ P  s# W% X7 K3 S9 v
    f_mount(0, &fs);- v/ Y' p+ f, R3 O) m. q2 G
        //Open source file
- M! q1 O: p$ Z$ D    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
7 N9 B' S# c8 ~( i! \        //die(res);
- ~% f; |1 e3 B        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
# H% {. b3 @. g9 q( |1 [        //buffer空间设大一点,会提高读的速度。8 U- }( R/ l9 ]1 t& G8 R
        //如果文件实际大小512byte,
; v# T: P$ ^4 K6 S" B2 r+ u5 Y' G        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
  G5 B2 N( \/ _: ^  Z: z        //for (;;)
% E# [, a" k2 ^  X# S* n        {
1 b6 |5 A) ~1 h! u                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存) G1 J6 k0 f, l$ h

' {, R7 B2 v/ b, D8 t                res = f_read(&file, buff, strl, &br);0 n: ?/ q& M9 O
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出' {9 x+ N+ H. R$ ?* X" \
               
$ R0 ^  C2 Y1 U9 O$ q" `                //printf("%s",buff);        , x' s( f8 p) O
    }                    
8 [5 @4 ^* ], k9 ]3 Z2 v    // Close all files/ e5 X  p1 q+ F0 r
    f_close(&file);
# n( B/ m" a6 `    // Unregister a work area before discard it. \1 F6 R& w( M. S
    f_mount(0, NULL);( R) m2 b4 |8 i9 p8 Q% Y0 E
        return res;
) Z9 p9 O+ M' n/ c6 P, O}! ]# D0 g; ?& U  i) J( M4 \# P
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
) f1 D' U% q" pFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
/ F) C+ ^' S& y6 I' T. G' ?3 W{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));
- D9 u' Y# ~. p2 o- I    FATFS fs;            // Work area (file system object) for logical drive
8 R( \$ H: ^" o, z) w* @    FRESULT res;         // FatFs function common result code- I' U! u$ S: q* Q
        FIL file;
. O0 c" Q  u* {) `# S* R        UINT bw;             //文件写入的字节计数
* X) o/ h, Z7 v! Z5 |% D( q+ q3 |        //检测磁盘是否插好
- O: z6 o& V  D8 W, v        //if( disk_detect_OK()==FALSE ) return;5 G. J' z# P0 p! i* s
    // Register a work area for logical drive 04 W" }+ ]! j' H# f
    f_mount(0, &fs);
# @$ p$ }! g: J2 A0 j# y! l" m# b    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
% d6 P% C7 h5 ~  F: e1 \" o         //die(res);
* E2 h; K4 r- O, z& z6 B2 L- {    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
& m- P% ^- z% U" [- l5 ]3 F         //die(res);% g) A! S4 [) K' x! b; x
        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符( e0 o8 L* t; F! g1 w5 f
         //die(res);
; x) s  _- N9 N6 i. B, ]        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
. J) f0 E1 f9 C  m  T1 c( F9 o        f_close(&file);//关闭文件
/ A' C( ]! r; z: T7 u4 \) d        // Unregister a work area before discard it: g) D# W& O3 u  N( F6 X$ d* y7 c
    f_mount(0, NULL);
' M  y5 d% c* N4 a3 [+ w+ P        return res;! z1 g7 ]. T& P" U) w6 N& Y
}, Y- c9 F0 e3 ]' X/ |( _
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////& @( M$ L8 Z/ h. u" C, c) ?9 ^6 i- E) G
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M
1 v; L& S- A1 j6 s{
+ i+ w- J( j+ Y    FATFS fs;; n* M/ I6 m; a0 d+ g
        FATFS *pfs;
% X, X9 }- ^7 V6 H3 Z+ L% B; _        FRESULT res;         // FatFs function common result code
$ h* V  U2 |' F        //检测磁盘是否插好
# r3 F" j% A# s) n9 O        //if( disk_detect_OK()==FALSE ) return;
" h( a& |  P2 l2 E1 S8 @- ~# }# }        // Register a work area for logical drive 09 y- t3 m# M9 S  H9 h
        pfs=&fs;//指向; ^' }. q7 T. N- m
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间! H  j1 j4 Q" z- i/ R( Q: |: ]1 |
    // Get free clusters; y; l) A7 n" }8 M. C. e; l, B, D
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"2 X2 r" q6 L3 {9 q3 e  N- [) q
        //die(res);' i$ C+ z3 t7 W0 A' `' L! z
        if ( res==FR_OK ) , ?1 c% B: S9 P0 v: p/ z+ `* A
    {) i* [6 A* ~% H
            // Get free space+ m( Z$ b# x* [6 Q4 O* _
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
' p" l. p  d# d% V+ M, o               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
% e9 x, Q6 a5 X# f% x                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
, T, z. k3 m* F         *freem=((*freem)*pfs->csize)/2/1024;( t3 Z! j) {4 w9 `
        }: s( O$ d" U* \1 L
        //else die(res);//测试函数执行结果分析
" E$ T5 g) \1 X2 {! z* f8 H  `        // Unregister a work area before discard it) c0 h! g8 f# w% X: q
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
6 i) E- ~, E2 v0 x% O/ G4 j        return res;
# }3 k3 E% t1 _8 G' D}
0 j- Q9 b( \4 s) c) f  ]
3 U$ i' _5 F$ |, C  S$ d* y
; A1 [1 m, ?7 G: H& l) P6 B# e" K, F; M; b
/ Feb 26,'06 R0.00  Prototype.1 b# r# z$ a; Q" m8 x
/
: z- x/ J: t' U; t& ^/ w( |/ Apr 29,'06 R0.01  First stable version.
. K& V1 s/ ]$ `4 A7 U5 ?. q/* y% q- p! l( @% Q+ `
/ Jun 01,'06 R0.02  Added FAT12 support.; x; L7 V8 [: t3 g; G8 b7 ]
/                   Removed unbuffered mode.
. N' v4 x* A) f$ d# Z/                   Fixed a problem on small (<32M) partition.6 p, Q2 N, C9 T9 W
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
9 F- d+ {! _) P1 q# v5 Z+ d6 V/9 Z/ b" ]3 ?6 T* s/ v& u9 g
/ Sep 22,'06 R0.03  Added f_rename().
& }; n; T6 r* e) S6 b/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.7 W( q8 s1 _! P! k0 z  I" n
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
: A9 m* c& ~1 D# y9 l/                   Fixed f_mkdir() creates incorrect directory on FAT32.( |( k$ |* L" k+ E$ L
/3 C6 M3 Y/ ^3 ~/ R
/ Feb 04,'07 R0.04  Supported multiple drive system.2 b$ G) w( ~7 z. a. j" n# H
/                   Changed some interfaces for multiple drive system." g" T5 F) W# L4 H7 }& D9 }9 _
/                   Changed f_mountdrv() to f_mount().. R) o  d5 X* {; K& P5 S* i$ a
/                   Added f_mkfs().
& v( j2 O! R0 T7 ?* G6 n/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.3 V% W1 H3 ]4 J& A$ D8 `( r4 ]. C
/                   Added a capability of extending file size to f_lseek().
. u9 x% H1 @$ C: ]$ w6 y) ]; h+ \+ u/                   Added minimization level 3.$ X  l8 Y0 U* h5 n$ N* D
/                   Fixed an endian sensitive code in f_mkfs().
5 e* ]1 P% U2 J, d! n1 ^- G/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.2 }# r/ H$ D( P, ~
/                   Added FSInfo support.
; P, h/ t1 h& S/                   Fixed DBCS name can result FR_INVALID_NAME.. }1 o: R* f" G7 L7 M
/                   Fixed short seek (<= csize) collapses the file object.
' ?& t  ~* }- O! L/5 A* _. a8 b+ X% s0 @
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs()." N( a5 ]% n5 T# k2 R* b
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
+ g0 U5 v3 D2 n: H) J3 z  {8 k/                   Fixed f_mkdir() on FAT32 creates incorrect directory.
" B6 ~+ ^+ q- }/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().$ h; \& N9 u1 r, w" o/ \- ~$ }4 u
/                   Fixed off by one error at FAT sub-type determination.! E- \4 t! G* F0 z, V+ g
/                   Fixed btr in f_read() can be mistruncated.- v* a* I& W! P) P% W0 o: }( M4 X
/                   Fixed cached sector is not flushed when create and close without write.
9 t9 ~! X# Q$ s& u! [/+ X, A+ }; j5 _" Q
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().* [" `# s9 i0 H& Y
/                   Improved performance of f_lseek() on moving to the same or following cluster.  @# {% h; z* U; \5 j6 h
/
3 k, {1 O2 H( J, }6 ]/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
  b) i& k) p5 t) c. K2 E: p. F* f' M/                   Added long file name feature.2 d; N" K6 U' f7 J% ^1 N/ u
/                   Added multiple code page feature.
2 u, q( @$ }3 D5 |! c5 Y- j/                   Added re-entrancy for multitask operation.
* v  y0 W! N) |3 `* L* G2 A/                   Added auto cluster size selection to f_mkfs().; t: V. N+ S5 p; p- d- \' s  k
/                   Added rewind option to f_readdir().
- B+ G# d; b6 b* Q' G" W/                   Changed result code of critical errors.
: C+ T, ]% C% e' B" D6 [/                   Renamed string functions to avoid name collision.
' E0 q0 h, l6 A' s# b) P6 H/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
+ i* D1 [" j# c& c+ `* G/                   Added multiple sector size feature.
* a6 V6 z: t( K' Z* F/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
, O( e) N! X5 C- }" t/                   Fixed wrong cache control in f_lseek()., W7 J' b, b/ n: t( x2 @
/                   Added relative path feature.
( E% y0 Z, b( K# |: a  l/                   Added f_chdir() and f_chdrive()./ ?# m+ M& a# H7 d$ _
/                   Added proper case conversion to extended char.! ?4 @( A& @! ?% q4 y3 |: _+ [
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.& o) s2 W% x) D% t4 u  i0 E- ^
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.1 i5 p7 G) i  h4 B
/                   Fixed name matching error on the 13 char boundary.* c/ `  @3 J% o# M# B
/                   Added a configuration option, _LFN_UNICODE.$ c7 y9 Q. s  O" H& s: u" O
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
8 B5 j$ W8 f& N( }" C5 G2 m/6 N0 {- T0 K% \; \/ R: a
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)
; q7 ]! _2 G  Q$ b5 T1 _) {" W3 L/                   Added file lock feature. (_FS_SHARE): R& l* `0 F  l
/                   Added fast seek feature. (_USE_FASTSEEK)
( b: n! H' F: _2 C/                   Changed some types on the API, XCHAR->TCHAR.
2 Y6 b' z+ Y. a" W/                   Changed fname member in the FILINFO structure on Unicode cfg.
2 @' I8 ?; {$ y/ S% W9 W: r1 r/                   String functions support UTF-8 encoding files on Unicode cfg.
" r% ?5 i* O: A) }+ P1 \/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)$ X& Z2 ~8 l8 x0 e. S
/                   Added sector erase feature. (_USE_ERASE)  q- y- ]& U# Y9 D* _
/                   Moved file lock semaphore table from fs object to the bss.3 n/ S+ Y* |- j
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
6 _0 h# _  }1 i- A$ X6 E4 k/                   Fixed f_mkfs() creates wrong FAT32 volume., o+ Y* p2 l) |2 [8 K4 e
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().  T  o6 k& ~( q
/                   f_lseek() reports required table size on creating CLMP.
- ^" p' Z2 Y# |/                   Extended format syntax of f_printf function.
9 ]9 o4 m1 p- s) T' _/                   Ignores duplicated directory separators in given path names.4 [  `3 B( j/ ~; @/ _+ c5 `
/2 O* h0 Z3 R: ~( I  N, ?
/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
; ^: C& f$ c2 A: v- l/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
/ z7 ?% O: X8 H' b8 X) A( g/ S) h, t/---------------------------------------------------------------------------*/) |; }. F: k* s* f6 M% {
# I. p, [8 j: _/ a8 n5 M

STM32的SD卡FATFS.rar

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

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

211

主题

652

帖子

1507

积分

四级会员(40)

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

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

本版积分规则

关闭

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

巢课

技术风云榜

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

GMT+8, 2025-5-25 18:40 , Processed in 0.063573 second(s), 34 queries , Gzip On.

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

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

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