找回密码
 注册

QQ登录

只需一步,快速开始

扫一扫,访问微社区

巢课
电巢直播8月计划
查看: 1389|回复: 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工程。下载即可使用。0 d5 _: `1 m4 n" @% Q
/*----------------------------------------------------------------------------/
) T: a* `. J! h/  FatFs - FAT file system module  R0.09                  (C)ChaN, 2011
6 n  V! a3 S! v$ b/-----------------------------------------------------------------------------/' x6 o/ U) {  j* ^$ R, X7 l
/ FatFs module is a generic FAT file system module for small embedded systems.
9 F9 k# n5 a/ |8 w2 u  Q% _/ This is a free software that opened for education, research and commercial
2 @, D( s# N" u/ developments under license policy of following terms.3 X4 e& [4 J1 R
/
/ r) X" o/ k' O1 {% a& r/  Copyright (C) 2011, ChaN, all right reserved.% \( l+ ?, D4 X
/$ B+ E* S( }: ^$ ]' ]4 A- k
/ * The FatFs module is a free software and there is NO WARRANTY.
, H7 I- P; D% A/ * No restriction on use. You can use, modify and redistribute it for
$ Q1 q5 G  Z, K$ i+ E; O+ q/   personal, non-profit or commercial products UNDER YOUR RESPONSIBILITY.: I) k$ d! s; \+ }* X
/ * Redistributions of source code must retain the above copyright notice.
+ Y8 d3 _2 r! V6 B; h2 I6 E" X/
$ {. _8 z; R0 z4 [9 A) }3 f" @  H/-----------------------------------------------------------------------------/
1 V) [8 D" p: [8 [" @% ?& K
4 N: C$ u- a9 b( R! b% M1 T$ H' N$ k2 \* `) j
/*--------------File Info-------------------------------------------------------+ y- A1 g% X* A3 U6 e
** 文   件   名:  FATFS_Function.c
( p2 ?: h3 W6 m; M6 Y  a** 作        者:~风中的叶~    整理
4 E+ e+ Y4 q) t% C' \5 t  p** 最后修改日期:  2012.01.187 |7 g; n8 l5 Y$ ~% [  v9 e
** 版        本:  V1.0
: z: V2 ^( U- X4 A+ `1 H** 描        述:  FATFS常用功能测试函数 .连接PC机串口,观察超级终端输出
& ^; h' I0 ]7 D7 J**------------------------------------------------------------------------------0 G5 S8 j  B* K# U+ ^+ k. ^
** Created   by:  Dt./ z! f7 }  @: E' J: x0 U
** Created date:  
: |5 r8 I$ u2 s! x* f4 ~* a*******************************************************************************/ # h" J* l. W* t  S
#include "TEST_FATFS.h"
7 g. n3 z8 w8 d  z" ^, K+ Y+ X# j#include "string.h"( r; e! w3 c  L, O4 A$ O
, x" ~- X5 p8 }( k
#ifdef TEST_FATFS_EN
$ [: P9 t. ?- P. U; }; X+ r  Y% {5 g
! z- H  Z- D2 N5 y7 \

3 _: A1 N6 D9 R; x. q0 I//检测磁盘是否插好
2 r' w$ Z' j# c" L1 Q* L5 d' mBOOL disk_detect_OK(void)! p# @8 ?, l1 X
{9 F1 y* |( p, K* D
    if( disk_status(0)==STA_NODISK )/* Physical drive nmuber (0..) */. L/ d+ I. e, ^9 K2 J2 {
        {/ `: K5 }" S. i+ i& `( O5 H
            printf("\r\n\r\n%48s\r\n","<未检测到磁盘,请检查SD卡是否插好...>");
* e9 T0 a" q7 {& g$ ?3 ^                return FALSE;+ o. F8 p0 _+ [
        }2 ]! ~' @8 s! u3 h6 S5 [
        return TRUE;
6 A4 ?( L9 ^9 f# X8 \8 L}
0 `& k1 Q, L4 c' p- j+ b( `/ p6 S
' n  g, m3 z3 E: ~7 A1 |+ H* g8 P: J
/ ^  ^3 f1 B# B8 m1 h
# J  ]8 V6 M, ^* G0 x//测试函数执行结果分析! u$ ~# ]4 F7 \, @; u. E/ v
void die(FRESULT res)) x6 p- W" S1 a
{# B( X- f' B4 L4 ~$ F- k) B
    switch(res); l) t0 |+ d0 q- e# t
        {
. ~0 M# [3 L3 c9 q1 e            case FR_OK:        //The function succeeded.
* G) f! m3 f; T! G: y                {( K9 k' y! _( w+ t
                    printf("\r\nThe function succeeded!\r\n");
  U/ Q% Z: ?( w- t                        break;5 ?  o: K1 B1 [, @- |' {
                }: e' U7 z* u' H
                case FR_NOT_READY://The disk drive cannot work due to no medium in the drive or any other reason
& N) x; p. s, ]% v- z                {3 w5 {/ Z8 ~  f# b: Z- g* J% b( z
                    printf("\r\nThe disk drive cannot work due to no medium in the drive or any other reason!\r\n");7 l  a' E( H: P
                        break;
) Q! y- v# S- W/ H0 o9 \' D6 D                }
( O' s# b  t  H4 E                case FR_NO_FILE://Could not find the file.
7 B7 E# V) i) I+ Y5 c! ]! B                {4 I& d* t% S" l/ F
                    printf("\r\nCould not find the file!\r\n");& T0 y' |+ s- J& ~
                        break;
; P6 Q; ?# _( g! x# Y/ J! j2 [  \) `                }
/ |4 h/ Q! d: ]& N# D2 q# h                case FR_NO_PATH://Could not find the path; `$ ~$ n7 A# F: [9 b: X
                {
' M" j( j/ e" X3 |# [                    printf("\r\nCould not find the path!\r\n");
: J- Z1 \6 Z+ \8 U, }# C                        break;4 A/ U, I: C, P/ @4 |
                }
7 R* U* }7 s0 W* ]                case FR_INVALID_NAME://The path name is invalid
. O3 ^% ~# l# ?& b" [+ }; P6 y                {: m. m5 X; Q+ J- s5 j& q; r5 C/ B
                    printf("\r\nThe path name is invalid!\r\n");
) u+ Z2 l- D2 w- u; z                        break;
* k. o' P4 C% ?. Q( z8 T                }
5 p" g# L2 j4 j                case FR_INVALID_DRIVE://The drive number is invalid: n- I5 c. |' @
                {3 Z9 g9 o4 d2 y. `2 f1 f4 C- P
                    printf("\r\nThe drive number is invalid!\r\n");
2 f: c2 M6 L$ K' g, N! W                        break;
. R/ n# b6 b. V& @8 _. ~; u                }" Q% i( |6 ?- D3 n0 g7 u
                case FR_DENIED://The directory cannot be created due to directory table or disk is full. ) H+ L+ {8 I! K: ~/ u/ ]; j) q
                {
0 j- p; `! l6 t9 q' n* t* v( g                    printf("\r\nThe directory cannot be created due to directory table or disk is full!\r\n");
* x7 k0 ?; I9 ^' |% m, Q                        break;3 n2 g  ~8 T' x' n
                }# [8 t  L5 U" X, ]3 e# A
                case FR_EXIST://A file or directory that has same name is already existing
% r. w" h: Z. P7 \                {2 r6 q9 e: w. g( j* }
                    printf("\r\nA file or directory that has same name is already existing!\r\n");) A/ L4 F& O; e$ m0 K/ O  ~* w
                        break;  h2 t$ d5 Z' R0 g, @
                }9 c) C$ N& S5 w0 V
//                case FR_RW_ERROR://The function failed due to a disk error or an internal error
- i) U3 p8 n2 f& ~/** g- Y) a2 F$ _5 @: \
                case FR_RW_ERROR://The function failed due to a disk error or an internal error
% s* L$ d" }2 n- ]  f                {
( q1 K# @& Y8 v" u+ H                    printp("\r\nThe function failed due to a disk error or an internal error!\r\n");
; y+ T* _* m1 c% q- l                        break;4 N5 q0 n5 I; r. U& ?& `9 v
                }) _2 V& E: m' v% [
*/! z5 Z5 h2 G( ~5 |5 H! W. z# n
                case FR_WRITE_PROTECTED://The medium is write protected  V5 J" B( S: `6 `, j; u' E" B9 L- w
                {8 t2 w. E9 H, {( ^: _" c/ a3 @
                    printf("\r\nThe medium is write protected!\r\n");  ]& q+ R3 B" E* M5 J4 g) P
                        break;- C  z; n+ H% h
                }
) t) U1 M( j- {- I. k( d6 t! A                case FR_NOT_ENABLED://The logical drive has no work area/ n3 C. Q: q& K( R! d
                {
, }6 C) @0 ]: }* e2 `# g7 O                    printf("\r\nThe logical drive has no work area!\r\n");
& i9 O7 s- X  {  q; ]: |                        break;
- k4 l, `. J. x: P0 N; c. P- U                }! G  E. w0 T- L0 b" P7 M! ]% N9 R6 M
                case FR_NO_FILESYSTEM://There is no valid FAT partition on the disk# \' P" D  l4 B1 W
                {5 v1 S8 j. X, [; Y& u1 }6 U5 O1 n
                    printf("\r\nThere is no valid FAT partition on the disk!\r\n");, H5 k0 t8 T; @8 s- w% e
                        break;% D. w& q9 U' t2 U
                }) X: ~& |3 [0 I0 c0 @" I, U
                case FR_INVALID_OBJECT://The file object is invalid8 n9 u, x& G; {) l
                {
2 {* @0 u) m3 P                    printf("\r\nThe file object is invalid!\r\n");
6 R9 g1 h7 X4 g4 C. c                        break;) x9 T: |  v6 \" f5 h. x. N3 h2 i, S& `
                }
