找回密码
 注册
关于网站域名变更的通知
查看: 3027|回复: 2
打印 上一主题 下一主题

[资料] 自己移植的SD卡的FATFS文件系统,FATFS R0.09 (MDK STM32f103)

[复制链接]

该用户从未签到

跳转到指定楼层
1#
发表于 2016-4-28 10:03 | 只看该作者 回帖奖励 |倒序浏览 |阅读模式

EDA365欢迎您登录!

您需要 登录 才可以下载或查看,没有帐号?注册

x
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK  STM32F103工程。下载即可使用。; V. L1 @9 b" M; T
/*----------------------------------------------------------------------------/
7 I# Z$ t) N' c- H/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
, u; j& W9 B( _' z7 R# C+ o/-----------------------------------------------------------------------------/
( H% q0 ^$ n; l" \1 y/ FatFs module is a generic FAT file system module for small embedded systems.
6 U$ u4 R' v* @# o+ v/ This is a free software that opened for education, research and commercial/ j  C0 U' L+ q. z' G8 {% B/ _
/ developments under license policy of following terms.( F2 |( B7 ^8 U: x0 B3 T5 J# _$ O3 L1 [
/
$ v$ ], J+ a8 c0 K: N/  Copyright (C) 2011, ChaN, all right reserved.
8 t% X. q# O% s! N/! k" p; \# o/ H$ z4 L- Q
/ * The FatFs module is a free software and there is NO WARRANTY.: r$ d+ J9 _, p: c1 _' D" p
/ * No restriction on use. You can use, modify and redistribute it for$ {* `+ u' K( h  [7 }' r0 U( J& b
/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.' e( d4 K* r' \& ~  Y: t7 n
/ * Redistributions of source code must retain the above copyright notice.
( a9 N8 h: w' l$ i+ `+ }/
0 l0 I0 q( m$ [0 y' w/ {2 R2 \' [6 H4 A4 q/-----------------------------------------------------------------------------/+ Z  n- L8 ?1 s/ v
7 B9 H; W9 C  |/ U4 V/ t( d
! ?# {# M3 e' i* {" |6 S
/*--------------File Info-------------------------------------------------------( i4 W# R; }2 W2 ]" q  H( d
** 文   件   名:  FATFS_Function.c; ~  B2 |  t0 X6 Z' E% k
** 作        者:~风中的叶~    整理
- s$ M2 O6 o+ D* R0 y9 z6 ]6 S5 `** 最后修改日期:  2012.01.18
. v5 w% ]9 R% U- [* M  b( n6 v1 P** 版        本:  V1.0
% c1 P1 B* p6 M- A' m** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
9 V8 O6 c. i6 R- a' c$ b**------------------------------------------------------------------------------
. \! P8 l( [- n! @4 ^! h* A** Created   by:  Dt.
  L" t4 X  l8 H0 E: N# ]& |** Created date:  
. y5 |  V" ~7 l1 ~3 @*******************************************************************************/ + n1 t3 r# u/ q7 H
#include "TEST_FATFS.h"
7 m! v1 e* m& |2 k; ?6 C. s#include "string.h"
6 Q( |% m+ F  T; k) Q
. Q& x% }7 U+ n  _#ifdef TEST_FATFS_EN6 u; G/ n7 W3 {2 ~, c, f

# @5 y# w( S) u! p% t3 t, I9 {  Y0 V1 G4 ?

