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

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

[复制链接]

该用户从未签到

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

EDA365欢迎您登录!

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

x
自己移植的SD卡的FATFS文件系统,采用最新版FATFS R0.09,并且有详细的中文注释,和操作测试程序,完整的MDK  STM32F103工程。下载即可使用。
8 m5 v* N* t/ K% r/*----------------------------------------------------------------------------// v* {) v1 }  ?! T% H, @9 L: T' J
/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
$ E  L5 x' {4 O/ O7 L/-----------------------------------------------------------------------------/5 X( T0 z: T& `& J& D4 N
/ FatFs module is a generic FAT file system module for small embedded systems.! I/ _7 l6 F) S: E
/ This is a free software that opened for education, research and commercial$ ^! P& ^; V: O, X' q. {) b. }% N
/ developments under license policy of following terms.7 ^6 A6 g5 f" o; N5 p
/
5 p$ M) \# @. m/  Copyright (C) 2011, ChaN, all right reserved.
: i- G9 P6 J/ \/
/ Y4 \8 @/ d9 A9 A3 i/ * The FatFs module is a free software and there is NO WARRANTY.; x8 @# R& ?9 a/ H. ?. P
/ * No restriction on use. You can use, modify and redistribute it for
. S$ \4 H  Q1 g  A0 p9 i+ [/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.5 A+ R% N8 W, Y! `
/ * Redistributions of source code must retain the above copyright notice.! O8 L6 t: w( c# E& H7 q, a5 B5 E
/; \, I$ }! L# {1 p% ~- k
/-----------------------------------------------------------------------------/5 z) p  F' w9 a( [

9 x9 F: A$ V2 R# D/ d5 N$ g/ {9 r( y% W; s1 H6 i
/*--------------File Info-------------------------------------------------------8 ?! W; a8 U0 {# k: S' |0 f0 s; \
** 文   件   名:  FATFS_Function.c/ O0 U8 i' J0 [7 e1 g
** 作        者:~风中的叶~    整理6 ]; ^; q; M1 R2 n+ e* d
** 最后修改日期:  2012.01.18, N. c3 A; {$ T
** 版        本:  V1.0& L: a- _9 z8 O
** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出' j0 y! f$ r6 g2 Q; N1 o
**------------------------------------------------------------------------------
. c5 E/ l% J, r: J+ d$ t** Created   by:  Dt.1 U0 p- B$ [9 ~( ~- G- I8 ]( k* M
** Created date:  7 N4 w2 X& R: u7 _
*******************************************************************************/ % ?# d* x* X" Y2 U, ^
#include "TEST_FATFS.h": f0 {- y0 \& b( Z; B. f  N
#include "string.h"
. m$ C. G4 ?" w+ }6 g. B7 I9 [" I0 f  H* r2 T9 t- T; H' H
#ifdef TEST_FATFS_EN$ v9 D2 \1 d8 ?- Y8 E/ \' ?

! j+ V, n) i) K% h9 L; F7 h/ Q6 R6 K# D1 Y
1 F* R' ^% ?  g
//检测磁盘是否插好0 Y  c8 X5 c7 [# N/ u
BOOL disk_detect_OK(void)
3 @- H+ H- ^# X; C; C2 z6 z' K{
( x, C4 s6 r6 @# c5 b    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */5 o7 E7 r/ ^. b( \+ s* A
        {
) ^8 _. |) d+ T            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");! @. M' o, N1 Z$ Q
                return FALSE;, h1 R" K  x5 ?/ l; u7 s
        }5 N2 \1 y3 C: a/ Q
        return TRUE;
