找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1382|回复: 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工程。下载即可使用。
, O. v* m/ S0 J3 l7 h. h5 F) ~- c/*----------------------------------------------------------------------------/* X3 @% |( H  U+ L, a$ r
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 20111 j  N9 p$ z$ H5 ]; _4 H/ W, k
/-----------------------------------------------------------------------------/$ g; `; O- N  y; t% g
/ FatFs module is a generic FAT file system module for small embedded systems.. h$ i& b+ j. d! Y% }% u
/ This is a free software that opened for education, research and commercial( K- l0 h5 @* Z5 J
/ developments under license policy of following terms.; P" @' t+ u% i/ e" u
/) Y; T/ Z% d7 Q2 A- J; T
/  Copyright (C) 2011, ChaN, all right reserved.( R# c' Z, `: H1 h1 w2 s
/# S8 J; H1 @# m; |+ O0 o* ]
/ * The FatFs module is a free software and there is NO WARRANTY.6 m. ^' K4 p( e6 R! L2 ^1 G" T
/ * No restriction on use. You can use, modify and redistribute it for
1 Q0 B  L4 n" _' ]5 e' b, }/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.; ^' t/ Z- U+ |5 H) n/ z
/ * Redistributions of source code must retain the above copyright notice.' I5 w1 u) J. I4 @( z6 B
/  K, m) B0 m' p; O
/-----------------------------------------------------------------------------/
- }3 h4 l9 O! x$ P0 y+ \1 B# G+ _- F4 W* V1 g

5 P3 Q( f% _0 \& _/ T8 n/*--------------File Info-------------------------------------------------------
7 ]9 M4 G8 e2 W** 文   件   名:  FATFS_Function.c( t! ?- T+ D1 ^. M
** 作        者:~风中的叶~    整理
2 G, u# W6 |) s7 V5 B** 最后修改日期:  2012.01.181 J' w; t  \7 L* }7 u) I
** 版        本:  V1.0
$ b0 `6 G) \+ I! \2 e( L** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出/ v; ~# V! v1 z( F2 b# w) c
**------------------------------------------------------------------------------# Q: Z1 J2 l" j/ c4 P, U
** Created   by:  Dt.
4 u: J. Y. D4 \! U** Created date:  + y& i& g; V- ^) a5 q. ?8 F! L
*******************************************************************************/ " Y. T, a6 K' _! z( q. h5 R& o
#include "TEST_FATFS.h"2 {- s" \; I% A$ p' n( A" c3 I9 Q  \
#include "string.h"
( z7 b4 `' C9 S' w/ h$ [% u- }( |( ^+ _# r) K1 \
#ifdef TEST_FATFS_EN8 W6 b1 S' f1 U! [& ~. V& |: P* a2 z

0 K; p* i7 E1 s! l: M! _5 _7 ~; V. K- O) W

. |. u/ N( _( y- k//检测磁盘是否插好
+ P. e) K4 {: b" hBOOL disk_detect_OK(void)& R1 O! y; D$ Z7 w0 F
{" O( \- t& z1 S- H- }% @# w& \
    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */
# P+ L9 J' b' I- p3 T& s+ [        {4 m1 f+ e) J7 `+ ]( u8 u0 G
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
- z: Y( e1 m- j4 H- I3 D                return FALSE;. x3 o( u) l3 R, c
        }
1 z) W1 f; N  h7 s. b9 }5 a5 n        return TRUE;
; ^& W- d- d2 M}
) ~* ~% }; ^) h* e" _3 M5 H* V% U) X; T( \
5 c& B1 ]- ~7 B  s
/ M, E0 y4 j5 n' z3 q2 N
//测试函数执行结果分析7 j( P; }! L3 E* G8 q* [. d7 A
void die(FRESULT res)
  M6 x; V5 R0 ~1 R{
. L$ l' J# h/ g3 Z, I    switch(res). M9 S$ V$ y8 v8 g1 _  w- c1 g
        {+ h( I4 v  h+ d. q7 h6 ^( O' C  x" I
            case FR_OK:        //The function succeeded. , t# X( z- v' }9 S- _, O+ m
                {
1 d* p8 s! S' `- p. e, f1 A& g) m                    printf("\r\nThe function succeeded!\r\n");* ^" t2 u& [$ Y( v! \: t% |
                        break;+ C" b% v+ z9 Z. Z
                }
0 P. ?$ p! D. G% P6 ~9 K3 y# Y  b                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason( |* O' d! Q2 @* d
                {
4 p) e$ _# N' Y* ]  _) g                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");% G2 y/ z7 I# |' r+ H1 j
                        break;
( [8 U, v- }  j# C                }& ]: {0 A9 L) [' Q0 {
                case FR_NO_FILE://Could not find the file.
6 j) s; I' i8 \                {- C, |( _( h+ w; r5 q9 ^
                    printf("\r\nCould not find the file!\r\n");
  ?( Z5 x- V0 q& T) m                        break;! I) c/ k) W) w4 `; C. W
                }, T7 U1 `  f4 d& p8 K7 c9 ~6 G
                case FR_NO_PATH://Could not find the path
! U9 j* N! @* }6 g1 T7 l/ N                {
# j( j. p2 Y) O! N* c2 }, U                    printf("\r\nCould not find the path!\r\n");, k* }+ C+ E( O
                        break;' X& @/ X) @3 ?+ b$ O
                }( l& m4 S" S- v4 O3 E- t$ a0 ^8 M
                case FR_INVALID_NAME://The path name is invalid
3 C6 K, j$ f, p# O" C' [$ z                {, L+ Y0 q3 m. e! i
                    printf("\r\nThe path name is invalid!\r\n");# y4 u' I- k% @1 |& Y- v# Y
                        break;
( }1 G. [( ~7 s3 e' T* N                }, \# G% f* F9 a
                case FR_INVALID_DRIVE://The drive number is invalid
6 j  z! a0 f* M" |" c& `                {
: g" z6 B/ k, U' {: f                    printf("\r\nThe drive number is invalid!\r\n");4 N0 O8 ?  t2 P, L# N
                        break;
2 u. Q) S/ g/ q4 ]9 T                }1 I2 V7 D6 }5 Z+ f  S
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. 4 q. r$ b# k; x2 c, m. B
                {
6 l; H9 F$ k, Z8 R9 w  ~3 P                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");0 f: l9 h. y$ u* }& S1 t/ B
                        break;  ]3 h3 d; G% M$ M% ?3 P' [
                }1 W8 r+ x5 g' @! t3 w
                case FR_EXIST://A file or directory that has same name is already existing
( u5 r& h* A$ ^  C8 R6 P' f% d                {
7 i" n( @3 X$ ^                    printf("\r\nA file or directory that has same name is already existing!\r\n");
7 a9 Z& ^  L5 }  z0 Y( K6 @                        break;
; S8 `1 V9 t" d5 o3 {6 m" h                }
: ?& y& j3 M6 C& I/ j9 d8 ^& P//                case FR_RW_ERROR://The function failed due to a disk error or an internal error# @8 z( [8 c4 n/ L) E' U+ a
/*. I8 B7 N! y) N+ {
                case FR_RW_ERROR://The function failed due to a disk error or an internal error1 S- h$ a  a9 z* i3 f# {
                {& {6 y( ^: t0 R1 t3 B9 f: D
                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
: {* F/ h: p% b' m                        break;
" x; F( D, }& T  \                }
! r2 D( v2 _/ y. p*/5 d4 r. @+ D5 U1 @9 q' r$ c1 ^
                case FR_WRITE_PROTECTED://The medium is write protected1 h& F( q+ O. W% E# l$ h
                {0 Z" g, l; ^# _# a/ Q9 R$ W3 |9 n5 M
                    printf("\r\nThe medium is write protected!\r\n");
) p& J  ?5 D; w7 b                        break;8 E1 s, W. J% Z- X- ?6 I7 P- W
                }
4 n7 J, Y2 {4 o; r5 u* E+ a( Q/ a                case FR_NOT_ENABLED://The logical drive has no work area
6 F2 c1 n; B1 w- K                {" ~, t. T3 m. \  w; w
                    printf("\r\nThe logical drive has no work area!\r\n");6 E6 O( X( K$ _* k7 X
                        break;; h5 e! _0 ]- n# Z
                }2 T6 _4 j8 J; ?3 o
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk
, q4 ~6 r, j4 Q9 ]: L                {
5 U5 ]6 }) x  w0 J% L8 O                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");& M8 S; [7 j( P/ l* W9 ~
                        break;
- t2 x" f9 K" U6 j" p) y* E                }* g7 c5 K2 B9 d* P2 W
                case FR_INVALID_OBJECT://The file object is invalid* K& ~- M  ^9 C, {6 F7 h1 _
                {4 s' w3 A+ _' |" m6 N
                    printf("\r\nThe file object is invalid!\r\n");
5 Z% F% [+ H6 {, ?+ z6 k7 f- E& B                        break;
) v6 I' F0 n, y# M) S                }
' J8 @3 ~# J5 ?
* [) J  d* [7 u0 `- g            //The function aborted before start in format due to a reason as follows.
- g6 ]7 M! ?( \' x        //The disk size is too small. ) M4 Y: y, P4 ]
        //Invalid parameter was given to any parameter.
" \0 U' o) J! ?$ G2 u        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
) ]2 m" h0 S* U- x2 m                case FR_MKFS_ABORTED://" O# X  n# E2 a
                {
5 g6 C- w8 M7 p2 w0 L1 X                    printf("\r\nThe function aborted before start in format!\r\n");5 a5 e& ]: d. y: n
                        break;+ f* |0 B' M% m' E/ x
                }
0 P! |% K: j( D# A3 G               
( w" a) H" r2 [' x) u                default:6 C  j  W. i- I* y  x8 Q
                {
6 E- g% g# G- D7 Q7 z( x9 ?                    printf("\r\nerror!\r\n");
3 \$ @5 n* `  U: d, c3 q0 A8 v" |( [                        break;2 \0 b+ ?0 {) z! Y- A" X% D
                }        
" V$ V- R- M, o+ y* k" m        }1 [/ l5 R  \2 J; ]
        return;
! D' h  U: @# p}( u4 y+ k8 c: y& k$ D
void Test_f_getfree(void)//获取卡的总容量及剩余容量: r6 L/ ^; q5 \+ o. k% V9 `0 P
{- }. d( w$ b1 G6 S& B* F
    FATFS fs;
  g+ m, u, n0 L, g( g0 A; M' U6 x        FATFS *pfs;
/ ]- I3 |1 P1 `; V4 x0 Z, p/ e    DWORD clust;% X1 q; K& W2 g7 P* \5 p4 }
        FRESULT res;         // FatFs function common result code
, E$ T" F. K# n' m4 L4 }, d& L! Z9 z5 B
        //检测磁盘是否插好
# G1 K: D3 W3 J- c* N1 c        if( disk_detect_OK()==FALSE ) return;6 W6 d* [) _# R& b5 p( f! ~
; v9 `4 A5 F% R( N! l
        pfs=&fs;//指向# i5 M0 q8 a9 K) ]' Q: L; t
        // Register a work area for logical drive 0
; h4 g: x4 f, _! M8 w  D    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间$ }& t) x6 N0 @0 O8 x3 ]& N

5 J6 R/ x* B; k5 e    // Get free clusters& |8 s# y/ Y9 q; i9 _
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
: `3 u0 e2 e" v: o* q- ]- i    if ( res==FR_OK )
2 g& s; ~% f; {; ~2 q* s# \    {# ?0 L0 i# k3 l  a: X
            // Get free space0 B' o9 O9 ?  [% x
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
9 t0 [$ H) g9 Q: T, H$ T0 S                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
2 e% s3 O# Z+ g$ n( n2 s                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
, k8 |& N/ M! q% o& {! W% S8 K1 S        }& W5 d$ Q. ~/ ?( r( L1 ^0 @
        else die(res);//测试函数执行结果分析
7 k' B( T! ?4 k8 f9 m        / @& J0 ?. i) [( c# _+ Z& p; e' v
        // Unregister a work area before discard it
/ I4 @/ a1 K9 o4 d1 n5 I/ _    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间9 [: m0 W0 a! P2 S# y# U
}
. H- T: P$ l7 Z+ D  [9 I! l$ N  r' L  \9 \
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误
2 @" ?' B+ x, p- w& s1 @{
9 ]5 K' u/ U& }' A    FATFS fs;            // Work area (file system object) for logical drive
; _% s! m  X& A: k+ h    FIL fsrc;            // file objects
0 T; b! o# ^0 Z' q  Z; G( L/ q" |    BYTE buffer[512];     // file copy buffer: |& l) c3 k9 P
    FRESULT res;         // FatFs function common result code
$ D* h! ?& R' T' X$ J0 d" H    UINT br;             // File R count
! F, a  z- g, O        u16 i;
9 c& u* B) h/ @, P" ~: B        ( t8 m5 x" B% p3 C

+ y7 Q5 |2 ~9 W) Z. a" y; |        char path[20];! b4 L' p$ S1 b

2 F' V* h5 p) P2 a9 E/ R% d        //检测磁盘是否插好
: q# k6 I; P- V; L6 ~! {9 @2 p        if( disk_detect_OK()==FALSE ) return;
! Y/ j- E% v% X! V3 H3 b/ e& |* v2 S8 D# H
    // Register a work area for logical drive 0
: u5 o. s: D: v8 N3 Z9 e    f_mount(0, &fs);
6 z& A. B$ y5 c* z, R( |( `* l6 o. i0 V) n- ^1 {
        printf("\r\nread file:>");2 @7 b$ \. y3 D* [7 X
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
6 t# ^* Q/ b& R& h2 m. L% E3 z1 F5 q: n8 r$ I
        //Open source file
# D5 I8 N2 `2 S: f/ {/ g    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误; Q8 L# L* E3 [
        die(res);
5 l: M" W0 o. a        
- I) W. i, a- i+ A1 M        //buffer空间设大一点,会提高读的速度。8 P8 B: F* _/ n* s
        //如果文件实际大小512byte,3 }. U# L- s% w2 x* z- M% d3 Y
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。7 i! \. v  F3 J( m: J+ B
        //下面两行主要是去除1s误差。
  o. ?' L( u3 U' V& L5 Z& I+ S# a1 X/ x" ]
        for (;;)
; v" W. w5 m% R8 E        {! k, b& h" l* F" W/ m6 b
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存  u5 E# `, [+ K8 R, u
, J, k5 y, R; w8 V( H0 }2 O$ }; E: f
                res = f_read(&fsrc, buffer, sizeof(buffer), &br);8 D4 h- e$ H. q4 c3 P$ A
        if (res ||(br == 0)) break;   // error or eof        
1 i* P( T% ]0 ]% A7 ^4 P& r/ g                / h9 z2 M% T, V7 q- v, \) Z
                printf("%s",buffer);        / |7 a( ~& q  K, b9 n/ T! ?6 h) T# n
    }