9 v1 k9 s4 Q6 Z% n! b3 d% `) }//检测磁盘是否插好% K" b9 v" A6 ^$ {9 u% g- a( w& R- |
BOOL disk_detect_OK(void)) h4 L# _1 Z7 K" Z8 S+ @3 i
{
0 w. ?8 s+ P4 Q! C& S    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) *// w5 k9 @! E7 k( C9 ?* {! R
        {
3 m$ [: l& y( f0 o* j            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");5 m( c7 X' J. c8 W8 d9 `: P
                return FALSE;4 g' ]8 d+ `6 M. o8 }
        }1 D" i2 [' ~* n6 s1 s
        return TRUE;) ]* u5 b' ]7 g# C6 p
}
6 i/ A6 K9 X/ ?( H2 k& i& A+ {! c+ Q3 {7 h* D
& K* f" C0 @9 A* m6 P" R

! y) w+ L: v, i0 y% g7 {//测试函数执行结果分析, |3 a; Q6 W* ?& s# P
void die(FRESULT res). w/ Y+ _# ?0 [0 P
{
. b3 q( j* G7 a# s( v8 ~% I& ~- E    switch(res)
/ G) x2 @. l  E, k. y( D+ U+ r/ Q        {6 y  J& ?" L$ G% F" Q
            case FR_OK:        //The function succeeded. + J2 p/ b& U  }0 e- W
                {
) H- l8 C1 _  A$ L3 Z5 U                    printf("\r\nThe function succeeded!\r\n");
7 [) v% {* x/ t" t; {. A# d2 [. G                        break;
& |( U5 w9 X% E5 N+ O                }
. D9 {( \6 [0 g( a9 o5 v3 A                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason9 c/ _2 }% G8 a/ v
                {
# Y5 ]$ t1 Y! j& d% W; ~& \, M$ x                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
- a( C, R7 p+ J4 Y9 Q                        break;  H, R. |& Q9 a  b2 v3 s* @% y; }. P
                }
; \9 ~  K. b' |) r& q" p1 G) [; F                case FR_NO_FILE://Could not find the file.+ J& G8 K, p% N* J. G
                {
5 B. V# Q. I8 \. J                    printf("\r\nCould not find the file!\r\n");0 Q0 C: W3 U3 I& v- H
                        break;
: c4 `# H$ u! K$ C+ Z& C                }( y& ]" u0 a& D- x
                case FR_NO_PATH://Could not find the path
, d- P7 `7 U  a' G) x- M                {9 W* A# [- x4 ~( B% f
                    printf("\r\nCould not find the path!\r\n");1 R2 w0 B4 T0 O; |' r
                        break;2 w, W4 T$ f1 P' S, i
                }
7 b. [! w; L$ c- h6 ~2 k                case FR_INVALID_NAME://The path name is invalid
  K  [) Q4 W4 @+ D* }; Y                {/ i+ `. S$ y4 i1 D, i4 O
                    printf("\r\nThe path name is invalid!\r\n");
! ~; G. i7 E0 Q! {. u: X$ @  w                        break;
. m9 k% _* J  Z# G+ G. D/ P# }                }
, y3 ]' `- s2 E0 O7 f                case FR_INVALID_DRIVE://The drive number is invalid  k" D2 L5 c' S" s
                {- g: t* Y( [; ]9 J
                    printf("\r\nThe drive number is invalid!\r\n");
7 q" @& _: d. L& t                        break;: g- E( s# x0 b& q0 G% B+ B& V
                }
+ N5 h2 W0 c8 o% n: K, R# `) p7 \                case FR_DENIED://The directory cannot be created due to directory table or disk is full.
+ \- n5 Z( X# C. n  q# O: `- R                {4 r4 y' @& l7 [5 F  C- M
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
6 Y5 b/ j+ E& t/ W; `: n                        break;7 f2 U0 s# W& X/ h( o: T- x
                }
5 q. s7 D5 h& `- t8 ~" A                case FR_EXIST://A file or directory that has same name is already existing- d! Y# Z/ W1 y+ P
                {
; [, k" }  r( u6 g/ Z2 n                    printf("\r\nA file or directory that has same name is already existing!\r\n");
% |$ L1 n( y3 m                        break;% \. J5 D# C3 m- B
                }
  X6 `  u  l/ D: O: ~2 e//                case FR_RW_ERROR://The function failed due to a disk error or an internal error4 U+ k1 |8 h5 I/ u( w0 R
/*
( \% l& ]2 p! |) e7 {                case FR_RW_ERROR://The function failed due to a disk error or an internal error
) ~- O% n: R. L" S# D) C' b! \                {6 _) T8 Q+ L6 p2 ?
                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");! x8 a% [# p% v% H
                        break;$ \) @" K3 q+ F6 C6 A3 Q
                }  t  u' [8 h& C, d2 ?" h
*/7 q7 W" m( V7 {% T6 b" Q" D
                case FR_WRITE_PROTECTED://The medium is write protected
* r1 \; m3 x$ b/ Z& |  d3 N0 c& [                {
+ B) N0 y* j1 X$ t, u                    printf("\r\nThe medium is write protected!\r\n");* }: e5 D. M3 ~3 R
                        break;5 J9 N0 A& }! y5 t
                }
! f7 t/ C# i% H- B8 y! j* o6 O4 u                case FR_NOT_ENABLED://The logical drive has no work area3 `# S0 `- |6 \( U. L1 j
                {
4 A9 u/ o0 `: J' b  H9 u: w9 i: j                    printf("\r\nThe logical drive has no work area!\r\n");
8 O1 U! Z0 n6 ~5 u% {: G                        break;1 E+ `# j1 \# S( U. y+ t% T/ j$ f
                }( n) z2 P2 g- |$ f( `/ M
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk" y& w7 }' h. ]: n6 w) u
                {
: p6 l% J+ R& }# \: I                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");
5 _- Z8 z. Y6 n5 X5 ~                        break;. {# m2 O8 s5 y5 S
                }
8 v5 |6 t& p6 L$ Z2 p6 H' H                case FR_INVALID_OBJECT://The file object is invalid
: z2 Z2 d8 j1 X& g                {: K/ I8 @( m' F3 M% {8 @; D
                    printf("\r\nThe file object is invalid!\r\n");1 h) i* p2 I8 i& y- j+ r% E
                        break;9 A2 a9 l9 R7 q  Z$ I
                }7 Y4 S# P4 F9 A- g0 I0 @2 m
( C" e) t! t; V
            //The function aborted before start in format due to a reason as follows. 2 T. [6 W7 |! I% f6 ?+ r
        //The disk size is too small. 0 m4 E# E- m, W* \' }9 ~( O! U0 Y- \
        //Invalid parameter was given to any parameter. # v  \7 @3 T) a% q9 |
        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
  m5 B+ X4 k( L! f/ S  i# R  P                case FR_MKFS_ABORTED://9 y# s4 r( k, F; J  ^) b, h
                {
. C- z; G! E& v& e9 A6 i- ~                    printf("\r\nThe function aborted before start in format!\r\n");
9 Q' U# E( L. V3 C/ `/ [7 |- ?                        break;& ]! s! H9 b  I( c( v
                }
, m( Q- u1 S& i- L) X0 ?3 m/ H: X                ' j% j) j& G- t4 V! Q  m
                default:
7 A. `  @' ^3 p6 g                {
" ]2 e% C# V6 J/ a: [: F/ V                    printf("\r\nerror!\r\n");6 `5 @5 x3 h% k( d0 H+ U4 c
                        break;" H6 B8 g1 h; B! L* Y- [
                }        - \/ q0 z0 a$ \2 X
        }7 m. V/ B' @' C' P9 B$ i* C; i8 L
        return;
2 {# e% o8 o: R5 |: q& C}
+ c1 i! x) d$ z9 l; uvoid Test_f_getfree(void)//获取卡的总容量及剩余容量
/ R6 q. Y; }7 d1 K0 a{
: O) f4 n; ~$ A. @" P8 x$ v4 g) G    FATFS fs;
& s1 Y+ q' \0 P& O" R        FATFS *pfs;
+ A- H/ N$ N2 l& t: X# M    DWORD clust;
8 r- U- X; b( R6 _1 N        FRESULT res;         // FatFs function common result code9 X9 G3 z4 h# g1 o- T, x

! i: @- A! J; y        //检测磁盘是否插好0 g" n0 p, ]+ |
        if( disk_detect_OK()==FALSE ) return;
6 h. ~3 d9 B. q/ ]& A# ]& D9 a* ~7 ?0 M( U* U$ {0 q
        pfs=&fs;//指向
- E' ~5 m7 j5 x- o$ p4 _        // Register a work area for logical drive 0: n8 L3 R3 f# y: r# `
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
5 ~1 f* F6 g0 Z% E9 r
. {" H: B% l+ A# g    // Get free clusters
& [" f! {8 m+ g% F% D( Z    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"* \" ~+ h9 D" W9 Z0 _7 o
    if ( res==FR_OK ) $ a4 {; j& D4 s
    {
: e% {# \  e2 V            // Get free space
$ P+ _: k, j( @  Z/ D        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",2 d9 p5 T7 T* L* v+ [8 S
                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024; q, b' U) h9 G/ J2 b
                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024& A  Z( A) _% r6 z( z" W
        }! J9 [4 S3 v, k5 j
        else die(res);//测试函数执行结果分析
, B0 G* |, R8 y3 l; t        * D- ?5 N9 }! P- l3 V9 [
        // Unregister a work area before discard it
' |& _& s* i5 X# t8 O* F    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间1 H0 v# C7 b& b
}; a. ^$ g9 P" ^
; P3 F: l! ~, `: t
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误0 n: {+ k& t# R" H/ Z+ P
{+ G) d$ h$ X- k
    FATFS fs;            // Work area (file system object) for logical drive
) i' y# h% z6 O+ o6 K    FIL fsrc;            // file objects* Y6 _. ?& V. K5 I+ o! s4 c
    BYTE buffer[512];     // file copy buffer. `# q/ D7 H* y4 m
    FRESULT res;         // FatFs function common result code
! Z& G2 k% f: T    UINT br;             // File R count
; V$ o$ U& I1 u6 g0 Z! W% N% @        u16 i;
: J" J5 O" n/ f4 M1 `" O4 q$ D        
2 ?# D/ h2 ]( l4 S! ]" i, @" _3 w$ @; u6 W5 ]- F8 M4 X
        char path[20];
1 I$ w/ U* Q* {+ ?4 W" j9 _+ v
- x1 j' @$ }0 w        //检测磁盘是否插好7 \0 ~# C+ y- f! K3 {2 F5 u
        if( disk_detect_OK()==FALSE ) return;
6 _1 H9 y, D5 a2 z3 @- l! d% j, H+ G0 h  L% S' q
    // Register a work area for logical drive 0
; O. H2 |/ i3 n    f_mount(0, &fs);) }3 R3 t+ d. V7 ]  w; r

, P- ?( `! _2 \. m" s. {3 o6 F        printf("\r\nread file:>");8 R9 o4 c) \7 A$ {/ w
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt0 M$ n: c; [' Z. H

" ~* D$ V% A" B' z8 S' \        //Open source file" s( A2 S. b6 s. X
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
  x. b( b0 ^2 T& b7 J$ C        die(res);
1 Y) H) m3 P' ^6 f. @. w, X        . b7 x& U$ f9 Q
        //buffer空间设大一点,会提高读的速度。
+ }  b4 c9 a/ y6 {0 O        //如果文件实际大小512byte,
( n8 c: c2 D; R% I* M        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。9 X. L; U( M1 b, E
        //下面两行主要是去除1s误差。
# B8 d. Z* H& W! w7 K# K- a, s8 E. i* z) ?
        for (;;) 1 M' R' C# |/ n) p* j8 b
        {
# W5 N  F1 k2 x8 Y                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存2 N) C2 I# {( I1 H
/ U. A9 x1 y+ Y7 R
                res = f_read(&fsrc, buffer, sizeof(buffer), &br);1 h4 ~3 h2 q/ G% e
        if (res ||(br == 0)) break;   // error or eof        : M9 u8 w$ b8 K. N8 }( F3 a& U
                / C* i! K) w- }+ n
                printf("%s",buffer);        4 r# D% e  a* d* F( t7 q5 {2 `
    }* X# `% H( M9 b8 X! L. }8 R& g
- T, m) w: U4 u3 V
                           
6 x0 p7 x4 ^; ^; ]: R    // Close all files$ |) l: O7 p  i# ?9 X6 R) P
    f_close(&fsrc);, f8 v% Q9 w* }( r: f+ d: g3 u, Z
    // Unregister a work area before discard it
+ |1 I: t* v2 }0 q' G) O1 }+ u    f_mount(0, NULL);
* I% {: N) _8 ~) c! W}6 a# L- F% |1 O. b  `

3 O0 u1 E9 Z+ _. E3 t. [void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
4 A5 _) r& d' ?{
: ?* P& l3 b1 O0 Q    FATFS fs;            // Work area (file system object) for logical drive
: }2 `7 \* S1 N$ k: K  F    FRESULT res;         // FatFs function common result code1 x# \7 Q1 _7 k* f! {3 P: [0 o
        FIL Make_file;
! U' `& V1 ^- V1 C* \3 z, l    char file_name[20];
1 y) `. B5 o- U$ x5 ?2 E1 H4 m    char Storage_buffer[] ="0";
; o; ^+ N) R; N* X0 t6 X& M( x! L          x, \2 U& O7 k: H4 @
        UINT bw;1 g5 Z* M8 U0 H( O3 C) k
        //检测磁盘是否插好& ~3 n9 G+ I! i" O* g
        if( disk_detect_OK()==FALSE ) return;( R/ X% N9 e8 T5 I1 [
         printf("\r\n inaert_ok:>");& l: h) i5 n: t0 F3 [6 g
    // Register a work area for logical drive 0: ?/ Z/ {( b7 U3 T, I& e
    f_mount(0, &fs);$ e2 h+ k0 [$ f# t2 M
1 s) [, [0 M! j4 a
        printf("\r\n Make file Name:>");3 q: E4 G+ c2 Q& y$ h( o
        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt, x  r2 `6 }8 R' L
. ?/ V4 K( T1 _4 ^
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 % Y6 D+ R! s8 X3 W3 G* i' w
         printf("\r\n open_ok:>");& m# W5 [+ f( R
         die(res);
" l6 e. M# L; c# G1 J    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  5 y6 w/ ^* v' O( W% l4 `3 `/ m
      printf("\r\n seek_ok:>");
( i# k) [# Q1 F: d: W% p4 ~         die(res);
; m7 N* f; B1 K  B; L: T$ z        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
7 o4 x- T# N, n* w7 v  t1 _  K     printf("\r\n write_ok:>");
' O/ \" k5 ^( }0 M4 B  J+ N" O         die(res);0 M/ l* P7 T; B
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  4 K. P7 y6 J$ K2 x
        f_close(&Make_file);//关闭文件. j0 M9 y5 M+ q- f& l
        printf("\r\n close_ok:>");
! H4 y; h& \' d0 {. B; X! I) Y! q5 D
        printf("\r\n写文件测试OK!\r\n");
8 b) `* R; |$ S8 z6 p
& d& x" J: x4 e0 I        // Unregister a work area before discard it
' @3 a* L$ y3 {! D0 w6 @    f_mount(0, NULL);
' {4 }% _$ o! t9 J1 e& ?# }}
6 H- a5 Z/ u% \3 B2 ~. Y8 i5 O- Y& i8 R; g
//The f_read function reads data from a file.
5 p% J" T% w3 y0 H& u" S& [( z//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
& i) \2 E8 ~- e8 m4 |* }//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了' w& B" S) `, H1 h
//所以以后要特别注意这个问题。
6 a  E) o3 U2 y- `+ P/ {
$ W. W3 ~. \/ G( a8 }0 U5 ^0 hu8 StrToData(u8 * data, u8 len)# E8 f+ b; h# }/ `! \
{
2 V5 ~" \) i) e6 \: v        u8 ltemp;& m3 p5 G, R7 Q6 K9 n1 X
        if(len == 1)! `* S# D- w) ]# q. A; C5 o
        {; S& G$ L% W+ z+ q3 d" [3 J
                ltemp = data[0]-0x30;; c" q1 |# c* y, t

/ p2 t5 [, O& [! ~% w        }4 F6 ^6 B0 q7 r0 t5 Y
        else if(len == 2)
, L8 @5 r0 L6 p  T' T9 }0 z! l        {
. Q) x8 Q- w0 U& ^. W- |4 ^9 u- D                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
$ r0 V0 c. h5 i6 u
2 L% [0 w) g1 C, O& R( q         }7 g! _) T6 B( l* Z$ `
        //else if(len == 3)
0 L4 y/ r! w" [. |/ z# l                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];- z( k; S% w' ]
4 O2 T* h# Y$ I% O6 ]$ Y
        return ltemp;* x1 X, u& s* q
        
4 R4 x( Y% g! j; D; h( B& E8 ~2 _8 L( k}( f5 G, w) W! n1 q

' ?# `; a1 R, T! |9 h
: t- A4 N* x: t# M5 q#endif5 G8 ?9 `$ P9 ?4 z. `4 d6 o  s3 B- A! a
8 Z! A# O* e" U+ {

! m! U7 ]0 H! i/ `7 o/*, Z" o; R( V$ W4 r
int main(void)
6 s7 j, Q) ^. U8 p. y0 v1 A1 S{
3 `8 }7 X/ }% H  L" a4 R///////////////////////////////////////////////////////////' r! ^: j/ Q: k* P$ M2 P
UART1GPIO_config();//串口IO口配置
" i: U- k( O/ ]4 \) AUSART1_config();//串口初始化波特率为19200
/ m9 P& G) V- X. B' j2 v* K//UART1NVIC_config();//配置中断& h5 n5 C- `" D
///////////////////////////////////////////////////////////
  E/ m; C# U' N0 ?9 NSDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
/ o: t( b/ V6 o& G//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它
* z: r( }& {& ^# S/ ~# vTest_f_getfree();//获取SD卡的容量和剩余容量
) ]" m' j% g1 Z; hTest_f_read();//SD卡读文件测试( S8 F; d2 n* z4 K: M
Test_f_write();//SD卡写文件测试
6 a/ ~0 K) h8 K$ c1 K. N/////////////////////////////////////////////////////////// ! g1 m* @# ~8 Q6 e6 R
    while (1)6 g$ V# _* n7 U* f8 y' m
    {1 T5 Q5 e/ E+ E  E8 u! Y" h
        //printf("好的");" V/ k  X8 l8 p' |/ L
    }( m; X4 j  G5 I  O+ U
}*/, t  i& a, Y0 `4 S4 i
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////6 d% R7 O0 x$ B5 I
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为03 Q5 M6 h  p# V: F
{
& ?& l$ R  b; I+ s* y$ X8 N    FATFS fs;            // Work area (file system object) for logical drive
( M+ ~0 p8 _1 K) S& X5 P    FRESULT res;         // FatFs function common result code
+ ~3 X: u  Q/ u/ E( g5 h& O. i3 v; a7 H; q3 P7 U6 H7 d5 z
        //检测磁盘是否插好+ L3 r1 @9 `7 q
        //if(disk_detect_OK()==FALSE ) return ;& M' s& F' O4 [0 r
        //printf("\r\n inaert_ok:>");4 r( t/ u' H: z+ P
        // Register a work area for logical drive 0( h3 ]+ l- [3 M+ n. }! E8 X
        f_mount(drv, &fs);3 {5 ^! I- K2 m' ^6 G" w. E' @
        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/* k" z) x& i2 Z% b
        //die(res);0 ^: w! u/ e, r
        f_mount(0, NULL);0 S+ k9 t" w9 X% b& i! ^
        return res;$ i) m1 W5 G) c
}  `7 o; Z, B; ?! |6 u0 f  f
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" A9 v5 V; u5 {- ]( oFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
) n0 s  ]" \9 p- G{; H5 R1 O. u  W/ j
    FATFS fs;            // Work area (file system object) for logical drive
& O& y3 {* @& S    FRESULT res;         // FatFs function common result code) B* O- C( d* P1 J# y
, s1 u$ ~! B* p( @. M
        //检测磁盘是否插好3 x8 O0 \3 Z3 z$ c* \( A/ \
        //if(disk_detect_OK()==FALSE ) return ;2 ]8 }; J6 [( i* X
        //printf("\r\n inaert_ok:>");
( l% q5 U' {" F  Y        // Register a work area for logical drive 0
) B8 `* u0 E4 Y/ K        f_mount(0, &fs);4 K9 b7 T. S. c* v6 b! a
        res=f_mkdir(path);//创建一个新目录/ B' e" N" z% b+ P  }
        //die(res);
# A/ F5 ?7 N5 ?/ C4 |7 Z        f_mount(0, NULL);' a" S' P- {0 d) V) ~
        return res;9 V2 W% h/ n/ m- Y4 d0 f
}
! ?6 B, e, m! V! Q////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5 ?, {% p, o6 S4 m8 ]; K
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        - m0 _+ ^( C# ^" A  Q
{
' a6 |9 S) p6 E- z9 B    FATFS fs;            // Work area (file system object) for logical drive
" p! W4 j: F9 }7 `" @8 R        //DIR        dir;
8 c  L$ S% X& Q9 a- O, P: K    FRESULT res;         // FatFs function common result code
$ u; x/ z$ a# R  T
) {& |! [4 H. O6 h        //检测磁盘是否插好
. N' w8 I% Y) r6 x8 h- H        //if(disk_detect_OK()==FALSE ) return ;
# ~- ~  R$ B% z+ U/ x2 T        //printf("\r\n inaert_ok:>");
7 e0 i% ^& C" p- K, q% f2 m        // Register a work area for logical drive 00 n; J# e' L3 t5 g8 i8 Q* R8 x* N6 h5 `
        f_mount(0, &fs);
2 V( J/ S: W; @8 R, x+ f+ [        //f_opendir (&dir,path);
  a" H% }6 L. Y        res=f_unlink(path);//删除一个目录) A& N4 }' n: I6 i' E
        //die(res);' Y* g+ R6 D: E8 k( {
        f_mount(0, NULL);1 ?$ [; I- H0 q2 k
        return res;
- m" ~; Z9 j7 o* _}0 H3 p5 d! K$ l  V
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% t8 u" J4 N( c* \- V! H, {! J1 |FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        ! g/ g1 }9 i' p1 y
{  m1 D5 ~4 k0 P1 D: ?/ l# |
    FATFS fs;            // Work area (file system object) for logical drive
2 L7 Z) o9 ?0 r" M$ b9 a' y- b$ ^        DIR        dir;4 Q( o/ G9 t. G* ~* Y) v
        FILINFO finf;
$ F! |% M5 y6 ]    FRESULT res;         // FatFs function common result code: {4 J' b* C: E1 }2 M1 u7 G9 A
' m6 g" }% y: M+ K4 L6 W
        //检测磁盘是否插好
! d5 \  S4 G6 N- [4 A        //if(disk_detect_OK()==FALSE ) return ;
% j' W4 [& N6 E; h5 A! k0 Y% |        //printf("\r\n inaert_ok:>");( [/ \# e) `1 I* A1 s3 D
        // Register a work area for logical drive 0" @# w( i9 q# g: e, q  J3 _: G
        f_mount(0, &fs);: h! S) G, w( f$ J" ~. F
        f_opendir (&dir,path);+ m7 m6 R# ^9 S9 ?

( A5 {, J) e, G6 N1 B$ K) F4 ~        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
1 a1 H: p, y$ d& Y        {strcpy(*(filename++),finf.fname);% |" z/ u0 K9 p% l5 o. u5 Y
        //printf("%s",finf.fname);
: u6 A, C9 X$ ^6 l. b+ x        }
+ N- O$ |$ p1 m) g: G( h" X        //die(res);
( ^1 C1 z( m4 M& w        f_mount(0, NULL);
3 p# J: ^  l! u% W, a, o        return res;
5 m7 i* y) k- F" Y& ?}
$ ~. v+ g; P; p3 _////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
! r! P/ a- d# G5 P) B4 pFRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名& }1 K- q" A* @/ L; k
{" I/ c  x: G' f8 d5 a3 q9 Q- ^. H
    FATFS fs;            // Work area (file system object) for logical drive
  q. z" H2 F5 D        FIL file;! G# \  U! ~! J  t8 y+ D
    FRESULT res;         // FatFs function common result code
: \4 G* u2 G# z; I/ {& W: a, Y  v9 U+ z0 d/ N- |  `5 Q
        //检测磁盘是否插好
# j. q* X! \, b5 }9 J' X$ r* m1 X        //if(disk_detect_OK()==FALSE ) return ;
! A& z1 D) `8 B% N- r7 f% Z        //printf("\r\n inaert_ok:>");" w1 a0 s; m5 O2 V& W4 `
        // Register a work area for logical drive 0
( `* a" N! n+ g* d  ?0 ^        f_mount(0, &fs);; ]; O+ Y% l& J
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
& z" w$ j$ k. B& M$ g                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。, ]/ ]# x* R- p6 l) M/ N+ v* U( t. g
                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。$ J; a0 k) l/ ?
        //die(res);) G/ P. Q1 `) L4 ?6 J) k
        f_close(&file);//关闭文件
- Z, R/ K0 _* m$ b( D' Y0 L        f_mount(0, NULL);
( E* W9 w, V% j5 _% T. j6 v        return res;
( K. V! Z/ x- S3 l}
$ l, C: z4 r' ^" G9 K) n////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////. _9 x8 `, J+ B3 W; _' E
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
$ `$ t$ E3 r& o# P& P6 [0 f{
1 l$ S. Z7 g$ J0 ^( f% n0 K+ F    FATFS fs;            // Work area (file system object) for logical drive
' U3 x* y6 t7 P% F; N; D        //DIR        dir;
6 b, X' b1 s! r8 m    FRESULT res;         // FatFs function common result code- `7 r6 r7 k. z2 V: X8 M4 D
) @( ^! \: S3 F) |  i! M
        //检测磁盘是否插好
0 T; P$ g# V5 C% x4 P; @3 @$ I" G        //if(disk_detect_OK()==FALSE ) return ;* i, b$ K0 h! O7 d; k0 q4 e
        //printf("\r\n inaert_ok:>");
* d. T6 I. E, T+ e, g        // Register a work area for logical drive 0
9 @; G/ r7 B2 |9 B        f_mount(0, &fs);: \7 r( T/ A& P: n; x9 ?; s5 Q. Z% ~
        //f_opendir (&dir,path);5 T* b  m7 M$ E
        res=f_unlink(path);//删除一个文件
* e  G. t/ {+ R! [        //die(res);
7 Z1 N$ X! e- @2 W# p& X" i; p5 U/ _& V        f_mount(0, NULL);" r  b8 i; V) V" q" R7 n0 h' J
        return res;
; t) J. b* [! d+ L: t- B2 d9 L}
5 V! M* S) J9 Z) s! ?; A////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////5 a& }  a4 q; z: f2 l4 r
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数5 h4 O& o1 q8 C
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
, g* L) _, R* x% f    FATFS fs;            // Work area (file system object) for logical drive
' ]3 x4 V  P( ^8 ~    FIL file;            // file objects* j8 Q# z- L: L, z7 d4 v4 d  c
    FRESULT res;         // FatFs function common result code& `5 m' d8 S) o7 E
    UINT br;             // File R count 文件读回的字节计数
7 e2 J( \, b( ]        //u16 i;
; K# @) Y7 \2 _2 T3 I' m0 y        //检测磁盘是否插好
" U$ w4 x" p' |& v( B; }        //if( disk_detect_OK()==FALSE ) return;
* |6 e! s: _2 L- [    // Register a work area for logical drive 0
! E- j3 z2 D9 h$ ]        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';
% D5 O7 G0 `+ y( M! p2 q! e    f_mount(0, &fs);
" i% T$ N/ l2 E2 p        //Open source file' N1 f/ \0 L, P3 B$ \+ [5 y$ _
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误) L1 H+ y# h1 h) |  |! y+ [3 U
        //die(res);
, w5 T1 N/ P  G5 q0 ^        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
7 y1 A5 b2 T; ]2 q; N& Z        //buffer空间设大一点,会提高读的速度。' A! X( M' \' g( _7 `. z) j
        //如果文件实际大小512byte,
, Z4 \- f; K. i: Y        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。; t" _+ {- ^" u( z+ L4 V
        //for (;;) ' G- b8 l# _$ Q: U& A
        {
5 i. s) J: D: I                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
+ n. d0 K! g+ \
- E4 M. T! F9 e0 R# O; U$ ^+ _                res = f_read(&file, buff, strl, &br);
! m4 u! b" v5 a" e0 g! o/ j2 f        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出
- ]; C. p' @6 ?& i4 z0 H               
8 M  {3 Z  t% d% W, V$ U                //printf("%s",buff);        # h+ t# {) n0 ?
    }                    
* i  _; v2 K& F4 U/ d    // Close all files3 J/ ^5 h- q- j: A+ m
    f_close(&file);
: Z/ {2 g0 @2 ]( q! {3 _    // Unregister a work area before discard it
- J) o6 q! h- h0 w    f_mount(0, NULL);
, M- f$ n6 s% h* t        return res;
+ N0 d, Z6 L* I* F& @6 x}' L" r; ^8 F( `; w
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
0 r. F* {7 Q) B% W: l" F) mFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数- [% ^4 ?8 K9 }+ T1 a, s3 M
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));
1 A5 I6 k% ~8 S0 B. \    FATFS fs;            // Work area (file system object) for logical drive
% G8 t1 M) q$ _3 Y$ @( G    FRESULT res;         // FatFs function common result code
. M/ R9 {* Y! @: e' }* V        FIL file;, g' ^$ V7 t' o* U# g4 L
        UINT bw;             //文件写入的字节计数
, @! s) `- Y1 G8 ~9 @        //检测磁盘是否插好
: u1 {+ }5 j6 f% z. E6 R        //if( disk_detect_OK()==FALSE ) return;6 |9 y1 a+ K2 W2 D
    // Register a work area for logical drive 0. L! u6 ]4 x' d5 o# H
    f_mount(0, &fs);
1 S4 M% u1 r8 z4 z) B' t# a4 e9 L    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 ! y% x& y' U& Y) i. a7 z. C" K. j
         //die(res);/ O/ C* d$ M: }/ }' p- x
    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 ) r" y2 \' X6 S3 z
         //die(res);
$ Q, o  ?. ~: r        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符
1 b2 K( w" |5 J         //die(res);
0 M9 Q4 h1 z$ F- P        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
% ~2 O6 }& L( l$ j9 y  V/ l        f_close(&file);//关闭文件- N/ e6 x1 u1 y: N6 \% b5 V$ Q
        // Unregister a work area before discard it
! V  J, d- B4 g    f_mount(0, NULL);+ {3 s6 p8 {) X6 t$ u+ Y, I& t
        return res;3 b1 X; r6 w4 f  Z9 J, E
}3 l& t; J7 L! G. \1 }/ m% Z
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
) B: p/ k: F$ SFRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M
$ u3 ^9 k' Y+ U4 J) {{7 L$ E8 s( I/ G0 f8 J$ R. v( U
    FATFS fs;
( S" ?9 }) @$ L' X& P        FATFS *pfs;( S; t6 d7 w; K( A2 W' X$ @
        FRESULT res;         // FatFs function common result code5 v6 V# w8 z: j, l" D: m0 t
        //检测磁盘是否插好& U- C1 R8 w  S
        //if( disk_detect_OK()==FALSE ) return;5 f0 @& h8 O: K* c8 _" m
        // Register a work area for logical drive 0- ^9 f& n8 M7 q! |/ F
        pfs=&fs;//指向* {* j* ?/ U7 T, j: w; W2 c* C
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间0 r) ^; A( Q5 b9 X
    // Get free clusters
6 k" V( b, C2 a" |    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"/ g3 ^( K7 J9 k9 I
        //die(res);
6 y7 d4 O, d2 J# \) s        if ( res==FR_OK )
  {/ {7 Y% J2 x3 {- W  j    {) N# @3 K/ l% ]( D: A2 X
            // Get free space: V+ `! Y: W+ M6 e4 K, j  _* }
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
+ O9 u! a  O/ @/ X" R; |# P5 K' ~' E               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
8 ~1 Q* |( `( v( c( z* W: N                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
- W7 Z' ^$ m6 U5 f$ R: ~/ x0 R         *freem=((*freem)*pfs->csize)/2/1024;7 _+ s& d& h. i* ?& b  c1 D
        }
! i6 P1 X2 ?9 J; f) r        //else die(res);//测试函数执行结果分析' o: g0 C$ ]' |+ D( h0 |
        // Unregister a work area before discard it- K1 D3 F1 @1 a2 o; G1 v
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间- o7 N  ^: P9 k) s& m/ i
        return res;( W. }7 q3 `# N
}
) i, e& \9 B9 U$ c! Z# B9 U8 {3 T" [& @' v# O

( [1 k! d$ J1 M- e0 G9 f$ D5 q& t* O1 u% ]
/ Feb 26,'06 R0.00  Prototype.1 t( P0 S/ ^- V9 g
/% O; s1 X; @4 C1 q* K, E. ~
/ Apr 29,'06 R0.01  First stable version.
8 m0 A- Y2 F0 F5 c0 n6 J- O/$ Z$ E9 }+ V' c6 j3 h1 d: m. F
/ Jun 01,'06 R0.02  Added FAT12 support., t. {5 H( H* \3 G
/                   Removed unbuffered mode.0 s0 G0 Z6 f; y/ A/ H
/                   Fixed a problem on small (<32M) partition.4 M3 U- {! r, |; S/ {% k
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
6 g- {) ^* r( n: v; s' G( H/, ?1 @  M- l; u' U
/ Sep 22,'06 R0.03  Added f_rename()., x" u$ m& o7 N" C0 m* n) }& a
/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.1 s; k3 ]' n* _8 `2 B' h
/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
" D' t$ F# n  a$ W6 J/                   Fixed f_mkdir() creates incorrect directory on FAT32.& `# u* b/ b7 l( S
/0 h% g- j  S/ U+ j# ]  J5 v
/ Feb 04,'07 R0.04  Supported multiple drive system.# S, P. H' h. O$ z  _' B; A
/                   Changed some inteRFaces for multiple drive system.
8 c: o8 T$ M" f/ T. M: G; b/                   Changed f_mountdrv() to f_mount().! S7 v0 b! D+ R% v' v1 o9 g$ j
/                   Added f_mkfs().
- b: W  h" V: d( X/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.* M5 H2 Z+ [7 J) K
/                   Added a capability of extending file size to f_lseek().
9 P- ]3 H8 o3 o/ O' T* B% W, x/ }3 L4 x6 [/                   Added minimization level 3.+ I0 k4 T3 K( g! _) T/ l+ Z* f
/                   Fixed an endian sensitive code in f_mkfs().
$ T  s7 Z" a3 P2 A; o9 j* Q/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.  s: G0 S1 N2 s* |2 A# R0 R; h
/                   Added FSInfo support.$ d, i8 _% B! Z, K
/                   Fixed DBCS name can result FR_INVALID_NAME.4 h7 A. q4 A& f3 {
/                   Fixed short seek (<= csize) collapses the file object.% g4 V+ c  j' _/ _
/) k& W, Z4 }/ v4 z2 C1 A3 y# r! d
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().- P5 x( e4 G1 B( w% F4 P9 B
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.) a" c( w/ w6 k0 o- q  v7 h! A
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.1 O+ Z1 m6 h3 v
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().) ?" q' O' B$ ?& P' a0 ?5 C
/                   Fixed off by one error at FAT sub-type determination.
# T3 U! v0 _* o/ u8 y" F/                   Fixed btr in f_read() can be mistruncated.
& s* c* k8 g8 V9 F/                   Fixed cached sector is not flushed when create and close without write.
$ Q8 y. t/ I& B6 ?4 p) Y/5 z1 z8 e! }; w+ w( b: U
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets()./ J& j3 g0 a  \" K) f5 P& g& \
/                   Improved performance of f_lseek() on moving to the same or following cluster.
" F- C7 \# F, I* ?$ i/) k" d# L. U: _: g2 \5 H; e2 @
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY), H9 w% M5 ]/ N; X3 L- q' v+ {
/                   Added long file name feature.
# P; L  N8 R+ ?+ ?  {3 T* \/                   Added multiple code page feature.
5 D8 C$ a' b- G8 a/                   Added re-entrancy for multitask operation.
* k3 t. ?3 H' s/                   Added auto cluster size selection to f_mkfs().' i+ }  O0 i( z/ ]
/                   Added rewind option to f_readdir().5 L& r, b( Y4 Z* O: O0 |1 V
/                   Changed result code of critical errors.+ i1 }! F4 r# K
/                   Renamed string functions to avoid name collision.& O) _5 d  F" o; ?
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
) E! s- P' }0 ^  O$ g% U& @/                   Added multiple sector size feature.
' E# A6 G7 @" E9 G7 Z/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
6 R8 B/ \+ U% d/                   Fixed wrong cache control in f_lseek().4 \% R% L5 \- E  a  }
/                   Added relative path feature.
% k: k9 D; L1 f: N- R* L/                   Added f_chdir() and f_chdrive().
! d1 A' u/ O5 f& `/                   Added proper case conversion to extended char.
$ S4 F8 V3 c0 T" }, {' I" j6 O/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
2 _9 }$ P) g5 U+ n- u9 ]/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.
( p; i8 d7 ^" u$ j/                   Fixed name matching error on the 13 char boundary.
7 \/ b# M! M- L0 R, W/                   Added a configuration option, _LFN_UNICODE.
- ^7 Z" ^/ R7 d! Y% s7 g/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg." H, W* x8 B& I  q  ^
/
: r9 f2 f- a( V  m+ E/ j9 q/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)8 l# u  p+ v) Z  Y, ]; x
/                   Added file lock feature. (_FS_SHARE)
' x7 o- m" d+ P# n8 N1 H/                   Added fast seek feature. (_USE_FASTSEEK)
( \) N! {+ I0 B  z/                   Changed some types on the API, XCHAR->TCHAR.) Z! }1 e! Q6 a  Z* x
/                   Changed fname member in the FILINFO structure on Unicode cfg.4 g* I+ F0 u( X$ @; v# ?
/                   String functions support UTF-8 encoding files on Unicode cfg.* G+ t+ v' H3 I
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)
, E/ s& |+ s5 U9 U0 _/                   Added sector erase feature. (_USE_ERASE)
/ S' d( p( s. l2 f/ c3 h( x" u, Y+ [/                   Moved file lock semaphore table from fs object to the bss.
4 {  {# j- ~* _% ^* X' F/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
# Q/ _& T) J( t7 D1 c/                   Fixed f_mkfs() creates wrong FAT32 volume.
7 k/ E( l8 y8 M  H6 u/ w0 J3 T/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().* t' Y) S# K$ Y9 h3 W5 n
/                   f_lseek() reports required table size on creating CLMP.
9 C! g% [+ F! q4 X' z) _/                   Extended format syntax of f_printf function.
- s3 Z3 n  F' I1 r9 v  w/                   Ignores duplicated directory separators in given path names.! R; H! h8 u1 S" I3 W
/
+ n4 {7 j+ U4 e% E3 Y$ X' P8 a# n7 U/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
" A  X- Q# {4 i8 E# `) U. v( A/                   Added f_fdisk(). (_MULTI_PARTITION = 2)/ E* E! i* ^5 M( m# u
/---------------------------------------------------------------------------*/
4 G" I8 ?1 K& N. s  P2 Z* j5 l9 I8 K2 T

STM32的SD卡FATFS.rar

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

您需要登录后才可以回帖 登录 | 注册

本版积分规则

关闭

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

EDA365公众号

关于我们|手机版|EDA365电子论坛网 ( 粤ICP备18020198号-1 )

GMT+8, 2025-6-10 20:33 , Processed in 0.125000 second(s), 26 queries , Gzip On.

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

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

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