- \9 W$ s; g( o, |' y- [- ^3 n}
9 q- h7 `6 }8 D& ?+ R" N  b, j( ^8 R0 F0 ]# v9 r' G
5 M/ Q0 Y% {% D, ^0 ~* Z' r
1 j0 p7 L1 @( b# S$ _% `: \& W
//测试函数执行结果分析
3 e/ _+ W' W3 _+ c7 p  evoid die(FRESULT res), H7 C+ g& A" i
{. ?8 E0 W4 @1 e$ [" @6 [
    switch(res)
1 w) P1 e+ \# E        {3 f) M% N9 C# @& O8 @0 f
            case FR_OK:        //The function succeeded. . \2 j# ?; ]- n/ d
                {$ n5 W. {# K2 ?# L
                    printf("\r\nThe function succeeded!\r\n");+ p: _2 A% [+ b% D9 F2 Y8 `
                        break;
2 S! K% t0 w# k- S                }
( G) O% g& ^% k) H' @- L                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
/ q2 r+ P1 _! y, t" m                {2 k. N. w: P8 e8 _# X& C/ p+ B
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");
) u& i. K$ z: l                        break;. z8 {( G( v  j6 H3 n* U$ \
                }& H; H8 @- v1 i" D' g
                case FR_NO_FILE://Could not find the file.
$ Q& i: k+ r/ J$ _; q# _                {% X* j9 h- k: V, n) u5 A
                    printf("\r\nCould not find the file!\r\n");+ P9 j! r2 L6 L# w( {
                        break;
& W, e" m% k0 D5 Z& M* x                }: O9 Q; A7 v' c7 g' G
                case FR_NO_PATH://Could not find the path4 E/ }. ?! C& ^8 q2 H- Y
                {
' ]  L4 Q; u+ V                    printf("\r\nCould not find the path!\r\n");
: S1 e/ ]7 B0 ]4 v% H                        break;
: w7 B, Q) ]. w3 k                }
1 E9 H+ x$ j% I! T- s                case FR_INVALID_NAME://The path name is invalid
7 T! g" Y$ [7 C2 s; @/ @- ?4 G* F                {1 e. V  |8 u9 |# e! N
                    printf("\r\nThe path name is invalid!\r\n");
& l- ?/ r- u1 \0 B2 X                        break;
) |- a/ ]1 O  i& O. q/ |4 m8 R                }
, C) y, k7 i4 A0 d& V                case FR_INVALID_DRIVE://The drive number is invalid5 w( p; y# O* W5 i+ `- K9 ?5 N  F& T& w
                {; }  W$ N; y7 `! S! p; L9 _4 a
                    printf("\r\nThe drive number is invalid!\r\n");* _  h! ^$ p* J
                        break;# t1 s; W4 f' i* F+ N) H
                }
- C* p$ V  g4 }1 f+ A6 R% r                case FR_DENIED://The directory cannot be created due to directory table or disk is full. ! ~7 y+ X! j% j8 i
                {
. G7 ?8 ]) ^  F* f  y) Q                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");, F7 u1 [- p; R2 M( U! ~3 u
                        break;
$ x7 x4 ^2 h: v% B* g                }2 ?" v  `! ~* p
                case FR_EXIST://A file or directory that has same name is already existing
$ G8 l% R) T; }# ~7 J3 j1 l                {
; Y8 k; L3 t  u# M2 y& M) A                    printf("\r\nA file or directory that has same name is already existing!\r\n");! L, l' |) J$ b# P+ c1 f
                        break;
% h0 f* e4 p' F4 V; Q! R                }& F! t. D6 q* e, i
//                case FR_RW_ERROR://The function failed due to a disk error or an internal error) {+ k3 H4 W5 T5 S
/*
; a( t/ t: A$ R% w4 E                case FR_RW_ERROR://The function failed due to a disk error or an internal error- K' `; ^; k( K' U1 \
                {6 b  f0 C1 Q7 ?% [+ M0 X* P* v6 {+ y
                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
' d- B' q, o7 Y' y. Y' t                        break;0 ?9 ?3 U8 Q# V2 y; O
                }7 @8 G( P  U- k8 @* L# P
*/
9 B9 }5 \" C$ W3 ?1 V                case FR_WRITE_PROTECTED://The medium is write protected
7 F; ~0 z5 c5 ?                {
: d# F% P4 x8 y! |. K) Q4 G; X' S                    printf("\r\nThe medium is write protected!\r\n");; }! j) [9 Y: B
                        break;( K" V. E/ M, h
                }, E/ N& Q) P6 Y/ t0 R# p
                case FR_NOT_ENABLED://The logical drive has no work area( o" ^6 {% S+ a! ~; e6 t# B
                {  ~" `& `' p4 h. U% u' L
                    printf("\r\nThe logical drive has no work area!\r\n");# ?( V9 P3 e: W2 ^9 u" F, t
                        break;' Q4 ~3 n7 j/ @
                }
& E/ j* N. D) l6 c$ Q9 ]9 c2 Q                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk" K5 c2 A* V( {' ~# P
                {. ]: J. m7 A/ x3 b! w4 j7 I
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");, M/ s% C  m' ^
                        break;% q5 X0 K) o8 M/ U2 K  V
                }