: c. g) Z7 b! }( s% v6 ?0 \1 b) q! X6 t3 G  E& y7 T. H: P
                            + f9 }3 h  m; X6 A$ N/ [9 S
    // Close all files3 @4 \2 a+ v% `* l
    f_close(&fsrc);
) O( M0 ]( m. t' ~  A% c, g1 \. F    // Unregister a work area before discard it7 O% E+ C7 Q5 O: ]
    f_mount(0, NULL);) ~( Q- l# t5 l" Y* J* J. s0 x1 E1 |
}
+ f8 B! I! w* m0 s
  N& f2 @) D/ N4 n6 }! d( y* Mvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
, E" `4 F; a- V{
7 A4 [' s  S8 U    FATFS fs;            // Work area (file system object) for logical drive
; j2 b0 d; J/ g2 X    FRESULT res;         // FatFs function common result code
' A, p# |4 D; j4 y! V8 G1 e        FIL Make_file;
: y" ^  _. @" t" g' O    char file_name[20];
7 B3 ^# f" l( x$ @    char Storage_buffer[] ="0";" m! L/ ^) t  y  f/ |
        
, E& H2 A* T3 H        UINT bw;
+ |2 L) J' n5 Z- I6 E: u" @- u        //检测磁盘是否插好
8 T+ P7 v) R/ a% W        if( disk_detect_OK()==FALSE ) return;6 \9 ]3 t( j" {. `3 Y
         printf("\r\n inaert_ok:>");7 F, h5 D4 y( o) }2 J
    // Register a work area for logical drive 0