7 R- s, \$ ?! R  [
" [* A7 o: \' I/ W3 \            //The function aborted before start in format due to a reason as follows. ; h6 ^$ n0 g7 @/ `( t( n- a& m
        //The disk size is too small.
0 C7 B, A7 C+ Y2 H1 E4 t; T/ J        //Invalid parameter was given to any parameter. 0 m, e3 U- L6 f' z) d
        //Not allowable cluster size for this drive. This can occure when number of clusters becomes around 0xFF7 and 0xFFF7.
- D! P1 s4 b7 B5 M                case FR_MKFS_ABORTED://2 A  ]/ K/ c% b0 b
                {
/ A6 m4 G9 b- U+ g5 E& Q0 N                    printf("\r\nThe function aborted before start in format!\r\n");
, P$ z/ b4 M7 z+ R& g8 }6 |2 h* Q                        break;
7 I" I- e. j% ~8 i4 X                }
8 U# [, f& c) t+ n3 M0 i" [               
, k0 C( _- t& `# M* h5 ^; W                default:$ p; K) G4 M' ]" m& A. E' k5 i
                {: h2 Y9 J+ i" r8 V( Q
                    printf("\r\nerror!\r\n");
3 g- W# z9 {3 Z  B/ F- {                        break;5 _; I$ x/ [: F& U: A* ]* ^
                }        / e) R( }" ~4 @& T3 U& {
        }
7 L& d# d+ k$ {4 T, v        return;
. A3 H" L: ~( o7 j3 w}
) _( s6 x" L6 q% ?- n$ Y8 Yvoid Test_f_getfree(void)//获取卡的总容量及剩余容量
. B3 [/ U$ G, d! d, p{
  L8 e8 V* @9 K( Y2 W& z1 d" s8 \    FATFS fs;0 ^, D, M: ?% w. j9 u' g3 k
        FATFS *pfs;% _( g/ F% i. c' B4 Z
    DWORD clust;3 Z" b+ I- }# f+ X, t8 V3 p  r
        FRESULT res;         // FatFs function common result code' y+ E) {9 `; K  W" O! W9 w
8 ?8 ^* E' U' c: ~$ a' q! V
        //检测磁盘是否插好/ T/ A0 r+ }- k5 U6 W
        if( disk_detect_OK()==FALSE ) return;
0 }! x1 @, Z* t# q; H
( d  ?, m6 q  M9 G7 ?( N8 f" I4 A        pfs=&fs;//指向4 p2 Z3 n9 Q# f2 u/ q' Z" t
        // Register a work area for logical drive 0
8 s9 ~/ }8 \. M    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间
& j2 X7 q" E$ b: m. T6 \4 A  v, P* d3 `. ?* j
    // Get free clusters
9 P8 l  [# h) m    res = f_getfree("/", &clust, &pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"7 k/ C3 `$ g& J. L% ^6 k3 V- e
    if ( res==FR_OK ) " L) B8 c- K" l7 H5 Q
    {& A  e. t6 f- c% {( V
            // Get free space( d; K: T/ P! p
        printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",4 o$ I* y5 @! D; \+ ~& z
                (DWORD)(pfs->n_fatent - 2) * pfs->csize /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024
6 a4 Y! ]$ T2 l* E6 i                 clust * pfs->csize /2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/1024
* u: @7 }7 Z' X& y9 s        }
# E6 v: H+ h" y$ ~" e% _        else die(res);//测试函数执行结果分析: l1 [/ J! v1 Z, y; U4 t1 p
        
' J3 i9 E* k0 x* ~. V        // Unregister a work area before discard it
6 L) ]7 D+ r2 f, ?0 N- \) Y" X7 s    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
' R! g4 f: U1 E/ `# s- i) G1 M- I}
# v! o2 e. f2 p; b+ s' f9 E, A6 }' P5 Q/ _( q% a
void Test_f_read(void)//读文件的数据,如果没有此文件则返回错误& D, A3 q/ \6 p+ _5 s. n1 Q
{: C' B% x/ V+ J) v* @6 s
    FATFS fs;            // Work area (file system object) for logical drive* h9 ]% o' [8 u# b9 x) ^/ ~
    FIL fsrc;            // file objects
/ ?0 @& H! s" r$ W  Y    BYTE buffer[512];     // file copy buffer1 p$ x; c8 w0 h) Y/ P3 T3 ]
    FRESULT res;         // FatFs function common result code" g# T2 r, x( _0 W, r/ |' E
    UINT br;             // File R count5 }+ w( R8 c- n2 N, `3 B) o
        u16 i;
/ x% S" J6 |8 F0 j2 p/ l2 O4 _1 A  y        . }/ M  G9 c4 |1 O1 J: W) u2 P
' a4 ]# A* U, [% W; D2 l
        char path[20];& j# ?/ |" ~7 b  C' E
+ B# t3 h' w% P8 X  X
        //检测磁盘是否插好
2 T) Z, P: ]& u) s        if( disk_detect_OK()==FALSE ) return;& B- h* F- N) c
$ H8 g# W9 O2 c5 X) }: }3 l
    // Register a work area for logical drive 0
