找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1391|回复: 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工程。下载即可使用。
+ x5 |9 r4 \/ k. o  j/*----------------------------------------------------------------------------/
  b% A4 g( e" b4 b1 d3 S/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
; A" _  P' @$ R' M: t3 K) G9 {/-----------------------------------------------------------------------------/
( l  H4 F) t. E/ FatFs module is a generic FAT file system module for small embedded systems.
* I$ Y% `! Y% _! F, f( `/ This is a free software that opened for education, research and commercial8 S) ]2 H# [" K
/ developments under license policy of following terms.
7 F& p6 f' F+ x- n- l. j& Q/' H* V1 p% r+ A( _9 D
/  Copyright (C) 2011, ChaN, all right reserved.' L% b: ]! s0 R3 C$ D4 o0 l) O
/
! i- T+ G+ [% a& ]' r  V4 s2 j9 Q/ * The FatFs module is a free software and there is NO WARRANTY.
1 z* b0 W& p- s+ ]/ * No restriction on use. You can use, modify and redistribute it for
( Y) T& \( x0 q* N/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.6 i; b* W/ _0 Q  a/ d1 f  `
/ * Redistributions of source code must retain the above copyright notice.
- J+ j- c- F) e5 O( f6 A( P2 S* Q/
1 g: s  m! l+ F6 |; e4 K/-----------------------------------------------------------------------------/  j7 Y; E# o) D# |1 d8 o: x  o

3 w' M/ e( z: M+ N' ?7 p0 T# s, A$ P- W0 }: e
/*--------------File Info-------------------------------------------------------
# m2 f0 V+ D, Y/ v** 文   件   名:  FATFS_Function.c( w: _0 g  q/ Y: u
** 作        者:~风中的叶~    整理
3 [" S" ]) |& o** 最后修改日期:  2012.01.18& G4 Y* `2 z& B  ?
** 版        本:  V1.0& L! M! H1 R& f$ g, a/ V8 W
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
5 f; ^' k( ^+ u& d7 E**------------------------------------------------------------------------------
5 Q+ h& y2 Z! ~, I. \! M. b' h, i** Created   by:  Dt.
* Y' Y) _" L# c- H% j4 j** Created date:  
, D5 {: m3 S) m4 H4 q*******************************************************************************/ : r. V6 X% ~1 Y' Z0 l" G+ ?! ?2 O
#include "TEST_FATFS.h"
+ I# k8 R) a% B6 s& C#include "string.h"
# j  a4 h( G& C1 s$ [5 _2 W5 {6 @& x; q; h1 g
#ifdef TEST_FATFS_EN$ K+ r  l! H' O0 `" {

0 o! X- |' T* j( d7 s, b/ ?9 S) B; t+ R: c' ~; @& f* u) u
3 M+ t! S/ l, k
//检测磁盘是否插好, l7 R' q+ G' L! H( X% Y
BOOL disk_detect_OK(void)% n  l9 M9 h8 h' t  O
{
; j3 s, x7 H4 \- x  h) }    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */, w0 u1 U( Z7 g3 q6 F+ `
        {! O  s2 L" I, y: _+ v( h
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
+ ~# {  f  w3 b2 q- _: U) Q( h                return FALSE;  b- v$ C* H; ?) c# t! M( q
        }/ E* c$ m2 k# o; Z7 \8 r- e8 @
        return TRUE;. C7 |/ {3 K, }! n5 _. {
}. S: ?* L0 [$ m+ D6 e$ C& Z
* B9 v0 j. W3 b) w/ B

# M( s7 e2 [& C3 n! s* P
! W9 @, |% N) N6 M//测试函数执行结果分析
- C) C# j9 n- Ivoid die(FRESULT res)
; F7 J) [9 _, J+ \- y{8 S9 N1 `" ?* T* T6 b5 z% n& ~4 M
    switch(res)
6 m& D& ~* X0 x+ c! t+ a8 e, `        {% L; L6 l, J: [5 f: y/ n
            case FR_OK:        //The function succeeded.
  m2 y/ t" s' ^0 P. ?& ~/ j                {6 `4 t' a) g; j5 g0 T# a  [2 \) R
                    printf("\r\nThe function succeeded!\r\n");
8 h+ k' Y/ J. ~8 G( Z1 v3 K1 r                        break;
5 Z; S" n# `4 D! ?                }
% ]2 T+ ]" H' P                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
: z1 J& K" I/ y3 S( r# i  A                {
* _  g3 ]: e3 p& @' {                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");: r$ q5 `' [# v# D
                        break;: l) k: L/ D3 P
                }0 H4 J' l+ ~2 a3 f6 |9 t7 i
                case FR_NO_FILE://Could not find the file.
% U1 _6 w" J. o+ L7 X, l! h                {$ A- K% {/ f/ w1 I
                    printf("\r\nCould not find the file!\r\n");
/ q& S1 y2 K) P# {# D                        break;) ^8 ^7 y8 ]4 R. H+ H
                }! S2 z1 D0 N9 V, C0 d
                case FR_NO_PATH://Could not find the path