' Q: }6 J" n* F1 O1 x4 x    f_mount(0, &fs);" v; i1 x; }! B0 O7 R7 H

" \7 ^( a! m: L. k. N        printf("\r\n Make file Name:>");
  h  @- g( l: v. }* r* _        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt# ~' s2 v0 e2 J  t. O
7 h- ?" s: @8 M1 D
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
" {0 b* {8 q- `1 f1 s: e/ b         printf("\r\n open_ok:>");
6 S, s- u; {" {         die(res);
# H- N; t0 Y# u8 `$ H8 n    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
7 F( ]2 ^9 N4 f/ ?- }      printf("\r\n seek_ok:>");2 {3 w' f- p7 V+ k1 j
         die(res);
) [: X. Y- l* @# F# r; _        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
6 N9 K- a+ f* D* B' m% O     printf("\r\n write_ok:>");' ?2 B! Q3 u7 W* r
         die(res);/ f  U0 [: v7 b& ], X: T: x% `* O
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
7 ~) M- t) A, p6 f  n        f_close(&Make_file);//关闭文件
) X( Z% l3 w; X- W$ s; ^        printf("\r\n close_ok:>");1 q* F& u0 ?6 Q
, n- \5 `6 N9 N2 I- R; X. x
        printf("\r\n写文件测试OK!\r\n");
9 R+ C0 C! ?- ?' V9 t. U! U+ R: R' K$ T1 ~6 m' r% W" L
        // Unregister a work area before discard it% w+ Z# b* O- n1 t! R! d
    f_mount(0, NULL);
0 a/ o! w; `: `- z: M5 ^}
& l4 c$ H  }  c* A7 q7 t9 K  H$ ~0 k5 q
//The f_read function reads data from a file.& f$ h7 l! S* l+ i# T
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
$ ?' G+ u: j) z$ ]. g5 w8 s//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了
. p8 a9 d( T, A  o  u, n( M//所以以后要特别注意这个问题。
1 y8 N# y# a  ?& s" _, C4 A+ `0 W  A; p5 h) i
u8 StrToData(u8 * data, u8 len)
+ ]" ^  N3 Q# _+ ?$ J{1 ?) @2 c- M; q3 `- S, p
        u8 ltemp;" \, b8 Z/ F% X- e; j
        if(len == 1)0 b, u, O. z) _% H
        {
- S; B' P4 O4 K* k# f5 |                ltemp = data[0]-0x30;
. `) i% T0 w' `+ O) y- F2 f( G9 S6 L; p+ \2 S3 t8 w! S- V, g! y
        }