- g1 c5 r. C3 }( F4 I    f_mount(0, &fs);
! N9 ^1 N7 e/ ^! y. S& n0 J3 X  ^+ |9 _; M. ]& w
        printf("\r\nread file:>");
) t. V6 Y; p% O4 W9 S- `: G        USART_Scanf_Name(path);//通过串口输入文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt4 _% n2 |  S! b* K; u* V, P7 ]9 u

/ k* G, B! N+ I        //Open source file0 F3 K" ^& e/ J4 Y# R7 d9 p; K
    res = f_open(&fsrc, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误
& _/ T1 k/ n& T5 M( U' E! O, T3 q7 }- f        die(res);
0 C3 s  s3 z8 F' e; ^! L2 l        
) q% L! r: B6 m0 h  z, a6 Q8 M: t        //buffer空间设大一点,会提高读的速度。
0 J* X2 Q2 f, B% c        //如果文件实际大小512byte,
( q, e- y; d, }% y        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。% {2 ?1 B& E% C! m" w) s
        //下面两行主要是去除1s误差。+ l8 R  m- H( H1 h$ x
' t! H( M6 C, h; `" E% l" l' @
        for (;;) % k2 C, g& w9 ], Y# |" D* N" e
        {3 y4 H3 p6 k2 B
                for(i=0;i<sizeof(buffer);i++) buffer[i]='\0';//清除缓存
( \8 p7 R$ w" l6 Q/ M- U3 f
. }! e3 T7 I2 y: `3 N* h- q9 |                res = f_read(&fsrc, buffer, sizeof(buffer), &br);
+ y$ K* b1 l: ^! N" F, X        if (res ||(br == 0)) break;   // error or eof        
& O" N) E  l* J  b8 s               
+ G- `2 M5 [/ \# M- x% x' I8 d                printf("%s",buffer);        9 C3 k# z( i1 L" k
    }# Y- E1 ~0 T: T! v. G; U
1 R5 _) r/ L) K% Z/ q
                            % A9 R3 Q3 S& b1 s" X/ f6 v& b
    // Close all files; M  u! v7 o" [: F5 s
    f_close(&fsrc);
3 \' a- Y" Q7 H1 q, Q    // Unregister a work area before discard it; A7 m* L( S! C' N/ z
    f_mount(0, NULL);# [" y9 ~: |/ W3 m9 V' T8 i  t. n
}9 Y0 E; P1 o, Q

. B+ Q5 t$ Z3 G( J( P0 Mvoid Test_f_write(void)//写数据到文件,如果没有此文件则创建文件3 p4 Q2 I: f2 |
{1 V7 {) ~% T* |3 g
    FATFS fs;            // Work area (file system object) for logical drive# X% c# y& c: U) G# r2 t0 i* {' |
    FRESULT res;         // FatFs function common result code9 T2 n+ R( E! [
        FIL Make_file;
, \8 e) d3 k% V! Z    char file_name[20];! G  t- v/ A) ~4 t) P/ Y+ y
    char Storage_buffer[] ="0";# {9 e+ v3 ~! Z# B/ L+ z
        
% Q/ z& N2 J1 q" z& g- \6 \+ }        UINT bw;
" w% t$ Q' v+ {        //检测磁盘是否插好  x0 }# K+ y" j$ Y6 G
        if( disk_detect_OK()==FALSE ) return;