! i7 ^6 b0 H5 t0 S0 B! C                {
- i; G9 |6 H& x) `. p) k                    printf("\r\nCould not find the path!\r\n");' z  i) y' H# z0 Z/ Z
                        break;# d# ]0 h0 |8 A, k  V' q
                }
+ ^5 Y, j8 {: G* Y                case FR_INVALID_NAME://The path name is invalid" l' A- ?1 n+ w4 e
                {
6 [( q3 j+ `6 I. ?                    printf("\r\nThe path name is invalid!\r\n");5 X: v8 `+ r- d+ E9 c) a: {3 x
                        break;
) o# _- g0 d, c: s                }
- ?+ c2 `% h: |* f5 o2 M- L                case FR_INVALID_DRIVE://The drive number is invalid
; k0 z# ]. K0 a) {0 p4 G+ i                {
& E5 b+ \0 @9 I6 A: Z4 }% N                    printf("\r\nThe drive number is invalid!\r\n");" |3 g6 q6 i6 k# W1 B& i  U
                        break;
1 j; [- S* H; l- G0 J* s& \                }9 f* j6 l) [$ G5 D3 S
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. # \4 l- M6 H; \# y* J+ Z
                {2 Z, D' T3 ?2 _& v2 R
                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");& ~* U7 a( p7 _
                        break;
6 U3 t  T4 O1 a                }  R# g' p! J/ i: K
                case FR_EXIST://A file or directory that has same name is already existing
" \( f+ f# y2 Q7 x( g' H5 O                {& i& B, q- \% Y5 D7 _6 m" g7 n* R- C
                    printf("\r\nA file or directory that has same name is already existing!\r\n");# `; ]) H0 ?+ [5 i5 x
                        break;
& V# }5 z' g+ F! v                }
* n1 j4 t: _# s- k5 o//                case FR_RW_ERROR://The function failed due to a disk error or an internal error- g3 T8 L/ j; b+ w
/*" W% e0 I+ S: P5 F! M, I5 b
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
6 R! L, M( S: h% y- h                {
3 P8 U  ~# k( r: j4 `                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");) M9 I8 P3 H9 m- o
                        break;# G8 W' Z+ k( K/ h& T; }
                }
% _& l) D* n3 C" |  `7 Q' v; S*/
3 `" f9 Z. W$ ]! J; H4 t                case FR_WRITE_PROTECTED://The medium is write protected
- l! \- {& Z! _! G9 ?                {
$ P9 |) q! [4 O" [                    printf("\r\nThe medium is write protected!\r\n");
3 n" R, Z! s* b# V! p                        break;
' w8 Z- m( O+ `/ g8 c                }
$ E" d9 M6 {" ?* T, ~/ r                case FR_NOT_ENABLED://The logical drive has no work area
2 h+ J% P& ^$ w; D2 P" W  A                {
" e8 e* I" C% A" y6 Y/ S1 z  o7 p                    printf("\r\nThe logical drive has no work area!\r\n");# e% Y+ J; E0 k
                        break;