* q. z- G7 [! e- a        else if(len == 2)* H2 b: ~9 M5 O. B. z! W( f4 k
        {5 V2 e1 L% A* r9 E
                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
0 E. `: C3 |* T+ y: {2 T9 D& ]  v# u/ A
         }
+ C# B+ x/ ~, Y9 ?8 v$ B8 z        //else if(len == 3)
7 b; V. s, H, d; Z; U                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];9 P0 h4 S2 \- t# l( u! v1 D
2 C$ ]3 D( y/ v% F, e5 a5 X
        return ltemp;$ f+ X0 k4 p" B0 W# h
        
! c' Z" x  F: e}! Q  ?9 O/ c9 b# B* n8 z! ^6 {
4 m6 B# b6 p0 y3 X4 I
8 T6 J% G; |; O
#endif
8 P1 n1 l  d) x/ I' L
' T; ~: P  Y: d& i+ P0 o- k$ Q( Z. n- K4 N, z
/*
1 v/ s; {8 A2 k( q" E1 _int main(void)# y3 I) A# L- m/ I! L0 U& _5 g
{. X: s8 `; O7 V: O7 a! F
///////////////////////////////////////////////////////////: e4 U8 F; n% I' Y9 _' m9 y" O- S
UART1GPIO_config();//串口IO口配置' O2 w* Q  J3 j7 `- I" ]1 p2 g4 o
USART1_config();//串口初始化波特率为192008 R; h' e; R  a$ Q" c
//UART1NVIC_config();//配置中断: ?( P& E) k* m& q7 H( w
///////////////////////////////////////////////////////////
7 V( I9 n1 @) i5 Q( ?SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式0 ~. k! _/ V! }3 E8 L% t# \( \
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
" B' l7 z# k8 I7 s7 c  l8 RTest_f_getfree();//获取SD卡的容量和剩余容量2 u' d9 D) k) d/ Q7 @
Test_f_read();//SD卡读文件测试" p) z0 f: q$ l
Test_f_write();//SD卡写文件测试
4 N' C5 X3 O. R8 O0 C3 V. ~$ y///////////////////////////////////////////////////////////
4 e. B) t9 e9 u    while (1)
, Q  _) l) \& s: y8 c! A    {
. i8 r4 v3 P, X3 c$ e! d6 {1 V$ d3 O        //printf("好的");5 l8 f3 E. |# [" H
    }" `2 d  T( F7 \& Q  |$ F& l* F' `
}*/  ]5 S5 z( e( V9 c2 G% Y1 d
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- x" y2 W/ l, c2 d  G: YFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0+ \5 ]2 N: p6 \' t/ S1 x, e
{
+ ]3 }: j3 Y* M8 w; |8 C' t; r    FATFS fs;            // Work area (file system object) for logical drive
3 G  j& [  _* D6 s& `* q. k* G    FRESULT res;         // FatFs function common result code
( p& p$ u7 R8 u9 R
" Q) V/ O8 z1 q& i' x" U        //检测磁盘是否插好2 @# y1 K( q4 D2 X/ D: h: o
        //if(disk_detect_OK()==FALSE ) return ;! N6 L, z/ e: ?
        //printf("\r\n inaert_ok:>");
* s# M+ Q* K0 ?5 ]6 C9 Y        // Register a work area for logical drive 0/ E4 i! h8 E: F1 Z; r! S1 Y1 L- c5 l
        f_mount(drv, &fs);8 i3 v' s. z3 J  D1 t% L
        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
1 t! P1 V7 B% F& ]! j- X& U0 U        //die(res);3 E! z0 O3 w, q5 B7 ~: v9 X' T1 u
        f_mount(0, NULL);
( Z, e8 i+ m$ Q' W0 G        return res;' I  N8 c0 q! \: _9 A
}5 N6 @: l" H' X2 @2 }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% |; _. p( N3 {  [9 {
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        $ q/ F3 \7 C& [6 O) d2 S# v
{
: x1 y! k, L% d2 B+ d    FATFS fs;            // Work area (file system object) for logical drive
3 e9 V" C: G4 g& x6 w    FRESULT res;         // FatFs function common result code- T+ \: @0 r+ c( h( S  Y# S9 K
. U8 J/ G% ^8 M, y. @) G
        //检测磁盘是否插好1 D) Z2 \. Q% Z0 m" }
        //if(disk_detect_OK()==FALSE ) return ;4 Z* ^! l# p# A+ G, o3 o
        //printf("\r\n inaert_ok:>");
  [. ^7 k8 ~+ F9 m$ J        // Register a work area for logical drive 0
$ o' r2 M  n& I3 d( _: Q        f_mount(0, &fs);$ ]+ H9 T4 t5 k2 h& X
        res=f_mkdir(path);//创建一个新目录
1 x3 [) y0 ?7 |        //die(res);) T( [1 V$ _6 Q6 B* X  ^
        f_mount(0, NULL);
* d2 `; M& ^' F8 A5 |        return res;
! k" r# M$ ?8 r; ~) @1 _9 V  e}. J: \9 n4 s( O' `
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////4 N2 h" J7 e* ]5 r% U: T
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        
' `- _; X3 d0 E7 C2 A% O  {{
3 D, M; n3 B; e. o    FATFS fs;            // Work area (file system object) for logical drive+ h1 O, {7 m2 U% O! q
        //DIR        dir;
  l! v8 f% _: v; h9 o    FRESULT res;         // FatFs function common result code8 I  w' z6 ~& Q5 Q
2 \( d: F' z) k
        //检测磁盘是否插好) k: P3 _; t: l2 N
        //if(disk_detect_OK()==FALSE ) return ;
1 |$ O9 G0 g! m- k6 |9 n        //printf("\r\n inaert_ok:>");5 L  J3 O7 L3 X7 r, {
        // Register a work area for logical drive 06 ?) |/ s' @; c* b- g7 n
        f_mount(0, &fs);
& `: b: X! m0 ~5 G& M7 ~* K9 C- ]        //f_opendir (&dir,path);/ I' v. }, N, V, e; ?+ f1 v
        res=f_unlink(path);//删除一个目录
) ^' C% C2 x! d        //die(res);, ?+ X, Q9 V) h3 n
        f_mount(0, NULL);
  l7 J" ^& [+ c+ }        return res;' \4 O8 i( I6 W- x- T% U5 j1 b" R% ?' w; `
}7 P8 Z; l) c8 t
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////: n. f6 t& E& ]" }3 O
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        1 Y6 {* F- D2 q, g7 c9 I6 `
{
1 X  p  U8 P, G8 d    FATFS fs;            // Work area (file system object) for logical drive) u: q9 o: h# S% M, f! M
        DIR        dir;0 f' B" v. G  u7 R
        FILINFO finf;
4 I1 ]5 w* k, @1 J/ u. F    FRESULT res;         // FatFs function common result code) J& _: K  W) l; o0 M2 Y( Y
( }  M! G0 @5 P& ]
        //检测磁盘是否插好
7 M4 C& y6 q2 Q" A/ ?: I; S2 U+ C        //if(disk_detect_OK()==FALSE ) return ;0 ^1 P3 y$ F" S6 s
        //printf("\r\n inaert_ok:>");' y7 j! j: o- J8 T
        // Register a work area for logical drive 0' |) u0 C5 C+ M7 z" \
        f_mount(0, &fs);, U7 @: _; e& |- `# z  n* ]
        f_opendir (&dir,path);2 g0 m% y3 u+ W5 E9 ~

& Z  z2 s; i+ U' U: r% Q% \        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        1 F1 ^- }  `8 Q: J; `( S9 L
        {strcpy(*(filename++),finf.fname);
6 Z* h$ S9 J$ w$ |        //printf("%s",finf.fname);
) F; |- Y! |& R9 p  N$ K0 `        }
/ Q' F/ E# t& ?' P3 \* U* p% V1 Z        //die(res);. N" j# j; h3 O
        f_mount(0, NULL);
+ R" x0 G6 E. ]2 ^        return res;
* i7 T- v0 b/ e: A% v* F1 c' b( y}) B7 a8 E3 k4 ^7 r( P
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
2 {" U. t$ [* K( C1 [. uFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名9 I; H& g) `4 `, n  _  N
{
9 J4 Z5 P8 l$ a0 U    FATFS fs;            // Work area (file system object) for logical drive3 }' S+ D. {' i5 Z8 A
        FIL file;# m; @# D* M  x$ F) E, U8 }
    FRESULT res;         // FatFs function common result code; v" ]1 p+ h& h
( F) Y, ?, A; [: ~7 Z; }
        //检测磁盘是否插好, c0 }# v' C7 j: v) y6 y
        //if(disk_detect_OK()==FALSE ) return ;: X0 Y5 ?2 ]6 d  _3 S/ r7 `0 Y: S9 t2 u
        //printf("\r\n inaert_ok:>");* s2 n1 _# `4 J% f9 U( @5 }. w
        // Register a work area for logical drive 0
; B' T" k/ ?, ~  w( k5 p+ ~        f_mount(0, &fs);
/ q0 ]" J0 |# T5 {        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。6 L5 p' a  v, F2 d3 ]4 v6 ]+ @
                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。! v3 y$ h' H' g0 f
                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。7 x9 e$ k# ?3 q6 y
        //die(res);
; q( C) R9 k0 N" x        f_close(&file);//关闭文件
! @3 K4 @1 d9 |# L4 j        f_mount(0, NULL);- O2 q. T4 P9 N
        return res;
" u/ S" l0 S2 B/ e0 I, V}
: B" ^! O4 ~& y, |3 |////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
; m; U1 A1 x& Q7 h  g7 v7 w4 _; YFRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
* `' h1 ^% I& h! \: H4 D# F{
- Z# l$ d1 A. [2 e2 _( W, K    FATFS fs;            // Work area (file system object) for logical drive
2 Q+ P5 K. ?* _+ W3 Z3 p+ L( M        //DIR        dir;# ~% f% f# g4 s3 A; ~
    FRESULT res;         // FatFs function common result code$ H$ I/ ~* K- x% M- ?, X
& \, ]% Q1 `: s2 D
        //检测磁盘是否插好; Z5 G/ _7 ~  M" b
        //if(disk_detect_OK()==FALSE ) return ;6 N! {+ \1 c3 ]" t  ]' N4 Z
        //printf("\r\n inaert_ok:>");