8 n5 f3 }( w$ U& R" g" u' r( a% B         printf("\r\n inaert_ok:>");
+ ^7 U, \1 J0 k/ S0 v+ F9 X. b    // Register a work area for logical drive 0; A$ I- i9 p2 b5 J4 H
    f_mount(0, &fs);  m! V, c' r% E5 D
4 j2 Z9 u6 g$ U2 z+ S8 Q
        printf("\r\n Make file Name:>");
5 R/ z9 `0 u0 H# N" |        USART_Scanf_Name(file_name);//通过串口输入源文件路径名/dir/file.txt或者0:dir/file.txt或者0:/dir/file.txt
' q) O$ {7 L4 P2 R/ |- i3 e( W+ [7 w( e8 q
    res = f_open(&Make_file, file_name,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建
4 B8 i. h4 `0 g% r# ^( v* i         printf("\r\n open_ok:>");2 O8 z$ Z. C% v4 T4 z
         die(res);
5 ^! _! O4 Q: p! U. F8 X8 f  x    res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
8 F, A* D$ H+ Q1 C( _  e      printf("\r\n seek_ok:>");
3 S  W$ _# k  h% i& ?2 U( c+ n         die(res);! D! }$ [, ]1 T, S& j% a( G5 M
        res = f_write(&Make_file, Storage_buffer, (sizeof (Storage_buffer))-1 , &bw); //每次需要写入的数据字节数,去掉最后的\0所以-1  ( W7 B& X( g1 N1 G
     printf("\r\n write_ok:>");
% v4 g+ A3 `$ s; Y$ j         die(res);) w0 J! |( h5 l, t! Q% s8 g
        res = f_lseek(&Make_file, Make_file.fsize); //指针移到文件最后  
; P! ~9 N" G, L; ~7 t        f_close(&Make_file);//关闭文件
; m7 v$ q7 O. _) \2 v        printf("\r\n close_ok:>");
0 Z8 C! `& a* f! A! H5 w4 C9 q# n8 }3 Q# M! ]8 X* E5 j4 A& F8 @
        printf("\r\n写文件测试OK!\r\n");7 \% {: m# J/ d2 N0 C
/ t; G! S7 a; [  ?
        // Unregister a work area before discard it
! R: D0 z( U6 `" v: _1 u3 W% z    f_mount(0, NULL);
% r) C3 ?- v) z/ x/ t! m- p3 g}
& C: _+ U! }  D. j8 v5 R# s- N# l/ H( I$ Q: m# v% ]
//The f_read function reads data from a file.$ _$ O/ Z3 ~1 U& l, ~6 h$ H# c
//在RAM里面调试这个程序的时候,总出现莫名其妙的错误,最后怀疑是堆寨溢出了,证明果然是这样
3 O7 b! i3 T' T( H" _8 y//把Stack_Size   EQU   0x00000400  改为 Stack_Size   EQU  0x00000800就正常了. T. t7 Z( g. o( }& {4 Q+ p
//所以以后要特别注意这个问题。
% q4 s7 ~: D  a/ _& M+ u6 G
- a- ]0 n! @- S8 i9 I# Hu8 StrToData(u8 * data, u8 len)
9 f- N# V$ K0 X3 n{
, D. n8 I3 s7 k        u8 ltemp;& L( A$ _- _$ x3 C
        if(len == 1)
; _7 M; T/ i  Q# ^+ Y" p1 U        {& P6 b, G+ s+ A
                ltemp = data[0]-0x30;+ N7 U3 l3 o9 o8 s5 B3 a+ N, D

8 h" I) W/ F2 I& `        }. M/ s2 M0 V. I) M" [( u% N: Q) [
        else if(len == 2)9 S! M' U9 h* y5 r
        {+ o! q7 E- k; @6 q7 I. Z5 J, `
                ltemp = (data[0]-0x30)*10 + (data[1]-0x30);
: I! k, _* S6 S; q
! Z7 Y3 ^# P( z- F- ?( F         }
* a* l8 _* j3 L        //else if(len == 3)
  \: o) a  {! _  G                //ltemp = (data[0]-0x30)*100 + (data[1]-0x30)*10 + [data[2] - 0x30];
! ?& D5 \2 s! _5 X5 S
8 D, F3 x1 @9 L+ Q        return ltemp;
- ~# \' d  q3 \6 v        8 @( H0 Y$ ~' Z
}+ x6 h  C% E, O$ J3 D

  Y. J$ `* }) N7 O' |  _
; H5 S: z7 X! f, n#endif
8 x1 Z+ B2 D7 {" E9 T2 _2 |" l; d+ \$ \+ W" ]

6 K% h+ a# c. t6 _# @( \& H+ y! k& C/ C/*
! C' O: l1 z  Z# U! I& }# @int main(void)# r# G# ~. M1 ^5 M' u) l6 B- ~2 [6 g
{
% D5 X. K1 l3 {& s+ q4 ^& J+ H///////////////////////////////////////////////////////////
! t3 M' ~; f+ S5 Z/ C8 uUART1GPIO_config();//串口IO口配置6 f" P: B4 O- A$ Y0 h
USART1_config();//串口初始化波特率为19200& H& L: \* F2 @; V8 \
//UART1NVIC_config();//配置中断& I, ?0 }2 m- B7 |, ^6 E% U7 |
///////////////////////////////////////////////////////////4 W9 W& i4 o/ P' d* }
SDCard_SpiInit();//SD卡的IO口及SPI模块初始化,PA2插入检测(H—>L)A3 CD_CS片选;PA5 SCK;PA6 MISO;PA7 MOSI;低速模式
: M: s4 A( B& N, }% u+ P+ p//SD_Init();//SD卡初始化,如果使用的FATFS则可以不用这句,因为FATFS在打开文件等操作时已经调用了它5 f) c1 x5 n* N/ ^, s
Test_f_getfree();//获取SD卡的容量和剩余容量6 t1 y/ j& a6 G  r
Test_f_read();//SD卡读文件测试0 H" S, m1 V9 v! M
Test_f_write();//SD卡写文件测试
0 \6 t0 x. W0 f) b: V4 S/////////////////////////////////////////////////////////// 4 [- Q. H6 S, h- r4 ?
    while (1)
9 _* D5 b0 D6 \    {
+ K" M7 ?5 h, l) m$ O' d4 J        //printf("好的");
+ `* u+ F3 b; i9 g    }! v/ r/ M# Q3 h0 t! O
}*/
. h2 W$ W* a: Y1 Y- d( Y! O( H////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
% I% L0 O1 ?) }. L) o7 Z& sFRESULT Test_f_mkfs(BYTE drv)//对卡进行格式化,驱动器号一般为0
( ]4 F$ ~4 A: X8 o8 C) v; u{
& p/ Z& k/ \, j$ \    FATFS fs;            // Work area (file system object) for logical drive
' [+ Z' c4 N$ X2 b    FRESULT res;         // FatFs function common result code
6 v- K$ h* d& u, l) D- A  |) ?/ Y: O) e
        //检测磁盘是否插好
9 k1 U3 Q' k8 `. ~! U# J  H        //if(disk_detect_OK()==FALSE ) return ;
3 T; }# S- m% E, M        //printf("\r\n inaert_ok:>");. g1 e, C3 {5 H8 C0 x# B; {/ C
        // Register a work area for logical drive 0
5 l$ }+ p5 [9 Y        f_mount(drv, &fs);
; R* _3 J; ~+ b0 Q/ L        res=f_mkfs(drv, 0, 0);/* Create a file system on the drive 在驱动器创建一个文件系统(驱动器号,分区规则(0:FDISK, 1:SFD),分配的单元大小)*/
, H. ]2 M7 u- e6 B6 m        //die(res);
$ L& X9 J0 B/ z( M) o: R3 t3 s        f_mount(0, NULL);
! W' O1 M( w0 O; |        return res;! H% C' \' t8 V& P9 o. g: u8 A* L
}9 B! S1 E  j* h* Y8 T& x  v4 s; N
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////% w+ d# p( L, O6 n( w2 P
FRESULT Test_f_mkdir(const TCHAR* path)//创建一个新目录,输入目录的路径Test_f_mkdir("/dir");只能一级一级的建立目录        
6 F% w" w3 Y9 y{
4 C7 f2 L' L% m/ e5 T    FATFS fs;            // Work area (file system object) for logical drive
8 _5 y% R6 u2 o5 `    FRESULT res;         // FatFs function common result code
& {4 W- x3 f+ {5 N% [# p3 f9 h3 H, i: r0 J/ E% C% D. m
        //检测磁盘是否插好
( W9 X5 h, h9 D% @0 f' i        //if(disk_detect_OK()==FALSE ) return ;" I, W! q  k# s5 _5 G6 |0 L
        //printf("\r\n inaert_ok:>");/ N& u" o, c8 F- u  t8 e
        // Register a work area for logical drive 0
2 q2 E2 c2 K1 @- r        f_mount(0, &fs);/ [+ k$ P) ?2 H
        res=f_mkdir(path);//创建一个新目录1 f6 r4 A. J' b9 b2 [% I; Y. J
        //die(res);( x9 {6 [; T% X$ O# I
        f_mount(0, NULL);& `& j4 }0 m& G1 K5 `) K# R8 g
        return res;
1 n) ~; J# D2 \/ ^! C- K}" g- X0 V% U3 b# d* H1 o. [: i% b
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////& \. s2 h0 C" k9 }+ s9 r3 }. d
FRESULT Test_f_deldir(const TCHAR* path)//删除一个目录,输入目录的路径;目录里的内容是空的才能删除Test_f_deldir("/dir");        : a/ B  W( @! J  _6 M
{8 O& [/ J+ G3 u
    FATFS fs;            // Work area (file system object) for logical drive
# S7 [. W) x0 Y7 Y  U/ V5 C2 E) }        //DIR        dir;
  B* o. V: Q7 ?4 A* @( D5 p    FRESULT res;         // FatFs function common result code
. n# Q4 `. I6 h9 _2 K
( L7 b/ W) T& A& P5 b: w) L1 u; h        //检测磁盘是否插好
1 @+ G3 s- t! ?: u+ n5 _        //if(disk_detect_OK()==FALSE ) return ;3 A* o* R7 f1 d& `5 k5 ?- O' F5 _# j$ Q
        //printf("\r\n inaert_ok:>");3 j+ Z- B- @5 ~) ]
        // Register a work area for logical drive 0, y; ~: m5 Z2 c
        f_mount(0, &fs);1 s6 t( P& p/ o4 c1 t
        //f_opendir (&dir,path);
: a: y( w4 }8 [; I        res=f_unlink(path);//删除一个目录
! p* h% l. }3 G) H        //die(res);  w( i, Y4 h: g" x0 @
        f_mount(0, NULL);