1 q+ h3 `! P, A* l; G0 `7 J                }
8 _( I6 {% A; l5 h9 ~                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk9 B5 n- g0 K1 e5 a; {8 I1 H6 r3 U% f
                {3 }; t6 S* M( _, Q/ m# {" ]  U
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");
* c% W; P/ F4 B3 z3 `, ]: L                        break;
% ~4 l( y# m) Q  i                }8 x9 n2 L( D6 w1 M) h9 {
                case FR_INVALID_OBJECT://The file object is invalid: T6 c8 \0 ~+ i1 P: ]9 A. |2 \
                {
! g% M6 \2 p1 ]" \                    printf("\r\nThe file object is invalid!\r\n");' H1 \# b( h& L# G8 [% D1 d
                        break;6 W3 J2 C) M4 c' k. [
                }* P. h6 D; F! E' |* f

- k) A' Z3 T* L- N; `            //The function aborted before start in format due to a reason as follows. , }+ C5 c2 K% W) ~8 x$ o+ q
        //The disk size is too small.   e+ T+ A1 Q% H
        //Invalid parameter was given to any parameter.
4 Z: s4 i- {( F! ^; A        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7. 7 d/ [8 B6 y( V* W' a" Q
                case FR_MKFS_ABORTED://
+ L4 c, `, w' m                {
' D, a& b" i3 y$ p: [- y# L5 |# q                    printf("\r\nThe function aborted before start in format!\r\n");' ^; U5 {/ z& L3 c4 n  _7 w* d
                        break;; M# @% N! D# v
                }' @$ V7 ~: T: S5 ]
                ; o. b, ^' U$ _5 G
                default:; _- [- G& J4 ]: G; g9 [+ B
                {, M9 [, [) n, i, P, |$ v
                    printf("\r\nerror!\r\n");
' e- G' ^$ }8 m0 D% k6 h! Z                        break;) W7 C" v! ]7 E) E6 O
                }        & d. |! L' Z  c7 D8 `: R: ^
        }! O* M4 ^  M, \2 B. c" a, w# O- y
        return;
4 M* S- S0 \- \6 R; ^  c! @" H}7 D3 P7 k3 w+ B: T8 E
void Test_f_getfree(void)//获取卡的总容量及剩余容量
9 p4 i- c. c. J{
+ ?/ y1 _6 A5 M8 Z$ l    FATFS fs;
* |3 l# S/ `- u' v7 ~* P        FATFS *pfs;+ [7 x- j7 X" G+ M6 ~% M$ d. i/ p4 y
    DWORD clust;7 O! u% M' w3 G5 Q- W# H2 o
        FRESULT res;         // FatFs function common result code3 Y' e; V, h  K# R( o+ w/ i( b
$ ?4 R; e; k; k, Q
        //检测磁盘是否插好
3 t7 q9 h* O" |! h* M2 G. T) T        if( disk_detect_OK()==FALSE ) return;
( [; y! B- b. K8 K8 J! \8 `3 N4 c7 W/ H* M6 |/ ~0 b
        pfs=&fs;//指向
9 [# ?. i/ u2 ]/ _6 N1 P        // Register a work area for logical drive 0
# m. R/ ]4 a! B7 I/ B    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间. k% r6 i+ ?& a0 V& P
' s! L5 @! F2 V" B- Q
    // Get free clusters
% d. o( }, J- s    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
8 Y. ?8 o8 k# n- I& O    if ( res==FR_OK ) 1 w, f* X( m% D
    {
( `2 T0 o/ O6 [2 P! P7 Z0 Z            // Get free space
! _3 G- E% _4 _0 [$ H5 v2 `% i        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
. ~6 j; f7 B4 x: a$ t% e                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024, @- K! ]9 @% m( ?
                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024; _. Q- B+ f6 W  h2 Y
        }
4 J$ k  I* i3 D/ J2 K        else die(res);//测试函数执行结果分析: t- X, j3 N2 L7 g! ?
        ( |0 D: I3 D- M" p
        // Unregister a work area before discard it
: ]; ~) l4 c* a' a9 e3 Y$ j8 @; u    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间% _) F# {4 e% r6 A8 S* M' w' _( c" u
}
5 J  D( N% x- s* r- e. M
" B- n) x. u' s% d& {0 Qvoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误! ~, a4 n2 H7 m
{1 ]( L0 u6 c5 _/ r4 [
    FATFS fs;            // Work area (file system object) for logical drive
6 a/ Y7 t6 _  \3 x) ^3 i5 b: J    FIL fsrc;            // file objects
4 Y1 r3 Z  B. b    BYTE buffer[512];     // file copy buffer/ x1 O1 e0 [' Q: C! @: f
    FRESULT res;         // FatFs function common result code
# c, |0 j% L# H- \. C- e    UINT br;             // File R count$ m$ G6 Q" A$ @9 F) J( \9 X
        u16 i;
, Y: ?6 e. [( B        
0 p- o0 f, q% K/ i# M
% w4 ?: @' B2 \* d        char path[20];' k8 r* ~& ^) c0 ^0 H! U

6 ?( @0 e6 C% |        //检测磁盘是否插好
5 q1 P0 j5 O+ _2 i1 I        if( disk_detect_OK()==FALSE ) return;
$ D" ^- {7 L& T! A; S4 q, \
& s4 h+ x9 f8 \' }/ [    // Register a work area for logical drive 07 z/ s* a/ @+ N0 a) R8 ^% g
    f_mount(0, &fs);
8 v6 x; ~% \# B& \' s
' [4 q3 n. H" t, e& \        printf("\r\nread file:>");, p1 k1 d; S7 _0 O6 s! `9 @0 h
        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt; K4 H1 C+ p# S" L' W: E  W
# u# ^# a8 ^# c% Y
        //Open source file- @; R# U. C  I4 @- y$ K
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误$ Z5 S# S9 K* k+ [' D
        die(res);
4 p5 a9 p$ s* P+ H7 h% n, F        
# p0 ?. J% H9 Y: Z5 y$ x+ m$ [: {        //buffer空间设大一点,会提高读的速度。5 o. s' b1 |4 U
        //如果文件实际大小512byte,
7 v+ o0 |- T3 I+ ^7 s        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
: q, ]9 u- A3 T1 P& M        //下面两行主要是去除1s误差。
* l0 N4 m! a! W2 |: S& W7 ~
( _; y$ [8 g) }1 L6 v# y        for (;;)
! l, `) X" x( y5 {& g* U        {
/ A8 c# {, D' l& ]+ o. r3 K5 V                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存6 P  S8 l& s' [: h/ e3 D' N

! t6 T6 p5 T) r$ w6 v8 @                res = f_read(&fsrc, buffer, sizeof(buffer), &br);+ q) c5 q. v! ~% U7 L
        if (res ||(br == 0)) break;   // error or eof        
) q1 h4 Y$ u7 s, Z/ w( R; v4 A               
9 B/ n3 w/ j0 A) T                printf("%s",buffer);        
" s* p: r! }0 x    }) C' l8 x" O( H0 s! e% P( R  G

9 ^- H9 B6 }5 ]: E. x* D                           
) j+ x& j" D. [8 f( B    // Close all files
, ]3 |  B& n2 k4 ?4 b    f_close(&fsrc);4 n$ T; @" n/ [' x, i8 S( [7 _
    // Unregister a work area before discard it
" [% ]0 Z+ L1 |+ |, J$ \! J    f_mount(0, NULL);' w& p( M( E9 k6 t3 ]: \% R2 W9 U
}
" X; i3 p2 m% `4 ]6 M
3 M# y# X( A, X" {void Test_f_write(void)//写数据到文件,如果没有此文件则创建文件
8 t( p) U  U# G6 k' J7 k. `" C{
' K) [( a6 ?! x- [$ S$ }* `& K    FATFS fs;            // Work area (file system object) for logical drive
* d5 V( I& C/ I+ L# {7 {% F    FRESULT res;         // FatFs function common result code
0 G# ]" K# B0 B/ M) b5 X        FIL Make_file;
* L+ v; I/ f# E3 F    char file_name[20];  ]# z1 I* P/ s; {% ^
    char Storage_buffer[] ="0";9 a" L+ x; Q  R
        
4 o. d6 K7 q, \7 U7 Z        UINT bw;
9 `( y' k, D# @        //检测磁盘是否插好+ M$ F) q  F+ w1 H0 l
        if( disk_detect_OK()==FALSE ) return;( T6 T  k, {: A9 U5 _6 P5 A/ F
         printf("\r\n inaert_ok:>");) a$ a3 @8 D- D1 r1 p, X
    // Register a work area for logical drive 08 X( _  c2 D& `! D+ p  B& g
    f_mount(0, &fs);
5 R& g" m  g5 p. ]: q/ ^7 c; ~5 D" V+ t" ?( c& k6 V, t
        printf("\r\n Make file Name:>");3 s+ q3 G% c' i( u" [) R
        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
5 }) O$ E8 u/ Z! P5 M1 ~7 e& F3 l6 S# H  f; |( U% F  T3 T% w- ^
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 - i$ e; [' a$ k/ t: d& m( `  G, g
         printf("\r\n open_ok:>");
- `7 v' [: v( z5 T         die(res);
4 H) ~$ \  `4 T9 u$ m0 i    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
8 y# w7 z9 A7 }% a$ a- z      printf("\r\n seek_ok:>");
5 D/ ^9 X6 J* Y: F: `         die(res);" j' b9 n9 m" L) T
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  5 Z( J. S" w1 Q1 ]
     printf("\r\n write_ok:>");
1 ^% r" [* P2 ]1 Y) j# }         die(res);
: R: E3 m7 `% W( ]* |  e        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
. L$ b5 \( x5 z4 n9 `# L        f_close(&Make_file);//关闭文件1 A: I0 B( S$ G/ ?
        printf("\r\n close_ok:>");
: Y2 ^1 f  `  N7 p% j% b# V! C; V4 [5 w' E  K4 Y. T9 [
        printf("\r\n写文件测试OK!\r\n");
% Z2 n9 o5 @8 U! ]( \8 i! o
+ \# v$ s3 L# A; ?" c* K        // Unregister a work area before discard it
" W( U( W! F1 f* J! J) G    f_mount(0, NULL);: R+ M' B4 U/ F0 B; h
}6 y: s1 B* U+ ~4 N' A

+ ~+ J4 w, R) w//The f_read function reads data from a file.
0 d1 s+ B1 V8 |3 Y9 w# b3 `+ o( l//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样2 h% m, _9 }1 `! h6 o% m
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了- w/ W3 ~0 F. e5 ?- Z5 [
//所以以后要特别注意这个问题。1 i+ J. F5 S/ W
/ Z! s: U7 I/ j" x! j# `
u8 StrToData(u8 * data, u8 len)* n# H$ K7 G6 }* }
{( l, Y4 o& |& [: y8 u( j/ n/ k
        u8 ltemp;
; w% \5 @- W1 l- o2 V/ L0 C        if(len == 1). J4 N+ @! |$ M" W
        {6 K& Z. C; R$ ]  ~, I
                ltemp = data[0]-0x30;
. a2 u& {' w+ o* B# m  V- z2 p) q- o8 f
        }
/ |3 f, J/ j7 ^! v        else if(len == 2)
" ^1 A9 j4 U9 |. B2 ~        {
: }- }& R- }; [4 J                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);) g  f/ f" }2 k( d+ b% ~, X

. x7 _9 w; ?1 L: t         }0 f: b( d* m& |+ r! a* w/ X, w) n; w
        //else if(len == 3)( J  _( O/ f+ E0 S9 ?3 q
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];1 q* a) q$ i/ N  Z( y

7 h( l8 s/ g( [- Z$ |0 Y: x9 \        return ltemp;
- ^/ S2 }: O2 c5 q. h/ n        
+ t$ J( [2 G* a3 q- L3 t2 c}
2 @5 Z) f/ n4 m7 A
& J( H* [# X: K; i' _& E) R7 s* d7 _* B5 B" E7 ^$ ?
#endif
, {7 c9 j. k( d. c9 c5 K# J- E
$ d( ]) ?1 l- u4 f0 ]5 E1 s9 g; p9 w) c, G5 y
/*
8 m5 k* G; |0 y3 v* |+ |int main(void)* _" e7 I6 W0 ~; `2 U: J3 ~
{6 t5 L4 H9 S6 U9 \9 @2 `% D# h
///////////////////////////////////////////////////////////6 k" r/ ~( w4 X% O3 `
UART1GPIO_config();//串口IO口配置
# n2 K$ s6 T4 [7 w- D* ?1 r& VUSART1_config();//串口初始化波特率为19200
3 J+ G" G0 p/ g+ V9 v: R! m//UART1NVIC_config();//配置中断
' Y5 {) u+ R; X, P! R///////////////////////////////////////////////////////////
! x% I; O0 H7 P7 s/ _SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
3 r0 ^3 E' Z+ t% t  H3 W//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它+ F7 d% y5 c8 o; Z3 P% N6 W
Test_f_getfree();//获取SD卡的容量和剩余容量
# O7 j" I! u, L4 }+ R1 YTest_f_read();//SD卡读文件测试$ C6 x( C8 n! @% ?6 F% J$ j- @$ d
Test_f_write();//SD卡写文件测试% e' Z8 c5 n7 @' B% [5 j+ e5 K* ]
/////////////////////////////////////////////////////////// + A; v# ?- X; _4 K8 ?; z5 i
    while (1)/ J, Z% I7 Y) z
    {+ z; Q" l) e9 l3 _8 n% k
        //printf("好的");7 d: p5 k6 x3 R
    }+ k" Z# D; y0 M' i$ A% b9 `( G
}*/! V1 G  _) o3 k3 s( Q) v; n5 h
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6 f: M1 V/ g" sFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为01 b0 p+ @/ n9 n$ h0 V
{
7 a5 N+ p2 o8 h2 H9 A+ h2 D    FATFS fs;            // Work area (file system object) for logical drive
; ^' C) \; }- l& K    FRESULT res;         // FatFs function common result code9 h+ S, S4 `6 U& }4 r* {
0 `0 R; P- \, |
        //检测磁盘是否插好
9 g. d( q2 Y9 ]& N# [. V5 I8 b4 l7 I        //if(disk_detect_OK()==FALSE ) return ;
( R8 S. `0 K7 h        //printf("\r\n inaert_ok:>");
% G1 I1 d& D; }+ l) _        // Register a work area for logical drive 0
0 v7 {8 M9 z) v: K9 N( \+ H9 u        f_mount(drv, &fs);
; s% i0 W5 x* e+ `9 ?0 p$ [        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/; ]5 @8 @' d" k* {3 r+ N
        //die(res);% S# {% Z0 Y( m' D; J, y  N
        f_mount(0, NULL);; ~/ F6 |9 {- C6 M$ g" s
        return res;
1 [5 l( \9 `4 i/ M/ G}
0 ]4 k+ r6 j* J! ^////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
) \( m4 G& o; j8 R' JFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        9 G# n) I1 G% h" S3 }# o
{
5 M" ^9 D0 ~- R! P4 E+ m    FATFS fs;            // Work area (file system object) for logical drive/ q/ x! s/ c, E& k9 C7 O
    FRESULT res;         // FatFs function common result code9 k  n9 ?; J/ [8 O1 u

4 M8 r0 k0 h2 c  M# o3 Z        //检测磁盘是否插好
% f6 \( {  d3 U4 C: F/ ^" n        //if(disk_detect_OK()==FALSE ) return ;
' {* X3 |8 A, D0 g: Z& d        //printf("\r\n inaert_ok:>");
% y7 x, c7 W5 w+ M3 G        // Register a work area for logical drive 0
: Y5 A2 q5 L" [3 m        f_mount(0, &fs);0 i- M6 {- y& v8 O: z$ @+ Y
        res=f_mkdir(path);//创建一个新目录# C# F# e% R6 @4 Q) I5 |
        //die(res);8 m% y0 o  v1 j9 C' Q; g; x
        f_mount(0, NULL);6 u) O# {- F7 U# @. ^6 y
        return res;
: y$ O) _2 ~$ u: D. z$ _}8 |1 c, u5 S* i# p* G
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////* {/ T1 G7 O) _4 [; w8 w$ Z- O% [
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        3 l* N6 y9 [; r1 ?2 C* `. d) C
{" F5 f& I7 \$ {* |7 {# R& M' _
    FATFS fs;            // Work area (file system object) for logical drive
9 c/ X& C; s3 W: Y6 s( k( Q        //DIR        dir;6 f) S0 m4 C, d: P" I
    FRESULT res;         // FatFs function common result code
: }, T+ U: }& ]* r0 ?
1 o+ P1 s* t/ H5 S  W2 z: R8 o        //检测磁盘是否插好, d. B6 i: {! O' S3 g" i
        //if(disk_detect_OK()==FALSE ) return ;( @6 b# n1 K4 o8 ~7 {! H# x
        //printf("\r\n inaert_ok:>");  g4 X  R2 J% t0 t8 |3 _1 ~4 e5 d" M
        // Register a work area for logical drive 0# O7 i% e; T  u- s( X0 _9 A' k
        f_mount(0, &fs);7 s2 N; l+ H4 f- F3 U2 v, c, ~# p7 l6 ?
        //f_opendir (&dir,path);+ }3 x% R; s8 I" {
        res=f_unlink(path);//删除一个目录0 `& X3 b) h$ Q" f2 z
        //die(res);
- L& B& g" _- r5 d        f_mount(0, NULL);
5 j0 |/ n8 B  X# Z        return res;
* E- t2 v- q$ [3 x8 L* h}
- w/ v; ]0 E3 k* }* ^; z$ O" ~////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% {0 a4 y: H9 U  T  M% }! g" uFRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        0 Q9 l7 B0 r* q8 V: H, G
{
/ z3 p( S, Q  q# D    FATFS fs;            // Work area (file system object) for logical drive
9 a5 ]. T9 d4 t: \7 {, W        DIR        dir;
  M" \+ a1 d  _( O# P2 e        FILINFO finf;
3 T& o; R; B& Y3 _3 u" S. y$ M    FRESULT res;         // FatFs function common result code, j9 B4 y- H4 [/ n
3 O  g1 m3 }( ]4 f9 ?! j+ e+ n6 Z
        //检测磁盘是否插好
: O2 `1 U* L# [        //if(disk_detect_OK()==FALSE ) return ;7 z1 O& R& f6 O) k+ U1 f9 O! G0 H
        //printf("\r\n inaert_ok:>");' K6 M9 `( g9 Z- e* d$ t
        // Register a work area for logical drive 0) Y; ?- J, r* W" K# L$ w
        f_mount(0, &fs);
3 |3 T: p$ o' H2 d: c  ^/ j9 j        f_opendir (&dir,path);: |3 U/ I( U8 I) S0 C
1 N: l$ |+ `+ X  c
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        + S. Y8 V5 g: F4 O
        {strcpy(*(filename++),finf.fname);
: F; Z. `4 W  A# y0 f) `2 i        //printf("%s",finf.fname);1 p0 x! V4 }4 ^6 W4 M
        }, t; h- ^3 s; r6 K4 m  h
        //die(res);4 E! `$ ~) j( Z; j
        f_mount(0, NULL);
. O4 ?) w6 g) \+ m: f4 c        return res;( b( U, m, O+ Q5 j* i6 g
}
8 m3 F3 ^+ r0 m' L////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////, g& |" _, Y) R
FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名- F1 I2 K( W5 |/ g, H( i/ @; x
{
6 O( ?$ E( G+ t) n* E    FATFS fs;            // Work area (file system object) for logical drive
. t, M2 N4 t0 M1 E: E6 ]        FIL file;
1 D9 ]; p% w& D* W' z& D/ z1 F    FRESULT res;         // FatFs function common result code
. z6 t9 T" {# [9 }( ?) q* l# W, j* v" J
        //检测磁盘是否插好9 S. \8 n4 @! P/ `" U' N4 l) T
        //if(disk_detect_OK()==FALSE ) return ;7 P* I# J. l1 n  ]
        //printf("\r\n inaert_ok:>");
6 [1 b, `! D1 t1 r  [        // Register a work area for logical drive 06 ^: p( w7 F" O
        f_mount(0, &fs);! c, Y5 f4 M" Q- Q
        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
- |2 y9 W) V9 _                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
! o& `. {1 c! Z# |- G, q, a5 W                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。" l+ y- \6 A: @; S& s. \' ]; i
        //die(res);
5 P( n4 L( G& P% e8 Q: T" l0 t* K        f_close(&file);//关闭文件
0 Z6 r1 ?. r0 J- R7 B% j        f_mount(0, NULL);5 F1 |* g5 }6 a( b( }
        return res;( u& P7 j, D5 ^6 j; w0 f
}
/ C- M, m7 K: D% m/ {////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////' M2 t+ o4 r& s& P; x3 [
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");          m% }% m1 g* i, O$ s* u
{3 v; h7 j+ Z! K2 _0 b# r5 z/ P
    FATFS fs;            // Work area (file system object) for logical drive+ w1 @; v, t/ x/ P6 Z; U
        //DIR        dir;
0 C: z4 O& k( L/ Q; x0 c    FRESULT res;         // FatFs function common result code
: e/ g" J- U: x1 R2 W; Q# t+ B3 q1 I
; Y7 U7 R+ I$ w- M9 R/ f# `+ k        //检测磁盘是否插好
/ E% F  \2 J* j4 @' {        //if(disk_detect_OK()==FALSE ) return ;
, X; b# ^" z5 S  W8 t  ^        //printf("\r\n inaert_ok:>");
0 ~: L5 E& h% w5 b( {% G6 q* b        // Register a work area for logical drive 0
' A: a) V) |/ U) K# t        f_mount(0, &fs);$ B7 t1 B3 C7 T/ X
        //f_opendir (&dir,path);/ |; X2 ^% ]; C+ X  S* F' [
        res=f_unlink(path);//删除一个文件
+ b% ~5 n, e9 ]* G7 _        //die(res);
* j9 f& i6 x- [, ^- ~        f_mount(0, NULL);
. K. M* e6 L4 f9 F. x0 k$ t        return res;; I/ x/ ]3 ]( I2 V. Y
}
! k( }4 H8 \5 u2 y' m+ v////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
1 H2 {2 m( {, Q' N4 \- MFRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数
' S3 j+ J, l5 [$ U{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));/ o: b: ^5 J  c; g
    FATFS fs;            // Work area (file system object) for logical drive
8 Q$ l$ O; l8 E! @2 G: ^6 o% u' I    FIL file;            // file objects5 ]" _) n* ^* a) s% ^+ F" C# X
    FRESULT res;         // FatFs function common result code) G3 J' p) D, E" g: J2 y3 X9 @+ l
    UINT br;             // File R count 文件读回的字节计数$ _) U$ U+ y4 L! Q- A- B0 }6 u
        //u16 i;$ ^- m9 \9 X' t4 k! s
        //检测磁盘是否插好
$ S* V1 @5 D9 W1 @  X$ r2 N% a        //if( disk_detect_OK()==FALSE ) return;
/ i7 I" R9 B* O6 S5 c1 H    // Register a work area for logical drive 08 M' ?5 ~& g5 ~  _# E0 l
        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';. C* p  ^/ Z1 @
    f_mount(0, &fs);9 B( }9 H( q: K
        //Open source file
4 n; b' S1 ~3 R, k7 ?    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
1 w  z9 W+ ]. Z) c# v/ k        //die(res);
6 d8 P9 n) p8 u' U% ?        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处
0 D8 h  M! o3 M7 B0 u( n& q        //buffer空间设大一点,会提高读的速度。
2 P5 j4 C7 U- q1 C/ I        //如果文件实际大小512byte,$ X% X5 x6 S/ a5 ^, |$ Y9 c
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
, ^, I8 t0 f6 M& |+ @0 n        //for (;;) : v* k% q5 z2 @
        {
' ~( a, i1 u3 d2 A% T2 v9 K                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存8 C; ?6 ^! v9 j3 E& j
% c; o# ~  T( c( ^  b6 s
                res = f_read(&file, buff, strl, &br);0 _+ h# k/ S" C
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出' l% j! _8 p9 h2 X
                ) z$ G* c% z( {4 K
                //printf("%s",buff);        5 f% P" Y9 u8 h' }9 }
    }                    
' r- z, r3 t# b% S" d# D    // Close all files
( D1 J$ k) X) D0 p    f_close(&file);
/ V7 f! E5 s- k! q4 G1 o* x: Y    // Unregister a work area before discard it
2 n/ z! j2 p" `9 Y8 c    f_mount(0, NULL);1 a3 T; d* W: G
        return res;
4 I9 v% ?; F" J' L}
( C! U! F9 `; }; _: G; r' F8 U////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////& ?& r& Y' j, J! r: E1 S6 g7 r1 ~
FRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数8 t0 h" D  x& m5 s; p$ a! g% C
{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));4 h/ N8 P% ]  [, G8 B
    FATFS fs;            // Work area (file system object) for logical drive0 y1 q) p! E( l9 J! {7 g
    FRESULT res;         // FatFs function common result code$ w: {3 ~9 d" s- f+ t9 i
        FIL file;; ]: E8 u+ g6 R. C+ j$ z
        UINT bw;             //文件写入的字节计数
/ q) p- ]( k6 ^" b        //检测磁盘是否插好5 N* N7 S( Q$ g. ^: E3 \
        //if( disk_detect_OK()==FALSE ) return;
$ B/ i# s0 L$ c1 |& z: p    // Register a work area for logical drive 0
/ L. u  n  x$ k2 u+ L# w& I    f_mount(0, &fs);
4 C5 ?' v1 z2 Q3 O, u( ?    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 # Z0 }- t' y0 e$ S. {1 y
         //die(res);
# v6 t% w, k" S/ F4 D9 \    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 * r* ^% B- d1 M# h
         //die(res);
" x" W6 E  T  @        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符7 ]/ G1 _; X8 V% T3 P. ?$ L, _
         //die(res);
( B. a9 f( L6 h        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
/ b. k- T1 F# F6 b0 q& W' q' D        f_close(&file);//关闭文件
! G0 E% ~. U' P& D        // Unregister a work area before discard it
( N1 F" d' c6 q2 {$ z) B  o    f_mount(0, NULL);# k% v: l9 T5 L6 z' a5 \$ ~) Q
        return res;8 |2 k$ z$ a1 T& I
}
9 g3 w7 U* I+ j$ }8 g. v3 A////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////; d7 R* \0 r. x* X2 Q; k, A
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M
/ E) Y" S; }5 Z# S1 K% M& h% [{
, _9 P8 x, s+ A0 {    FATFS fs;# `8 T! k" v8 B) X& R% ~3 o# y
        FATFS *pfs;0 u$ {2 a% m: u0 x! K/ J
        FRESULT res;         // FatFs function common result code
0 m- ^. r, j1 _* t4 z9 N9 [        //检测磁盘是否插好7 d2 B8 Y! r; ?% T! [
        //if( disk_detect_OK()==FALSE ) return;5 m+ ]0 u9 r% e3 C0 a5 q0 l
        // Register a work area for logical drive 0
; N& w4 V/ K2 z9 H/ P9 j        pfs=&fs;//指向
3 n. @. ^' Z; Q: o1 _1 s2 o. D: u5 S, o    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间. Q1 z. F# R4 \
    // Get free clusters
' E9 o# o) r3 a0 @; F    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
  F$ U$ ]  W! h0 `; m% V1 S  I. a        //die(res);
: u" j, ]( T% x. ?: `% A, l        if ( res==FR_OK )   e" X# I2 e6 D4 W" {9 d
    {
7 K6 I  j. y( O6 a- t            // Get free space0 x6 {" b7 Q3 }9 M' x
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
; A4 Z* z  A" n6 D/ A6 I               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
; ?& l* ]: g- a7 l4 r# U                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
0 [' f* h) K: e6 l( m4 v         *freem=((*freem)*pfs->csize)/2/1024;- c) g2 X# Z( O; s
        }9 i! X( Q& F! f2 V2 e" F
        //else die(res);//测试函数执行结果分析
+ J) }% r0 _1 I4 s. W+ o- }1 T: ?! i        // Unregister a work area before discard it
. z3 W; \- @' C- z    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
2 _/ [; W; I( f$ [" x( L5 _: d  _: T        return res;
6 U: U! A5 G  i8 s+ M- u}7 U. E- j8 |/ a2 W0 u/ C0 Y3 P5 X
6 [! S. [# I6 F4 v

% W; P) T) x; Z( T
. ?& [: e% \9 U9 X" o" D/ Feb 26,'06 R0.00  Prototype.0 i1 N, L0 S1 |
/
9 [/ H# E! i( |( Q2 |" [/ Apr 29,'06 R0.01  First stable version.8 K, N9 C, U* `; z/ s9 q7 P
/
5 V$ H6 X$ N; @. o6 ^( V  q% {- ?+ h/ Jun 01,'06 R0.02  Added FAT12 support.2 E6 A% G5 \- J" H: f
/                   Removed unbuffered mode.# q5 j- J# c9 {) X, n* K( J
/                   Fixed a problem on small (<32M) partition.6 a- S# T4 q* k+ Q. f) d
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).. {8 w! ]3 r( E* S0 M& T9 k
/
- ?2 l# J# g# A  ~2 j. ?9 R) X/ Sep 22,'06 R0.03  Added f_rename().
- c* I5 j) b. X) D0 i$ O- L! L4 \/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.
6 }. ~7 [* @7 _/ \2 G2 |/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
7 [& Z2 p: r4 t6 Q! b4 c% K" f# S2 v/                   Fixed f_mkdir() creates incorrect directory on FAT32.
8 K3 `; D! V7 R9 B' Y+ r. \# _" z/
3 |, ]* I$ s0 T  O/ Feb 04,'07 R0.04  Supported multiple drive system.0 o9 v" G& O6 Q0 _9 n! u3 O
/                   Changed some interfaces for multiple drive system.: {$ m6 T0 [! A, _. x1 k
/                   Changed f_mountdrv() to f_mount().
% k- Q# m+ t4 ^5 O$ F/                   Added f_mkfs().
' D# p0 Z8 |; q  C2 }% }- f6 z/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.* ~( o) f6 J# u
/                   Added a capability of extending file size to f_lseek().
) P9 n5 L% N. J6 x- o9 z/ W; `/                   Added minimization level 3./ s. `: G# ~" x5 U
/                   Fixed an endian sensitive code in f_mkfs().' K! y2 p+ g0 b$ T4 x0 S7 I/ R
/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.7 F4 r5 O: J  d% \' n3 z3 r; c6 H
/                   Added FSInfo support.
0 F9 {# M5 d& T; D/ B/                   Fixed DBCS name can result FR_INVALID_NAME.2 S  M& E0 Y; M5 Y
/                   Fixed short seek (<= csize) collapses the file object.
" q5 }/ P9 m$ w2 q, o/: B: h% [/ e) S. A
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
; f, d( A; t' {+ K/ j" R/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.2 N* X4 a7 q% v' U: F) T! o1 A5 M
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.; J& f, t+ ~! ?; m' W$ [
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().( C" j$ B( w4 K
/                   Fixed off by one error at FAT sub-type determination., p8 n* ~0 j; O" L5 g7 s
/                   Fixed btr in f_read() can be mistruncated.& U0 s4 c* S) Q3 c3 r
/                   Fixed cached sector is not flushed when create and close without write.
0 Q- |. S& p! k/ N% X6 j/" ^- V. ^. F" _5 h
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().; y% P- i8 `1 S, p6 n5 J
/                   Improved performance of f_lseek() on moving to the same or following cluster.
& p+ ?# @2 R5 _) e9 q% i/  ~# f# T; W. j+ w" B
/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)% }8 @7 O+ h$ s. n* V
/                   Added long file name feature.( {9 J$ D+ U' Y2 \& U
/                   Added multiple code page feature.4 {2 g( E* S, k
/                   Added re-entrancy for multitask operation.
. r; i) `6 i" x) ^: @1 l* O/                   Added auto cluster size selection to f_mkfs().
6 D4 ^- e* R# _/                   Added rewind option to f_readdir()., A* b1 i* E( F7 Q9 b0 s9 J
/                   Changed result code of critical errors.
1 c; E2 Y0 {; r% q& |  M/                   Renamed string functions to avoid name collision.  i, ]4 ~# J. F) M; S/ A; \! D
/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
* U" H: W8 p+ r; g, g; F/                   Added multiple sector size feature.
4 w  w8 a7 O  A' ?/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
" O; W% [  `% }4 i) m8 |/                   Fixed wrong cache control in f_lseek().& l$ W- w( p  O
/                   Added relative path feature.
4 u* q7 Z  P: b/                   Added f_chdir() and f_chdrive().
2 k- G, Y  b' D/                   Added proper case conversion to extended char.
3 E- H' v  E" S. O/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.
8 E. G7 `: {% T- K/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.3 ?* g$ y9 u/ S0 I! b. {& T, L* x7 P
/                   Fixed name matching error on the 13 char boundary.
4 y% x9 |# R# x3 ?/                   Added a configuration option, _LFN_UNICODE.
; X' M( e( h1 s( m/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
$ g7 S9 A/ g" I0 q' Q' a1 u1 ~9 l/
/ x- N) S9 c3 r6 B8 g! g# _. p4 t; Z/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)" c. r% N2 a) ]" v8 I* b2 M7 c
/                   Added file lock feature. (_FS_SHARE)
( X$ I3 F; R5 a/                   Added fast seek feature. (_USE_FASTSEEK)
* N0 x( w4 W% W5 s& R' p: G" [7 j/                   Changed some types on the API, XCHAR->TCHAR.$ g/ i0 F& w) Q+ y) M' J8 G6 H
/                   Changed fname member in the FILINFO structure on Unicode cfg.6 G3 l8 O# e3 Y+ t8 P1 r* a- o2 U
/                   String functions support UTF-8 encoding files on Unicode cfg.
8 n- f1 T  Y, `9 a0 {/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2). b. S2 L5 F5 `. A" f
/                   Added sector erase feature. (_USE_ERASE)
0 [4 ]: Q, k1 |/                   Moved file lock semaphore table from fs object to the bss.2 A2 L9 p! K: l3 X4 s0 N6 C
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
$ W. G" l$ M3 Z1 ?. _/ I/                   Fixed f_mkfs() creates wrong FAT32 volume.
- {1 t2 s0 D0 M8 i+ j3 _+ {/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
& U: t- D/ ^4 o& E, d, c- j3 ^/                   f_lseek() reports required table size on creating CLMP.
' R3 k% t; V1 s6 b* w2 a/                   Extended format syntax of f_printf function.) q' g. j; `# k' x8 d. a
/                   Ignores duplicated directory separators in given path names.6 @: C+ d+ h. ]- o: _$ @
/
5 y, w$ k. e) s( ?/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
! z9 d8 g! _( _: ^+ c; {/                   Added f_fdisk(). (_MULTI_PARTITION = 2)) [5 |. S: _. ^( {/ z0 Z
/---------------------------------------------------------------------------*/0 M8 U$ t8 J3 [7 H" T9 ^& g
' }9 n0 y5 n! w6 L. O9 I9 l# i( t

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 21:39 , Processed in 0.063090 second(s), 34 queries , Gzip On.

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

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

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