: a" B( J! Y! v& M        // Register a work area for logical drive 0
  ?1 `9 \( g6 j4 ~* c        f_mount(0, &fs);" u  F1 w( J: l
        //f_opendir (&dir,path);
* \4 e2 R0 P( ^: I6 y( t' E& F        res=f_unlink(path);//删除一个文件- J/ L, t; e5 M3 T% ]5 L
        //die(res);8 y( W7 ^2 w: y. P8 B4 Z
        f_mount(0, NULL);
7 O" c" _* M4 O' A! Z0 L( K        return res;
' d# @  I1 A4 d) g/ x  c}5 S, m" |( w2 L5 L0 Q" C0 ?- O
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////: H, x: ~; G* x) W/ n
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数
' A& N) w4 {3 ]5 v+ w6 K{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));% _8 Y5 ~% v9 m. i; Z! R# Z$ y0 a
    FATFS fs;            // Work area (file system object) for logical drive$ Y9 O+ C: p4 [
    FIL file;            // file objects1 c+ d2 @8 b; Q$ F% L5 a
    FRESULT res;         // FatFs function common result code
3 R) \6 ]$ m, v; X  W    UINT br;             // File R count 文件读回的字节计数  {# j/ s+ ^( D
        //u16 i;5 q$ B6 |4 M; W. a9 t2 a
        //检测磁盘是否插好1 G. h1 v: C: Y/ n0 m  L* z
        //if( disk_detect_OK()==FALSE ) return;5 f* k. g5 H7 x
    // Register a work area for logical drive 0* ~1 ^. Z' G) I$ {4 P0 v
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';2 {3 S  T" ~" D& y+ F/ D  J9 t2 L0 q
    f_mount(0, &fs);
! O4 M: ~( g* [! V3 V1 q: u2 ?+ U        //Open source file  v  b& B6 d0 e' @/ M7 V
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误: v: C  Z* d' S: L; S- M
        //die(res);: u3 A8 ], m4 j" F- ~0 K6 U
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
' D" m: d+ Y; A4 \& J0 e        //buffer空间设大一点,会提高读的速度。
9 i  Q( R. y) G/ Y8 \3 _7 P0 [        //如果文件实际大小512byte,
/ d9 o3 h8 \+ ]  {7 b        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。6 n. }6 u5 a: y; V" U0 L
        //for (;;)   J. w; s- Q( k, S/ l+ a
        {
! p" Y' [! X( O: K3 B8 G" v                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存/ F& L- K; Q7 E6 ~2 w! E

7 O1 M) K& q& `: |0 z: W( f                res = f_read(&file, buff, strl, &br);# v8 R, k  ^* R; {# U
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出
- t9 U5 P& s+ Y  W& ]7 }* A1 `! L8 U                  a. q! P8 H, I+ _, V2 N* c
                //printf("%s",buff);        0 T- M! V4 _8 E" v; {  [  |9 w
    }                    
/ `. Z3 x& e3 i0 K$ _( P( l' }    // Close all files
! W1 _5 ]0 }9 k2 {6 V& \7 X/ r    f_close(&file);8 U8 u! V! n% W( n/ u! a
    // Unregister a work area before discard it; V, x! ^( ]2 a3 d/ g
    f_mount(0, NULL);
/ m! d- V2 r, P  n: I' a4 L        return res;0 E- Q' T# m: s8 Y
}4 ^3 K3 F  p& U. T& g* e9 R) |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8 x% z, M+ L; G  ~  C8 \3 y  l" W! w/ }
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数9 @% L& k& N- g! ^8 z+ L
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));1 a6 h* Q- n2 l/ W
    FATFS fs;            // Work area (file system object) for logical drive1 O  i$ N) i) i: e) }
    FRESULT res;         // FatFs function common result code