; e! G, f" H& W- L5 L' h" Q        return res;) r* B+ m* b/ [) C% B" b
}) }0 O" t  D" z* Z2 ~7 N
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////# m1 U: }  z1 b, O( t
FRESULT Test_f_readdir(const TCHAR* path,char (*filename)[13])//获取目录中的文件,输入目录的路径;输出文件名和文件夹名Test_f_readdir("/DIR",name);char name[5][13]        
0 \4 n  o$ `& k7 \6 J) c) c{
1 K3 @" q  q7 l( k) [& Y6 N% ^    FATFS fs;            // Work area (file system object) for logical drive( H8 e( a/ J2 H2 f* K
        DIR        dir;
. e# E+ y9 q! D4 p9 v        FILINFO finf;; n* z" ]* |0 q+ M
    FRESULT res;         // FatFs function common result code
  F9 A5 {, F6 j7 s9 m
% W/ ~5 X7 I$ O! G0 \3 D        //检测磁盘是否插好& ~4 d' X" |  B* X" a  V( ?
        //if(disk_detect_OK()==FALSE ) return ;) I/ n% e3 r/ {0 N1 y
        //printf("\r\n inaert_ok:>");8 I! V  G- G8 {0 v; l# M8 i/ o
        // Register a work area for logical drive 0* e5 l) y. v8 S3 [
        f_mount(0, &fs);! H3 F6 ^7 Q8 ?0 M% D6 e7 {
        f_opendir (&dir,path);/ J! o* c9 J8 P: o' f- v

- P/ k' K4 `8 E        while(((res=f_readdir(&dir,&finf))==FR_OK)&&(finf.fname[0]))//获取目录中的文件        
6 `- d! Z6 I: e: G' O        {strcpy(*(filename++),finf.fname);
  X3 L4 A" w8 \! Q; `! u3 M( Y        //printf("%s",finf.fname);: q& r$ U# z; G/ p! A( o
        }
3 K( v8 G( Q8 J  _4 C2 Z$ i' N        //die(res);% Q& A/ H/ Q8 ]
        f_mount(0, NULL);
" N: ?2 w" Z7 A6 U        return res;% w9 }% o2 R" R$ w, Z2 r5 \
}
! e7 R/ ~4 I" U////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////* G% j2 U  S* j, P
FRESULT Test_f_creat(const TCHAR* path)//建立文件,输入文件路径和文件名
" F& \( \3 u4 l# t* Q- C4 K{
1 r- e# m/ w8 ?' O& T! W    FATFS fs;            // Work area (file system object) for logical drive" }* Q: X% V0 K" D
        FIL file;
6 x: p- J/ ?: W1 ~, Q6 D- ~    FRESULT res;         // FatFs function common result code
  A/ v5 X- h3 g2 ]$ e! I+ n1 @# B: s/ Z- i8 J( T* H% ~; v7 N
        //检测磁盘是否插好& z5 m+ r$ e) y2 h1 B
        //if(disk_detect_OK()==FALSE ) return ;
8 o' ^) [" ^; O6 }1 f        //printf("\r\n inaert_ok:>");
4 G% p+ ^# ^5 l/ A3 t/ T+ Z5 N        // Register a work area for logical drive 03 q  @) Q* v/ Z3 R4 L- h! z
        f_mount(0, &fs);
: @/ s7 E" V! a& y% s; X* o* B        res=f_open(&file,path,FA_CREATE_NEW); //创建一个新文件。如果文件已存在,则创建失败//FA_CREATE_NEW创建一个新文件。如果文件已存在,则创建失败。# I% d4 k% @* e( v% p% P: I
                                                                                      //FA_CREATE_ALWAYS        //创建一个新文件。如果文件已存在,则它将被截断并覆盖。