5 [( Z8 O/ E& \5 E: F9 d% d5 U* S                case FR_INVALID_OBJECT://The file object is invalid
5 T9 ~/ P9 D. T: S* T4 f" Z* y4 N                {
- ^9 R6 o3 a( G2 L                    printf("\r\nThe file object is invalid!\r\n");
2 o5 N+ L1 Y7 i                        break;: O& |" v/ }1 x7 n% @5 _/ ~0 v
                }$ a& V" @6 z/ O3 n, P

- k+ V! h8 r' g* O% w* F            //The function aborted before start in format due to a reason as follows.
  y& ^' N9 \. P5 m1 }7 E% p        //The disk size is too small.
* J& B$ x. }4 z0 l! d        //Invalid parameter was given to any parameter.
6 z# O1 N* p" }) {        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.   X2 K. i2 A) H( ?0 j
                case FR_MKFS_ABORTED://
2 C9 A0 i/ O" k/ R                {
0 a1 {3 h& t' F6 i% K/ E+ A& X                    printf("\r\nThe function aborted before start in format!\r\n");
( h' w9 g# w3 K$ T; \3 v% B                        break;
7 m& m$ u* _% w0 Y# D' ?                }" I: C. e% [1 p4 T& ]# }8 R
                0 ^6 d7 a; O  r( d" R. J
                default:
& C3 }1 W7 U1 N% q- R7 s                {& S/ t/ b( T* u! C0 C
                    printf("\r\nerror!\r\n");( ]/ ^/ p5 k- ^4 ]# @7 C. ^
                        break;
& n/ R, `- B0 T9 L' G                }        
8 |4 r6 Z" E* [# C4 s+ }        }: j% X) y/ v2 \2 `: j; n
        return;
+ ?* F8 J+ K. q}
) U% a/ c, r! c/ I, d( m9 bvoid Test_f_getfree(void)//获取卡的总容量及剩余容量
" [% f6 Q/ U) e6 c{
3 \, R# \4 Z8 G1 r    FATFS fs;
; y3 H# `: u0 f  g( g# P8 S9 c        FATFS *pfs;; m  G" T1 v9 [& d
    DWORD clust;  a7 A$ U- e; ?$ y
        FRESULT res;         // FatFs function common result code9 v% @) r0 L( r5 n; B0 L
& `% m. ~1 I2 k
        //检测磁盘是否插好
9 c4 w3 x/ m8 o  V0 L        if( disk_detect_OK()==FALSE ) return;
  l( |  \3 T* c" w; D
) }8 A* [( T" T. L' O1 y; s        pfs=&fs;//指向# n7 K+ q1 Y! y3 E  k2 X
        // Register a work area for logical drive 08 r$ N* N. |+ b% S- s
    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
  n* a: j0 ~7 d# [1 U4 [
5 U+ @6 ~. i8 u    // Get free clusters! J/ S* X0 p' D. Y4 i2 `3 `' E
    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
4 \& h- h9 }" T  [, @. t+ U    if ( res==FR_OK )
( {$ Q% {0 A. l6 H$ `; y6 ~9 G    {8 ^' z+ g1 M! H; {5 P; w- Q- ?$ J
            // Get free space
5 `/ G  t! ~8 ]! B* A$ S8 y        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
( _% R4 d/ w; u! C& m5 I                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024( ?, Y4 t5 y; e0 L4 O
                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10247 V6 `: O% f% x: w( }0 |$ ^
        }
! c2 {/ D7 U3 t- d( p+ K0 H        else die(res);//测试函数执行结果分析
4 e* ^& E5 W9 ?6 y( s; r        # ~- o. K9 F  W0 s' H0 w
        // Unregister a work area before discard it* I4 E  w/ T2 |: Q& R0 r
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
, ^' V$ f0 ^! S# t}: n  y( Z, E3 C# g' \9 F

- s1 [1 v7 _# h! gvoid Test_f_read(void)//读文件的数据,如果没有此文件则返回错误1 d2 p9 \7 I( v, e: ~
{
" k8 W0 a8 b  F    FATFS fs;            // Work area (file system object) for logical drive
3 U4 M  s$ u4 G1 u; Q% H8 p1 y    FIL fsrc;            // file objects" P& @! q0 w: `9 c& L
    BYTE buffer[512];     // file copy buffer* A3 C; M9 |7 b
    FRESULT res;         // FatFs function common result code+ y  u8 Q; m5 D* d# J
    UINT br;             // File R count) C1 ]1 p1 o2 N! f
        u16 i;- E3 z9 F. H9 |6 P
        
, y  K' q8 V; I9 u& S& V, O- v$ ^* Z4 N2 f9 n. T
        char path[20];
* h# E6 ~( |- `3 g3 d5 r! C+ s$ ~9 M$ G9 F
        //检测磁盘是否插好
; G7 u. I( N* `8 ?2 o5 P, L        if( disk_detect_OK()==FALSE ) return;) x4 j" ]0 ]: j6 [5 s
4 D0 I; T8 w) t7 N8 X
    // Register a work area for logical drive 0
8 N) ~  D/ X9 r9 r8 k  X    f_mount(0, &fs);; \' i  g6 H: o/ O" s" X1 w9 C  k
/ g5 r% Y! O( L: ]* E$ @
        printf("\r\nread file:>");
6 v1 D, r: |  U        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
# F1 ?7 [5 k4 g: y. Q4 x7 b3 `7 t5 f4 {
        //Open source file) g7 i( @. o8 U: D9 v- i0 ^/ P) c: M
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
$ c7 u) X% a; T5 `& y( [4 e+ P% j        die(res);  ^- G) M( z& u, l% F3 A9 g
        
0 Q! b8 D8 G/ X# \        //buffer空间设大一点,会提高读的速度。  U* Y/ F  [. D& E0 b1 g4 O9 q
        //如果文件实际大小512byte,
1 C6 K+ g* A3 C' S$ h  K" ~  a        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。( i5 ~9 j: c' |& x; w, f7 \
        //下面两行主要是去除1s误差。5 _2 B9 Y, q+ N# V9 ?- p% t! f

% B  n. h+ H2 s        for (;;) ( G" n" d" W$ I7 f% Z' r$ b) ~: h
        {
1 z, _: h& ~, }4 G' a6 ~                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存
7 {& ]  P/ }0 [, T: P+ m
# R$ e9 Z5 f% s  f. y. f; ^' H                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
/ h3 a" c6 z; [9 v2 ~        if (res ||(br == 0)) break;   // error or eof        
# |. b" |$ ~* B3 q8 y# t               
3 p9 g" p/ m5 ?8 V% Q% _8 d9 G& }                printf("%s",buffer);        
2 R1 A, y- G' T% n) T; I# Z    }
3 q6 }6 J3 G5 [( I: B- h7 e: a. }. C, V7 Z: k9 S2 z+ d
                            8 P/ }9 d* @. C8 [
    // Close all files
4 M* V5 d" Y) m    f_close(&fsrc);
( P  O: M6 V* I# V2 D, M    // Unregister a work area before discard it6 N. z8 [" B) @1 v8 H" l( g& F2 s6 P+ J
    f_mount(0, NULL);
" y5 a% e% [; D0 Y% y9 M% k2 S+ h( _}' W/ J' [6 I+ A/ X

5 n; \' J, {% R5 u! J% {5 tvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件- ?! ^- s2 B- ?: X. t* i! y
{" A9 u$ M+ K$ c7 t. Q2 X' p* @; L
    FATFS fs;            // Work area (file system object) for logical drive1 b: M$ ?; S1 j- v0 P+ H
    FRESULT res;         // FatFs function common result code
3 v) [6 S6 s; i9 v9 Z# _8 z        FIL Make_file;) C+ A0 X' n9 a- |
    char file_name[20];# }0 c4 x5 @0 o$ [5 O  J
    char Storage_buffer[] ="0";0 P' f$ _7 K5 M9 D7 R' x( w( t
        
, q$ G7 d6 a% M# h' U( _+ S        UINT bw;" d- r0 f6 }: x: j
        //检测磁盘是否插好& m; N- T0 [0 K8 {. s
        if( disk_detect_OK()==FALSE ) return;5 ?1 Q: N9 A1 N4 G' p! d; i
         printf("\r\n inaert_ok:>");
8 H( Q" T9 F9 S    // Register a work area for logical drive 0
/ s( V( T" ?  X3 D    f_mount(0, &fs);
9 `8 ^. W# M1 }; S) p6 S& U+ E: l8 V' _
        printf("\r\n Make file Name:>");
1 w8 [& G5 p6 Q  `9 S! W0 C        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
; S& i8 O, Y, C4 L6 P5 k, X0 L0 B1 y* n6 L: o/ S
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
' m8 M% h, ?+ O3 c& L! r  L! e         printf("\r\n open_ok:>");. N) H* l6 c3 @2 P- ?- C
         die(res);
  j/ d7 b! F, |8 S& p# L# i! f/ C) [    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
: t$ E- ], x! A+ ?" ^      printf("\r\n seek_ok:>");* H7 J* g+ j* |& r
         die(res);; A4 s- R" t2 {" O" W. N7 e" v" h
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  
1 ^; F1 y8 \8 U. i1 x6 f     printf("\r\n write_ok:>");( {7 J4 T- T: T& T- a$ k
         die(res);
" T, B8 A  Z$ K( |, u' W( L* W( a        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  ! k7 A( C6 L; |8 ]  f% C3 S3 e
        f_close(&Make_file);//关闭文件" w# s8 E" K. v1 y; S, K
        printf("\r\n close_ok:>");
+ n5 ?/ x8 @1 `1 Y1 x+ k( h+ ^8 _9 ^1 p6 n/ G: U
        printf("\r\n写文件测试OK!\r\n");$ p. Y3 d2 G; y2 B% ]

, a5 y8 N) K9 L$ I& H- B        // Unregister a work area before discard it
0 A2 e# T0 a% v6 Q4 V; }: X    f_mount(0, NULL);- R# h+ o, G2 H  w% b+ E& j* }: N  b
}
' e5 r8 f) m+ [7 Z2 ^
7 f+ k# N2 P9 Q* Q7 B! D//The f_read function reads data from a file.% T& w5 l! f+ ?% A+ `" ^1 t8 M
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样+ e) Z% W4 `4 B( j2 P, [
//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了1 h! }! m# g' ~" A: i
//所以以后要特别注意这个问题。( z. d$ u. m2 I* p2 K( h" b7 ?' y: @
+ j; y  r8 A$ C, H3 [
u8 StrToData(u8 * data, u8 len)
" a/ v2 }& u! z{; `) T: |9 b/ R# x
        u8 ltemp;
, P5 S! A5 N5 F' Z  c        if(len == 1)
8 {4 i0 L) `0 P/ i) o- ~        {4 f! d, e( ?4 D- ?$ y5 s
                ltemp = data[0]-0x30;
: Z. W  [. r+ G. P- x
& Y" [& e8 C! ^7 @3 j        }
- h% K4 ?7 J$ A! a! s1 D        else if(len == 2)! A- F+ F+ r" d; C: O! Z
        {
+ R/ U4 S' s1 `2 G, H: G7 h                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
  l& B. o1 r' p
. N6 U) L/ Z  v" B         }
+ L5 L1 S, I  W, Z% u) H        //else if(len == 3)$ N; S" |! H6 t, n$ z) s* E
                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
6 r  w$ h* i8 D* Y
( a6 v5 d4 r( S" v. L        return ltemp;; ^1 e- r" v" H3 X
        " x# c/ y9 x* A# A  B4 ]6 V, k
}
  a/ `7 x2 D1 V9 S) O/ J$ Q4 A! a( H* j! I6 @0 V  e

) n. C  H/ ~5 l' M4 z#endif
! n/ q) m' k* O: A
/ f4 m3 H  r( g; g, E- b+ ]. U9 W9 w5 b( Z5 z7 G7 {
/*! h: A/ c' l, X8 ~7 v
int main(void)7 }4 a. r! D+ ?7 H4 X
{
+ J& E! }8 n! u///////////////////////////////////////////////////////////
" Q9 F. {, m0 G0 `UART1GPIO_config();//串口IO口配置& v& {# `# l$ K0 q0 [
USART1_config();//串口初始化波特率为19200
2 b( w- P9 ]2 Z//UART1NVIC_config();//配置中断
- P" ?* \6 J* M- Y4 B2 H* n///////////////////////////////////////////////////////////& e% l- p7 G1 V& e
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式0 [2 _7 C$ S! }) t& [2 d& o  s" Y
//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它5 ]% b/ p* ^  M2 O8 k: K; |
Test_f_getfree();//获取SD卡的容量和剩余容量, w& X( m; M8 s6 `6 |
Test_f_read();//SD卡读文件测试0 r8 |  p, F  r9 |5 @
Test_f_write();//SD卡写文件测试. k2 s# W9 x1 U
///////////////////////////////////////////////////////////
8 ~2 Z" K! `8 g6 w    while (1)7 i0 e: ~) c  U0 r: m5 F
    {  ]8 b$ c* j! W. `8 C5 r$ @
        //printf("好的");
& y8 G- ^( g, i. ?6 z; s    }
/ A$ V3 L7 c2 F6 _}*/) r! D7 L9 Z/ U- Y* G, y. _
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////8 H* I: ]! t) {1 l0 G
FRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为02 O) G( ?/ T7 B$ J
{
6 |6 c( I; V5 o& b! r& s% N" f    FATFS fs;            // Work area (file system object) for logical drive" q9 r$ f' D. D" O
    FRESULT res;         // FatFs function common result code
0 ~1 i2 \5 T- P( X7 u1 O' K& X7 L, ^; b" F
        //检测磁盘是否插好
& A8 K+ `0 W! R4 N# F        //if(disk_detect_OK()==FALSE ) return ;
* q3 p0 `$ ~- p" d" o1 ]        //printf("\r\n inaert_ok:>");
8 S9 s; s% I; L1 U) s        // Register a work area for logical drive 0: d6 Q6 ?* d4 B/ n
        f_mount(drv, &fs);
# e1 _) v1 Z. L: N% d/ d1 K2 |        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/) n* N: C/ V8 \5 N( W% ?
        //die(res);
  ^, ]; B- z- ^6 U" N2 n        f_mount(0, NULL);6 |7 T  R4 W. p# j+ n
        return res;
; z- p2 ~$ P8 }( `% ]8 O}
& w% a, u3 p. E4 v" ~/ j////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" U, y- K3 r, O# U' XFRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        % g1 [$ M" u8 P8 W5 s3 K
{
1 c% y% F- M: U$ x# v  E    FATFS fs;            // Work area (file system object) for logical drive
1 Z" ]/ X! }' T8 N# l    FRESULT res;         // FatFs function common result code
$ r7 [) Y& s! W
4 a0 U, ^! X0 J  I, ~& G6 M        //检测磁盘是否插好4 X* a! N& u$ R- i0 Y0 f4 A
        //if(disk_detect_OK()==FALSE ) return ;+ Q; P4 E" S# K0 [! X' S. ?
        //printf("\r\n inaert_ok:>");
; J) n$ o' K, X        // Register a work area for logical drive 0
+ A8 D- ^5 U- s/ n        f_mount(0, &fs);+ t7 h. |6 y* f
        res=f_mkdir(path);//创建一个新目录1 ^) B% d$ |3 t; K& @2 z) @5 a
        //die(res);3 r1 P. ^+ u" x  N8 @9 S" ?
        f_mount(0, NULL);$ y9 W) k- d! c" b& X, L. A
        return res;1 Y- p+ R* [( _, ]2 C0 m  Y
}4 X4 D: E" {; w0 q) |
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
* b$ J: b9 h+ S5 Z) I4 ]FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        
! t% `, r1 ^$ M4 W+ `6 m{2 i1 d2 z9 t9 G6 d
    FATFS fs;            // Work area (file system object) for logical drive
4 h+ h. j# Q/ R9 j0 @0 z        //DIR        dir;9 x2 L+ ?8 j0 d* v  y+ W
    FRESULT res;         // FatFs function common result code
" v- S+ G6 c& T/ d
! y. \6 M; g: f  _' d        //检测磁盘是否插好
+ ?$ o# ~# H0 Y2 J' ~, s        //if(disk_detect_OK()==FALSE ) return ;
% P8 T# w( D& s9 M  z  [/ U( M        //printf("\r\n inaert_ok:>");
7 d6 W% _+ ~* x        // Register a work area for logical drive 0
# Y- c0 L8 ]: s0 `+ Z! N        f_mount(0, &fs);, @) |4 \* R3 L; A3 ^
        //f_opendir (&dir,path);+ U; h1 k3 F& N) m- Q: ?
        res=f_unlink(path);//删除一个目录0 ]: @1 Q* D; e0 X; a- a. Z5 k
        //die(res);
- X0 ]( K; @; E+ x, Z        f_mount(0, NULL);
8 z# t$ Z4 |& V* t& }9 |4 u5 y. ]( A        return res;$ V" E3 s1 |* |2 I+ ^5 V
}
5 j1 n6 q" b# A2 `. w////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
" _) E2 h% |* V* d2 ^FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
# D9 N" \, O& B$ e  K& \2 o2 g{
! J% E+ w. H0 B1 P0 A3 g' U4 i    FATFS fs;            // Work area (file system object) for logical drive
& w1 W. g( N! m        DIR        dir;5 y6 m9 V' Z" J* D, C& y
        FILINFO finf;- ~. U! A. F9 i
    FRESULT res;         // FatFs function common result code/ z: O3 I7 G! T& v0 V& R

3 L) F3 d3 q! d$ ]        //检测磁盘是否插好# w) m0 @( Q! \! q9 E6 Y8 u8 o
        //if(disk_detect_OK()==FALSE ) return ;
  `1 c, h" q/ E        //printf("\r\n inaert_ok:>");! @6 n' X, R2 e# R! m8 `' s
        // Register a work area for logical drive 0