5 p: E. g7 c. V% Y& y% Y% n! w9 I        FIL file;- U( f. k* W( Y
        UINT bw;             //文件写入的字节计数" Q( v9 S# F$ O. y1 D, S- U
        //检测磁盘是否插好
/ J/ _. f+ X9 j$ b9 j  N/ C        //if( disk_detect_OK()==FALSE ) return;
& Y0 @6 F5 y  z8 |3 D$ P2 f7 c4 e# U) L: X    // Register a work area for logical drive 0
8 U3 X& d' _1 a  O- t    f_mount(0, &fs);
! i  ~+ @& F- k    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
; Y; }2 t. }; f- p         //die(res);
# r) F( k0 H9 F4 [. D% F" Q, K0 }  b    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
0 m$ ~; r3 r. [$ J4 M         //die(res);
6 M  ?7 y/ }+ |        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符( x) y# O$ P8 R8 K( x) I
         //die(res);+ C% [9 Y0 A0 r; V+ S2 D3 F
        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  5 f: V: E! W: }) c# ?
        f_close(&file);//关闭文件
' c3 V( H6 a4 H) R        // Unregister a work area before discard it; p3 F! G* q# e; K
    f_mount(0, NULL);) z. S& i; ]6 ]: i6 g9 j
        return res;