5 [# x! E. r8 ~                                                                                      //FA_OPEN_ALWAYS    //如果文件存在,则打开;否则,创建一个新文件。! D$ c" {, O! a: H0 B
        //die(res);. E5 b- Z' ^/ Q! D
        f_close(&file);//关闭文件
3 O* H0 ?8 G0 w. w% o        f_mount(0, NULL);6 m; x  @0 W- L5 q9 Z
        return res;
) W& @7 |! L& P}5 y7 E3 q* P; D9 F; I
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
9 D* Z: V) P+ l2 w( L: cFRESULT Test_f_delfile(const TCHAR* path)//删除一个文件,输入文件的路径;Test_f_delfile("/dir");        ; d4 H2 @- v' k! U
{7 e: P4 P, V- z$ c$ U/ e
    FATFS fs;            // Work area (file system object) for logical drive8 {3 _* z& L: R0 p- c
        //DIR        dir;# H( G, E+ @, [, P
    FRESULT res;         // FatFs function common result code
5 X1 c% C& m3 g2 r
6 _8 w1 ~, t1 W! r; [0 d; @1 g6 r        //检测磁盘是否插好8 ~4 i% u1 X+ H3 U
        //if(disk_detect_OK()==FALSE ) return ;
8 h3 m" C2 \9 |# k2 e1 V        //printf("\r\n inaert_ok:>");
. s3 m! |) L0 h$ _  k        // Register a work area for logical drive 09 T+ d/ ~, y) M  F
        f_mount(0, &fs);) w' @) X% A' X$ h# g
        //f_opendir (&dir,path);
8 u: b/ d) o. `8 A% H' g' d& B        res=f_unlink(path);//删除一个文件0 A5 E( K; R$ }3 _3 r% u- C$ O2 v
        //die(res);
) Z5 u9 T  c. |% V: ?        f_mount(0, NULL);! t. K5 e) a7 G% e1 S$ _, U
        return res;" a. [5 A5 V7 l) P
}5 l! x7 W$ x$ F* k( Y" _* H
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////1 K/ \5 S( k0 t8 w1 `) a3 t
FRESULT Test_f_readfile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//读文件的数据,如果没有此文件则返回错误;输入文件的路径名,内容缓存,读取开始偏移指针,读取的字节数* U, U( \0 {0 F% M  n* e$ p
{                                                                                                                                                  //Test_f_readfile("/dir/r.txt",str,0,sizeof(strr));+ R4 b/ s9 s  `1 J4 J! M) R
    FATFS fs;            // Work area (file system object) for logical drive
6 P' m( x' w5 F! y" \1 P$ ?. z" K    FIL file;            // file objects
- B" y( l8 o5 R& R  F    FRESULT res;         // FatFs function common result code2 }; ?0 J5 E5 T+ H$ w
    UINT br;             // File R count 文件读回的字节计数
9 Z% ?# {/ o/ d& {* d        //u16 i;) z5 M+ |" C: w( \
        //检测磁盘是否插好% i7 y& t! K7 D5 J( `' _# ?
        //if( disk_detect_OK()==FALSE ) return;
/ g5 |. j% q+ M    // Register a work area for logical drive 0
1 ?+ |9 t7 O8 M! y( C" O2 C        //for(i=0;i<sizeof(buff);i++) buff[i]='\0';
! D7 c- h* p' a4 f$ F9 {    f_mount(0, &fs);
* I8 H4 Q( b; \5 D% O1 H        //Open source file$ T6 ?4 s% g  A# E1 w- k7 \4 I9 ^
    res = f_open(&file, path, FA_OPEN_EXISTING | FA_READ);//打开存在的文件,如果没有则返回错误! ]  d& H+ |3 o' O- @$ e6 B7 s
        //die(res);
# {) k7 K4 h5 Y/ {% }" V        res = f_lseek(&file,ofs); //指针移到文件ofs个字节处% r' q2 Y" Y6 c( L
        //buffer空间设大一点,会提高读的速度。
% u" ^! M" U  J2 ]5 r        //如果文件实际大小512byte,& s5 m. r2 F* i( n# H
        //设为buffer[512]时,只需要循坏一次,如果设为buffer[1],需要循坏512次。
; G! C1 E$ T0 }        //for (;;)
1 |% f7 M& x  P* J8 G3 f        {
0 q# _) F5 {. E1 ?( K( ]. X                //for(i=0;i<sizeof(buff);i++) buff[i]='\0';//清除缓存) y& P* L- p- l8 O+ `

! r% i. t2 v2 M1 w4 e0 h, e+ O                res = f_read(&file, buff, strl, &br);) P; I9 V7 n4 h8 x5 i: o( `0 }
        //if (res ||(br == 0)) break;   // error or eof如果错误或者到文件末尾则退出* N7 W. S9 w, o
                1 {. z4 T. A2 ?2 S, [' h/ f$ A
                //printf("%s",buff);        
0 t% c5 B! A  ~- S) F    }                    - n; a  J! ^! B. F7 W7 g/ `0 O  V
    // Close all files
% p5 G+ ?4 Y' b/ q( K  X    f_close(&file);  P8 j; q. J% Q! J3 R  _/ ?' }
    // Unregister a work area before discard it
6 c& B/ v7 |2 d' w0 I! _5 r    f_mount(0, NULL);
. W. ]& H% D+ N- l& E- g* B        return res;& v# i" W& S$ @8 a0 q: w
}
( Y* W2 X6 b0 }- a////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
- Q8 d, i5 v' z$ ]/ XFRESULT Test_f_writefile(const TCHAR* path,char *buff,DWORD ofs,UINT strl)//写数据到文件,如果没有此文件则创建文件;输入文件的路径名,内容缓存,写开始偏移指针,写的字节数
' C) r9 }# G, ?. v8 o{                                                                                                                                                  //Test_f_writefile("/dir/r.txt",strw,0,strlen(strw));+ k' [% v) G6 ~/ F5 x
    FATFS fs;            // Work area (file system object) for logical drive