; {) j! b% H9 @% U2 N        f_mount(0, &fs);3 Z  r& B  ^* ?, u3 q  U6 f
        f_opendir (&dir,path);
+ ]$ V; |' t" N  v+ D2 _' u" l& x& `% x5 N% T6 j: U) P% b$ R
        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        $ H5 }  M- C' `* c4 o2 G
        {strcpy(*(filename++),finf.fname);: }- c  `% x5 O8 R
        //printf("%s",finf.fname);
7 u1 m$ w" a, B        }
( c/ S7 _9 I6 y9 a        //die(res);! K  D) ~) A1 ]
        f_mount(0, NULL);
; r& k; @7 K+ [        return res;1 @3 {, t' O/ l9 a& m! d8 C1 ?
}' o2 F8 F* @( }. P# m+ P* [6 ^6 A/ u
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////9 q2 ]$ m' d$ }
FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名. @. {# F; V, P# U0 u4 b7 R8 t) |
{
2 V: E. b* t0 b" s9 u    FATFS fs;            // Work area (file system object) for logical drive
% d0 n8 p4 x, \( Z% Y: R        FIL file;
2 q4 O, z; s/ c' G    FRESULT res;         // FatFs function common result code
# w  o: ~/ J1 N( ^+ ?
6 x& m" D% C9 R' S" C) k        //检测磁盘是否插好
, [( e& s/ b; q) s9 P4 q        //if(disk_detect_OK()==FALSE ) return ;
$ `& X- c  H: ]  a        //printf("\r\n inaert_ok:>");
5 r. M( e( p% r2 ?2 F" H# b2 x        // Register a work area for logical drive 0
4 l2 S7 m- r, A        f_mount(0, &fs);
8 L- h" h9 A2 {        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。
- O. \& y: ?; u                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。: p; X! u. Z# |  j
                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。
+ `! @4 x) L5 S/ _2 X6 O  s4 t        //die(res);( W5 H, V( {/ h- p3 r9 c! x8 \' }0 E
        f_close(&file);//关闭文件
# x1 ~2 A1 H9 l% t* K. l1 ]/ D( C' b        f_mount(0, NULL);6 L; w: m& Y  z- j+ Z, I( ]% R( l* [
        return res;. v& U% y8 _0 M5 j6 F2 z
}( l) v/ u( V9 S6 H2 h
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////& H, t+ {( c( A" e
FRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        
. S( {2 p, `$ ^) P# U{- r3 B6 q; g( K/ o& {
    FATFS fs;            // Work area (file system object) for logical drive
6 q$ P5 B( l" c        //DIR        dir;, h4 N# L' _9 C* j# I3 ?! l  F
    FRESULT res;         // FatFs function common result code- i! F' h+ Z/ z: A* v3 j
3 V+ H; I+ D, f0 [
        //检测磁盘是否插好
/ l% l+ {7 I1 N2 o9 ?) ]        //if(disk_detect_OK()==FALSE ) return ;# p8 T: B* @; _' p
        //printf("\r\n inaert_ok:>");
; F0 x& J9 q: P6 ~  w        // Register a work area for logical drive 0
2 b) D1 J/ C$ t) H$ @% P2 G        f_mount(0, &fs);
) }% B) [  X, D( [( I        //f_opendir (&dir,path);) U5 w* v# Z# S: t4 E
        res=f_unlink(path);//删除一个文件
" ^; t/ t& f4 _# c        //die(res);
% d0 d' h1 Z2 e2 x        f_mount(0, NULL);
3 e3 _5 R7 K) N3 w" U( B        return res;
  g4 o* ^. v! r# p+ \}$ g  X+ Z& W, I7 ]
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////* Z* Q# i( w6 s. }. W' v
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数
# d2 A' Y( x. N# ^8 u$ @* E{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));
! p! r# Q8 Z0 F$ Q  S    FATFS fs;            // Work area (file system object) for logical drive# P1 g; B5 f/ Y6 B* `
    FIL file;            // file objects* O6 d) I$ O2 {2 L  J7 Y
    FRESULT res;         // FatFs function common result code& v1 `3 p. {. m0 M
    UINT br;             // File R count 文件读回的字节计数1 i8 i3 t* f' o, }* c
        //u16 i;8 d/ k# `" ~  D" J
        //检测磁盘是否插好
; K8 z$ p% R; k  z        //if( disk_detect_OK()==FALSE ) return;
: v4 f9 H1 M6 B2 `5 h& `9 T1 O/ q    // Register a work area for logical drive 0
9 x2 z  P- a/ v! C3 ~) C1 D0 E        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';; \! h, x6 N! ]' Q0 y, @
    f_mount(0, &fs);
) S, A: [4 h  I: Y; n        //Open source file/ ^' M: ~% \; ?! _8 ?) C
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
8 w" H* W7 D+ K! q/ D0 {* H        //die(res);. j/ k$ D4 j! V; W
        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处2 }1 F9 |' K) ^; Z
        //buffer空间设大一点,会提高读的速度。. b$ Y# y1 q. y# ~
        //如果文件实际大小512byte,6 U7 }$ f+ V! o' `; ]0 x
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。; P! Y2 Y+ \2 T. |0 j( \) [
        //for (;;)
6 h( X- r8 k9 F( {: m        {
+ I" v; W! x$ T5 J                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存
- `! K/ |; v0 S6 L* K$ s
! n( V1 v0 y$ q- L$ [. q* V3 X                res = f_read(&file, buff, strl, &br);3 B3 f$ }/ e% k  F8 _% S
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出' q# n- [* m# l/ e) D
                , [; T+ {. k& d" D( F; @
                //printf("%s",buff);        5 @9 L' f. \* d* R
    }                    . I, `% z% F( ^
    // Close all files
3 \. M" I* B7 _- F% W: l    f_close(&file);
$ B& v& I% z; L* s( J    // Unregister a work area before discard it# y. _+ m" D% b+ l/ h% K; Y
    f_mount(0, NULL);
. P" w" O/ T! |. S8 g/ j4 v        return res;
$ l/ b& U2 L# v, Z7 J}/ E8 w/ w* E5 o  s7 v. _( b
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
6 x  \. a2 S2 ~2 Q+ }! |" eFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
1 \) B7 M  n! m# Q. S1 X{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));8 v0 b2 i$ E& R: m
    FATFS fs;            // Work area (file system object) for logical drive, w! A% b. u: j5 \4 o: K1 ?% V
    FRESULT res;         // FatFs function common result code
# |4 j& _% g0 f" x        FIL file;
6 x( s4 o. c* _2 F$ D; ?        UINT bw;             //文件写入的字节计数
5 S, I/ n0 ]% L0 ?3 |1 G! y; m$ z        //检测磁盘是否插好6 M7 n! Z8 L9 F. P3 h# l  k0 w9 g
        //if( disk_detect_OK()==FALSE ) return;
) Z& t, S( P1 U# A$ B1 d+ @9 y/ b    // Register a work area for logical drive 07 s6 X* X7 ?8 n, {# j
    f_mount(0, &fs);
- D! O+ Y* s. R    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
/ }7 g8 ]$ I9 \" D( m         //die(res);. P& a" g6 p* ]' W/ }! r
    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后 & o; x2 ?. g, E# ^; I
         //die(res);# S! `5 k0 I1 ?. Y
        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符
. l. t3 {4 O; o) q, S5 `8 C6 D' Z         //die(res);
" y$ ~/ _/ d) w/ k# k, _5 a        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
5 V, z9 X  |  U4 G        f_close(&file);//关闭文件
/ [4 u3 D2 n7 W0 s        // Unregister a work area before discard it
3 @# w4 }( S0 O. G; I+ U: r) K8 m    f_mount(0, NULL);
% `% g& B# O9 }" c        return res;! f' j6 B4 N3 X3 S- v
}& Y' `- Y# ^: V' c( g, B% k
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////, L$ W! o5 I" m
FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M+ I' G2 J% Z6 T& ?: t! n
{
& w; F2 j& q( C) t7 v. o. f6 H    FATFS fs;5 h; |: o# ^4 `1 p7 w
        FATFS *pfs;
' P3 O7 G  a6 I6 B$ |7 N3 g) h+ S        FRESULT res;         // FatFs function common result code1 _' F$ t0 p$ A$ w6 o
        //检测磁盘是否插好' Z( z6 G; s8 Y, c* t
        //if( disk_detect_OK()==FALSE ) return;
9 d0 F  ?1 B7 E7 H+ e        // Register a work area for logical drive 01 F- @" u9 }3 {7 P& P/ F9 h& q) F2 m
        pfs=&fs;//指向
8 C7 ^' ?5 X# j% U. J) h    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
2 P; h( f( U. m' G' X    // Get free clusters
3 Y1 [# F& D2 Y' B* F2 Y& @    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
3 n+ w6 g6 @) b' N/ f        //die(res);
# j" z' ]4 c; \        if ( res==FR_OK )
1 R( P, a5 f, d% I    {3 z, L. N( D( V( H
            // Get free space
! Z/ \* z  f/ V' E6 R  V        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",
6 V. O$ P& W: `8 c( O! I( `; R- x8 V               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/10244 F" M: t+ R6 r0 h; s  q; Q
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
4 K2 u6 X6 |1 F  p" j" g: ^  o         *freem=((*freem)*pfs->csize)/2/1024;/ d7 \; v$ p- h6 ~3 p
        }
( u/ ~$ Q' p+ M! [8 a# n5 W        //else die(res);//测试函数执行结果分析2 w& X' b. F' t' [
        // Unregister a work area before discard it/ [+ }: v4 R" x1 T
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间! Z: T5 r$ `7 s
        return res;2 ?+ S' j+ E% K! B
}
  O5 b. q$ z, U6 Y$ u
- F5 }7 x3 b8 @8 t9 H9 x
2 x: ~4 h, J: p( D6 i& ~) _9 y. e  |0 c: ?+ h0 U' q' X* s2 b
/ Feb 26,'06 R0.00  Prototype.. T$ x' ]; z3 |) t1 {" i
/
2 N; ^: d' g1 M, A, E! L/ Apr 29,'06 R0.01  First stable version.! D4 o9 {6 h" L  w% |6 I
/
+ ~: k6 `7 s. ?  S4 y& o  `& N/ Jun 01,'06 R0.02  Added FAT12 support.
. U2 D; D# \1 M/ R/                   Removed unbuffered mode.& @+ P9 p7 j# ^/ k5 U6 I8 ]/ b
/                   Fixed a problem on small (<32M) partition.# M# V& L6 V' W' A8 T, Q/ _0 X. i
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).# H4 y" r) `0 y5 T4 T, W: T4 P! I
/
2 L0 M# L1 |* u7 _' [( v' @/ Sep 22,'06 R0.03  Added f_rename().
/ ?; P5 I' F3 k  o( W" g0 u/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.
5 `9 I7 T% p, u0 f" M) G: W# a9 Z/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.- L8 u( b. F$ L$ r' V
/                   Fixed f_mkdir() creates incorrect directory on FAT32.
' X. Y6 O* T, [6 E// C0 o$ w% O2 B) \% b& }! S( R5 P
/ Feb 04,'07 R0.04  Supported multiple drive system.: A8 O/ {1 D+ M1 X
/                   Changed some inteRFaces for multiple drive system.
# e+ B# W. e+ e( T  J/                   Changed f_mountdrv() to f_mount().
$ J" P- N. P* A# Z1 M5 u, M% A/                   Added f_mkfs().% |) _7 K/ }/ _4 W* B
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive.4 o8 J! V2 B" P2 J
/                   Added a capability of extending file size to f_lseek().4 _/ }. j" F, v1 K/ P. i
/                   Added minimization level 3.& P( |: M; E1 J# W3 Q3 z
/                   Fixed an endian sensitive code in f_mkfs().
! H" ^( [- A8 p) ^& w4 b/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.! `2 H3 M2 E) o5 k
/                   Added FSInfo support.* G5 p" E$ ?/ u
/                   Fixed DBCS name can result FR_INVALID_NAME.
, \7 Q& ?: c9 i2 W! T' D/ u/                   Fixed short seek (<= csize) collapses the file object.6 T" \8 j# u0 J& C1 b8 k* l9 ?
/
( W! S3 U1 ]4 k/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().
" o$ o4 p( C1 h+ z" \, j: V/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.- a! }; O/ M2 z9 L: x
/                   Fixed f_mkdir() on FAT32 creates incorrect directory.) w1 T) f( D; x2 C% d; X
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().' Z' A: i2 [* V( U1 Y
/                   Fixed off by one error at FAT sub-type determination.
# t6 v4 t" i- X/                   Fixed btr in f_read() can be mistruncated.
" I/ Q' p3 X' w1 G( f, x/                   Fixed cached sector is not flushed when create and close without write.* |$ z  X) A( {! D0 e
/* o6 v* B9 a& H) ?
/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().7 O* S$ [- {; a- h7 N0 [4 `& I
/                   Improved performance of f_lseek() on moving to the same or following cluster.
$ f6 S' W' Y, P" u9 g2 g$ g/
6 l# l1 {  Z+ l" {: w/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
* A" @3 E7 h* y! W% D, q3 @) p/                   Added long file name feature.) w. h& w' K, [- u
/                   Added multiple code page feature.
" w# D; N0 [, t+ u/                   Added re-entrancy for multitask operation.
- |/ d6 \1 A' S8 Y- v* [8 p& T/                   Added auto cluster size selection to f_mkfs().; j& G0 L% \) b7 i& [) p3 s& {: ?8 N  u
/                   Added rewind option to f_readdir().
, K3 `) G% k: U0 S/                   Changed result code of critical errors.
+ P$ y5 n; B& z" T/                   Renamed string functions to avoid name collision.
& f/ A4 ~; S" ~- v% t" M7 I9 Y' g/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.3 z9 @# P+ o# h
/                   Added multiple sector size feature.; Y5 E0 t' `4 V0 y1 {: L
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.; S) h" G2 I8 k6 _% k# O
/                   Fixed wrong cache control in f_lseek().5 Y  y+ |' G' Y
/                   Added relative path feature.0 N; N+ ~" A1 \" |1 H8 L
/                   Added f_chdir() and f_chdrive().9 y/ T* S, a& j; X
/                   Added proper case conversion to extended char., m/ f/ u  Y- k$ K& u
/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.' Q1 S- z8 [( g
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.3 _" [, F' z6 `3 i- ^4 E/ {
/                   Fixed name matching error on the 13 char boundary., Y% Z4 n& C) C$ i' f
/                   Added a configuration option, _LFN_UNICODE.# _# m# V8 h. q$ }
/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.
5 q4 r2 }7 C) g; Q/& E' B7 v8 n* s, H+ L4 V* Y& V
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)! y+ b6 B1 y8 O' v& l8 w! F" Q/ x
/                   Added file lock feature. (_FS_SHARE)1 P4 x7 D- Q; t( y% A" {# V3 r4 l
/                   Added fast seek feature. (_USE_FASTSEEK)! a: v, B2 L3 \' i# s8 w
/                   Changed some types on the API, XCHAR->TCHAR.
6 [3 c" p' x  O/                   Changed fname member in the FILINFO structure on Unicode cfg.8 N0 y( l" N9 l2 C: V/ ?4 B+ D( |
/                   String functions support UTF-8 encoding files on Unicode cfg.
) d) o1 k; Q# K; i8 v5 I' M/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2)+ g+ n) _" c2 @/ d. \
/                   Added sector erase feature. (_USE_ERASE)/ [( f9 b/ d# {" ^1 }
/                   Moved file lock semaphore table from fs object to the bss.
! ?5 ]2 L% v/ J/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.- P8 c5 n3 M. a* [
/                   Fixed f_mkfs() creates wrong FAT32 volume.: D. ~- t2 G# X% ~; N* Y4 }
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().3 [0 J! d/ B9 j8 Y, M
/                   f_lseek() reports required table size on creating CLMP.% Z& E3 p4 m& H5 B9 v( z
/                   Extended format syntax of f_printf function.. T) A! @  h" j: V( v4 {" h: v
/                   Ignores duplicated directory separators in given path names.. T9 ^/ e* ]& D" c/ I+ z
/
+ e/ _3 i  l3 r( C- w9 w/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.
4 h3 }# K/ z( ^; T/                   Added f_fdisk(). (_MULTI_PARTITION = 2)
* s1 N, S) l. `# g9 _/ E/---------------------------------------------------------------------------*/
' d: s8 t' U8 Z" _" d& d8 W  @3 V5 |

STM32的SD卡FATFS.rar

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

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

本版积分规则

关闭

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

EDA365公众号

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

GMT+8, 2025-6-21 17:08 , Processed in 0.109375 second(s), 26 queries , Gzip On.

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

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

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