# T! N9 F+ V, t- a}
7 _! `% C* c8 w& q: _$ ^////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////1 |# y( k; z. ~
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M# M7 v0 A& n8 y
{* _: K1 n3 P) x% F
    FATFS fs;  x+ l1 B! ~9 l4 ]. o3 ~
        FATFS *pfs;
: z/ n! C0 K' R% U5 \8 @. p        FRESULT res;         // FatFs function common result code
0 h( J  F' o2 }) V# z% @: K        //检测磁盘是否插好
# ]: V  M  w1 B9 I        //if( disk_detect_OK()==FALSE ) return;  b+ d2 W1 ?( A1 E" `2 s. H' B1 a
        // Register a work area for logical drive 0
. D3 d7 W: D" ?        pfs=&fs;//指向2 x5 e. l4 S$ Z; a' r1 F
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
" v- S+ Y3 B: I* e( S$ w  B4 K    // Get free clusters1 F" N4 [# d& E) @
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
4 c9 b1 ]9 _) l' X0 u9 W* K        //die(res);
4 @* Q1 F3 t7 M3 \. P# E, e        if ( res==FR_OK ) ! [: j+ B( B* I+ l
    {; n& |/ L- [) s" r9 h* F; n/ T6 U( A
            // Get free space
/ m) P/ G; H4 v1 Y  B        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
3 G0 x0 _9 q2 P: B: T3 C5 F               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
& ?/ }, Q" r, }                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024; B& L/ e* O! J; {3 `* ]7 \
         *freem=((*freem)*pfs->csize)/2/1024;! {0 U7 F! g: I3 R
        }* H$ a$ w4 Y- c/ c8 p
        //else die(res);//测试函数执行结果分析