4 i+ k1 A4 i, r    FRESULT res;         // FatFs function common result code
& P4 ?+ o. _) |6 u" `        FIL file;
$ @0 T) x( m8 |/ a        UINT bw;             //文件写入的字节计数
. e2 y: F6 Y0 @" |4 O        //检测磁盘是否插好) A) \* N* c+ a% w6 m9 A
        //if( disk_detect_OK()==FALSE ) return;+ D+ _, j+ ^9 i) H& ?
    // Register a work area for logical drive 0/ T% r' }6 i7 d+ m: Y# ^$ }, w
    f_mount(0, &fs);
* I! [& l- @' T4 C# T4 v0 B! Z    res = f_open(&file, path,  FA_OPEN_ALWAYS | FA_WRITE); //可写方式打开 没有文件则创建 5 s  ^5 Q: O6 L
         //die(res);
  G9 h) m; M& f, Q  i0 v    res = f_lseek(&file, ofs); //指针移到文件ofs处;输入file.fsize指针移到文件最后
3 |7 s4 F( I% G% ~1 `         //die(res);
& h' f+ @" [* G$ |: g# k+ Q        res = f_write(&file, buff, strl, &bw); //每次需要写入的数据字节数;如果btr为strlen(buff)则写入所有的字符% P% v7 J2 u0 e( z; N  o; Y
         //die(res);
$ Y7 |4 Z3 K2 P- U, B        //res = f_lseek(&file, Make_file.fsize); //指针移到文件最后,一边再一次的写入  
! p- R2 ~  ~3 d9 T2 j. t        f_close(&file);//关闭文件/ w* B) E' D' t# z
        // Unregister a work area before discard it
4 m2 s( y8 A/ S0 e& H. q    f_mount(0, NULL);
& }8 n& e+ B& X! _/ ~        return res;
8 N8 T# `" H; c# l& \}2 B" ?1 `4 H; X4 v3 S
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
7 I$ w- E, [- v" p. \! {FRESULT Test_f_getfreem(DWORD *freem)//获取卡的剩余容量单位为M1 D+ f1 a. Q( e6 E& F
{' m% \& y8 t8 z4 m! r7 x
    FATFS fs;
# U+ U/ e2 _( i& [) e' L" E        FATFS *pfs;4 ~0 U- L# O# h3 q: ]3 n8 w; P7 D
        FRESULT res;         // FatFs function common result code+ n& J& ~7 o$ C9 O) ~, `( V
        //检测磁盘是否插好
0 V" F$ Q1 c' F' y        //if( disk_detect_OK()==FALSE ) return;
' y* E& {# P& \  \        // Register a work area for logical drive 0: S8 \0 i4 t* m& P9 ^# H9 v  z
        pfs=&fs;//指向
+ R/ Q' q% d7 i4 a# v    f_mount(0, &fs);//安装FATFS,就是给FATFS分配空间6 ~, q) f0 ]- ?+ V7 f
    // Get free clusters; d& @: c8 Y" U" C) A
    res = f_getfree("/",freem,&pfs);//必须是根目录,默认磁盘0;"/"或者"0:/"
7 r& [$ H7 _* r. D- ^: p/ ^# g        //die(res);' b: m  V& M% e! {
        if ( res==FR_OK )
* m/ c$ C+ `$ i5 A# Y& P6 D/ `    {( N4 B" }. x( s- O) x
            // Get free space+ K% G) g/ y( X
        //printf("\r\n%d MB total disk space.\r\n%d MB available on the disk.\r\n",# F0 k! r: _# {( Q/ H
               //(DWORD)(pfs->n_fatent - 2) * (pfs->csize) /2/1024,//总的磁盘空间M        =(总簇数-2)*每簇的扇区数/2/1024=可用簇数*每簇的扇区数/2/1024: K2 ~8 k, P  y9 u
                 //(*freem)*(pfs->csize)/2/1024);//空闲的磁盘空间M=剩余簇数*每簇的扇区数/2/10247 }9 L+ Q  B' r1 p
         *freem=((*freem)*pfs->csize)/2/1024;3 ]" F$ o5 h6 s/ r# C  o; W/ s$ H
        }
3 J6 M. |7 K+ g# O, k  Z        //else die(res);//测试函数执行结果分析
- m9 e. e$ V7 M5 z/ U# f) e        // Unregister a work area before discard it' Y. ~( Q1 u' h2 k0 A$ n" m( D
    f_mount(0, NULL);//卸载FATFS,就是释放FATFS结构体所占空间
2 c) I0 |4 ^9 ^+ K4 K+ m7 {        return res;0 K0 d1 C. M, h
}
. ^( [% U$ t9 B9 w3 e
: ]1 g. s2 Y2 ~4 j0 ~8 g
4 _: ^( C1 N4 C
) x# [& d2 C& h: u' U; W' f/ Feb 26,'06 R0.00  Prototype.2 ~+ M' M6 c7 R6 @* o% B+ f
/
/ [7 T# E7 E% J" _0 P# V, S8 T/ Apr 29,'06 R0.01  First stable version.
+ E! p4 \  b8 `! I1 `/
. e- E- M/ ^* ]' [/ }, G8 a* H/ Jun 01,'06 R0.02  Added FAT12 support.$ r5 g! h- e; h$ x# O* p4 Y$ S9 p
/                   Removed unbuffered mode.
+ U8 e  d8 q- N1 S/                   Fixed a problem on small (<32M) partition.2 i! w3 @0 N) q- D! z
/ Jun 10,'06 R0.02a Added a configuration option (_FS_MINIMUM).
. Y4 i. s& _, ?4 i# C& e2 _- O& h/
- ^, q+ Q9 k# @0 U) y3 N3 J" D/ Sep 22,'06 R0.03  Added f_rename().
+ S  K" B6 `. `/                   Changed option _FS_MINIMUM to _FS_MINIMIZE.
( v# P6 U+ U$ ^/ Dec 11,'06 R0.03a Improved cluster scan algorithm to write files fast.
. J9 r  @2 z- O2 \) B4 _/                   Fixed f_mkdir() creates incorrect directory on FAT32.
* a1 z" j6 |" N/
* \/ w$ `4 Y5 ^# `! `% `/ Feb 04,'07 R0.04  Supported multiple drive system.4 g1 Y: \, ], z  s( X9 q$ n& N
/                   Changed some interfaces for multiple drive system.( U% A8 r- z1 X9 ^  @2 o8 n) z, \: i
/                   Changed f_mountdrv() to f_mount().
! @- E# }( O  [; D" V% H9 ~  S/                   Added f_mkfs().& k3 B$ g) F( T. d9 `5 F
/ Apr 01,'07 R0.04a Supported multiple partitions on a physical drive./ p( e9 x: J) p; [) n. f
/                   Added a capability of extending file size to f_lseek().: W$ o5 M  i4 }2 w: }% j
/                   Added minimization level 3.+ n6 f4 h* w/ x6 K( c3 U; m1 D
/                   Fixed an endian sensitive code in f_mkfs().
8 M; B+ V2 \. x5 b: g- u/ May 05,'07 R0.04b Added a configuration option _USE_NTFLAG.
7 Y0 V" e! E3 i+ u6 D. I/                   Added FSInfo support.
2 s; S2 q( a: z; O3 K5 g/                   Fixed DBCS name can result FR_INVALID_NAME.
5 a1 `7 m" l8 j, H( r/                   Fixed short seek (<= csize) collapses the file object.8 ~' P. n% F" l4 x# _
/5 Y+ }* @- Z6 p) k: F
/ Aug 25,'07 R0.05  Changed arguments of f_read(), f_write() and f_mkfs().1 U  f) N  V  Y8 ]. L
/                   Fixed f_mkfs() on FAT32 creates incorrect FSInfo.
9 B9 o- ]) i, v* m2 h9 T5 w) }/                   Fixed f_mkdir() on FAT32 creates incorrect directory.- @: `5 G; X/ z+ Y* v3 x
/ Feb 03,'08 R0.05a Added f_truncate() and f_utime().
: b7 _$ X  A- L+ d/                   Fixed off by one error at FAT sub-type determination.5 O2 h; ^7 R% t4 x% C
/                   Fixed btr in f_read() can be mistruncated.
% w- z7 L* M; M! [: B/ N9 p0 P/                   Fixed cached sector is not flushed when create and close without write.% Y3 ^* w; K- v9 l' v
/
2 I; p# E9 V" R* K9 r2 Z1 _/ Apr 01,'08 R0.06  Added fputc(), fputs(), fprintf() and fgets().
( _7 N4 ?& x: L! p# A/                   Improved performance of f_lseek() on moving to the same or following cluster.0 f0 A" k$ b8 g7 I
/
8 U8 I' E/ [! U/ Apr 01,'09 R0.07  Merged Tiny-FatFs as a configuration option. (_FS_TINY)
0 g+ G1 P: ~% h; r( K: l/                   Added long file name feature.
0 ~6 l$ v0 p4 `- ~% ^/                   Added multiple code page feature.* T( O* [1 V. d' O3 |
/                   Added re-entrancy for multitask operation.1 ?5 k2 s# V, B! Z9 {! z; g
/                   Added auto cluster size selection to f_mkfs().
/ b$ H% J$ `+ M  `/ F/                   Added rewind option to f_readdir().3 ~  O/ J9 g7 ^$ }5 q3 d
/                   Changed result code of critical errors.7 f4 Z/ v$ |7 B7 |8 Q) S. U0 q
/                   Renamed string functions to avoid name collision.
: c9 L4 w- w* M8 Y6 Z5 D! C4 ?/ Apr 14,'09 R0.07a Separated out OS dependent code on reentrant cfg.
* o; Q- \, D8 J/ }7 ~& g+ n! {/                   Added multiple sector size feature.5 n0 z% B+ k; ?0 |3 j0 }3 F2 [6 n
/ Jun 21,'09 R0.07c Fixed f_unlink() can return FR_OK on error.
# _) Q; J3 f' Y" n4 N! r( K# m/                   Fixed wrong cache control in f_lseek().4 L9 H# x- m( }% T  A
/                   Added relative path feature.
, _4 W$ C) V1 b8 Z3 B3 e1 \/                   Added f_chdir() and f_chdrive()., H% k& r0 {. j) F! G
/                   Added proper case conversion to extended char.
6 e+ Q! I: }) Y* x& a1 `/ Nov 03,'09 R0.07e Separated out configuration options from ff.h to ffconf.h.; y( a7 b" R- s
/                   Fixed f_unlink() fails to remove a sub-dir on _FS_RPATH.' G/ H* z  b; M( K
/                   Fixed name matching error on the 13 char boundary.
% n4 G( d( i* e  i/                   Added a configuration option, _LFN_UNICODE.
7 H5 {% U2 M9 l/ B) Q$ P9 B) e/                   Changed f_readdir() to return the SFN with always upper case on non-LFN cfg.6 E9 p' B! R# p; ?7 T
/% b- M. c) d* b; f0 P) w
/ May 15,'10 R0.08  Added a memory configuration option. (_USE_LFN = 3)+ ~: C& \6 c/ @7 O5 w# E
/                   Added file lock feature. (_FS_SHARE)% `! g" v+ R' u2 [$ @; n3 i' H! `
/                   Added fast seek feature. (_USE_FASTSEEK)6 p) T- K8 W; I! x7 B; N
/                   Changed some types on the API, XCHAR->TCHAR.2 S2 J" t$ s( ?4 _5 g0 H
/                   Changed fname member in the FILINFO structure on Unicode cfg.
( \, b6 J  F0 p: V) X/                   String functions support UTF-8 encoding files on Unicode cfg.( z- m3 t; U. S5 \! D
/ Aug 16,'10 R0.08a Added f_getcwd(). (_FS_RPATH = 2); Z, T$ Q3 z* E& x, v
/                   Added sector erase feature. (_USE_ERASE)
& V; ~& k0 u/ B! E5 B. [4 x6 \/                   Moved file lock semaphore table from fs object to the bss." i+ Q' a9 Q: `+ D
/                   Fixed a wrong directory entry is created on non-LFN cfg when the given name contains ';'.
" m* d# l" s( \2 J2 c% q, K$ Z/                   Fixed f_mkfs() creates wrong FAT32 volume.* F; L' {% v6 a/ I
/ Jan 15,'11 R0.08b Fast seek feature is also applied to f_read() and f_write().
& v% c" U3 P' f% @. L/                   f_lseek() reports required table size on creating CLMP.
- S! {7 Y) j6 w4 \1 v/                   Extended format syntax of f_printf function.
1 k; y+ x3 o9 @& m$ Q" k" K% ^  o/                   Ignores duplicated directory separators in given path names.
7 E; i6 |/ G, u+ \8 v0 \+ f9 B. p/
. S' B- U; |! D- }" g+ _" S# c/ z/ Sep 06,'11 R0.09  f_mkfs() supports multiple partition to finish the multiple partition feature.9 C! p& k# L/ S  F5 x' I% d) s8 u
/                   Added f_fdisk(). (_MULTI_PARTITION = 2)0 X/ g4 Z6 I4 k
/---------------------------------------------------------------------------*/
, i$ H2 ]- x( m& R* o9 L' F# A( H5 O* c

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 07:23 , Processed in 0.066654 second(s), 34 queries , Gzip On.

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

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

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