; Y& M: ~/ x' b9 V6 J        // Unregister a work area before discard it& y2 u8 u) R% E# d7 I
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
/ V, `! X5 T% h6 {5 n1 s        return res;
! Q  m2 u/ i5 I}1 ~! I9 K0 \; H/ Y3 f4 y! x* O& c
2 C1 K( ]( g  r* _: j% {7 M& W$ @& N
+ v% T1 x/ M7 ~/ q

  d7 A: P: m* ~5 O# b& p4 ]6 b% ~/ Feb 26,'06 R0.00  Prototype.
; [1 E6 s$ h, B, F$ c) {% y  o/8 e0 `, J5 ]8 u' R! Y0 \7 }3 L
/ Apr 29,'06 R0.01  First stable version.
4 A6 g6 {, Z8 e$ p9 i  B4 D/& P6 I* o$ v) ?0 H# r
/ Jun 01,'06 R0.02  Added FAT12 support.1 Q% A  o0 T* I2 T: u
/                   Removed unbuffered mode.
, G, z$ D# K0 I: O/                   Fixed a problem on small (<32M) partition.
+ P7 i) E) I1 M, e5 a/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
' d# U: X# i; a+ L1 H, v/6 Y) O% g+ M% z( M& s+ a
/ Sep 22,'06 R0.03  Added f_rename().; P8 \/ \8 f& O3 S. p3 J
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.+ }2 N0 v4 r' w  U; B
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.* N3 w+ }) H2 c: o6 M
/                   Fixed f_mkdir() creates incorrect directory on FAT32.
7 X. T' H* q' }$ X2 d1 _7 k1 ^: S/! R  {+ Z, p) F- I
/ Feb 04,'07 R0.04  Supported multiple drive system.
1 |' r7 v! d2 J: R6 E. z" O- N/                   Changed some interfaces for multiple drive system.! `9 _; n; p0 R" p" O& m) R
/                   Changed f_mountdrv() to f_mount().
4 n1 u% |3 E1 ?4 _/                   Added f_mkfs().0 h$ }" }& ~2 x  S# E, L
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.
4 {; t1 J6 ~. Z# `7 l0 Q/                   Added a capability of extending file size to f_lseek().' G6 C+ F" P/ c" @3 @" b/ X
/                   Added minimization level 3.
9 }! B& b/ E2 l+ c7 W1 S* {/                   Fixed an endian sensitive code in f_mkfs().
" u# s7 W7 ~  J/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
. }  v  q# G" l* ~) E) p) D2 K5 P/ K/                   Added FSInfo support.7 a4 ^4 W% L9 m6 x# ?1 B
/                   Fixed DBCS name can result FR_INVALID_NAME.8 D& a# K# G! [
/                   Fixed short seek (<= csize) collapses the file object.
" E# s3 ^5 P4 w9 C) M) e) i  l/- S9 Q- d. P6 f* C# ^2 x
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
' v% C+ k4 ~2 L8 d/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
- b, |! Q2 v# p9 T/                   Fixed f_mkdir() on FAT32 creates incorrect directory.
0 c1 K9 H7 t: w' k+ l/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().4 u9 I& Z7 W+ }0 p
/                   Fixed off by one error at FAT sub-type determination.& \4 d& f( \4 y
/                   Fixed btr in f_read() can be mistruncated.
! L" I) A1 L$ v/                   Fixed cached sector is not flushed when create and close without write.
0 V2 N  P$ D' r. b" M( r/
4 Z. Z& _5 i7 H  _7 n0 Y( E/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().
0 r: |" l, o; O0 i5 \& Y* m! ]) e/                   Improved performance of f_lseek() on moving to the same or following cluster." z  m/ m# c8 O. G- j/ K# @
/
2 u4 y& V9 f1 S# F# r$ m/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)7 y& v$ ]" e/ g
/                   Added long file name feature.7 B6 t5 G1 L. e; G  N
/                   Added multiple code page feature.
+ K! t4 I+ m6 @1 d* a/                   Added re-entrancy for multitask operation.
4 ~. a% G& L0 R0 ~, x" S1 c0 G- H/                   Added auto cluster size selection to f_mkfs().
/ P& O; @' S" Z' K+ k0 ]/                   Added rewind option to f_readdir().
6 [/ Q7 w) g' f/                   Changed result code of critical errors.
) |1 l( ?' A; d) k7 k% k' F( }' N/                   Renamed string functions to avoid name collision.5 a' h# }4 ]8 D
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.6 O2 p3 D/ G. I
/                   Added multiple sector size feature.
" k$ j: m8 g; k# a( J: Z, W/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.! ?, n5 m& Y. M. o
/                   Fixed wrong cache control in f_lseek().
  b$ M: h" Z, ]/                   Added relative path feature.* s: E. p' K( E) _9 `
/                   Added f_chdir() and f_chdrive().
& r$ d- b' H; E' c/                   Added proper case conversion to extended char.' i8 U; z. p8 ^/ Q/ f, S
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.3 m& ]- |+ E8 H! y$ j
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.# j" ?; n0 X9 X9 U
/                   Fixed name matching error on the 13 char boundary.6 Z) ~8 g5 V8 y  D5 X% M9 v- D
/                   Added a configuration option, _LFN_UNICODE.  V: {0 v; C) h- J" ?- a
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
, n+ u' O0 h) E# i/) w6 I' c/ G" w+ j' U2 v  m9 B
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)' t+ l; P5 V3 v, ~5 D& B1 |* C+ ?
/                   Added file lock feature. (_FS_SHARE)
& j# J6 L* X; Z" P: ^. _/                   Added fast seek feature. (_USE_FASTSEEK)7 A; @0 U, n! J$ A. @7 T( Q
/                   Changed some types on the API, XCHAR->TCHAR.; B( p, ^, O& j
/                   Changed fname member in the FILINFO structure on Unicode cfg.5 U, N. X; g  t- P
/                   String functions support UTF-8 encoding files on Unicode cfg.* h" o2 {3 A! H; }4 H
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
$ t) _2 Q% ]* \" c3 i. M  i8 b6 E/                   Added sector erase feature. (_USE_ERASE)
( M/ T6 ]8 ~9 x1 B/                   Moved file lock semaphore table from fs object to the bss.( N( W) g) N( ?8 M
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.$ v4 }/ c" O* ?: Z1 n
/                   Fixed f_mkfs() creates wrong FAT32 volume.+ m& B2 E' i, h+ u  K
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
  p/ J/ }0 ^5 b, ~/ U, A/                   f_lseek() reports required table size on creating CLMP.
, B& X+ a& L: F& R/                   Extended format syntax of f_printf function.
* p  O! t5 ?/ L5 e/                   Ignores duplicated directory separators in given path names.
) U% E+ F5 o' R/: E: p( G) E/ w: M6 M9 ~% Y* _7 N
/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.) _& R! J% m* l) K2 s. K# A+ m; M
/                   Added f_fdisk(). (_MULTI_PARTITION = 2)# R& u2 L2 A2 L- N! Q6 p- z
/---------------------------------------------------------------------------*/
' W# @$ n4 N5 y: I" V( k4 Y* T$ I+ d  {

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-1 10:45 , Processed in 0.065913 second(s), 34 queries , Gzip On.

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

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

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