FATS document management system STM32 transplant

Preface: I transplanted FATS of STM32F1 code has been uploaded to my resources, if necessary you can click on the following link: https://download.csdn.net/download/qq_40831778/11916818

I. Overview

1, the file system Introduction:

(1) file system: institutional management software and store file information.

(2) commonly used file systems:

  •      FAT/FATFS
  •      NTFS (file-based security system, is a unique structure Wundow NT file system used.
  •      CDFS: CDFS file system is most CD

2, FATFS File System Introduction:

      FATFS is a completely free and open source FAT file system module, designed specifically for small embedded systems design, written entirely in standard C language, have good hardware platform independence, can be ported to 8051, PIC, ARM and other microcontrollers just do a simple modification. It supports FAT12, FAT16, FATI32, support for multiple storage media; an independent buffers, multiple files can be read / write, and especially for 8-bit microcontrollers and 16-bit microcontroller optimized.

3, FATFS file system features:

  •      Window-compatible FAT file system (supports FAT12 / FAT16 / FAT32).
  •      Less code, and high efficiency.
  •      Platform-independent, portable simple written entirely in C language.
  •      More configuration options: to support multi-volume (physical drive or partition, up to 10 volumes), a plurality of ANSI / OEM code page, supports long filenames, the RTOS support, support for multiple sector size.
     

4, document presents the main file system:

 

file name

Features

Explanation

ffconf.h

FATFS module configuration file

You need to configure the parameters according to the needs

ff.h

FATFS and application modules common to include files

no need for correction

ff.c

FATFS module source code

no need for correction

diskio.h

FATFS and disk I / O module comprises a common file

no need for correction

diskio.c

FATFS and disk I / O module interface layer file

Platform-dependent code, you need to write a function according to user storage medium

interger.h

Data type definitions

And compiler-related

 

Second, start transplants

1, we open download FATS good source, there will be two folders Normally, we open the src folder, this folder which we need FATS source,

 

 2, we note that there is also a src folder, this is an optional external features (such as support for Chinese, etc.). Generally, we use the Chinese, it will add to the project cc926.c inside just fine.

3, we need to add the source file to the STM32, Normally, we just ff.c, cc936.c, diskio.c, added to the project inside just fine. , After a good start configuration file.

4, ffconf.h configuration instructions

This ffconf.h header file which is about FATFS various settings, we can cut FATFS according to their needs, we have reached the standard they want. We look at it all those settings:

1)              _FS_TINY

This setting is configured to use the standard mode, or minor mode. We use the standard mode, set here: 0.

2)              _FS_READONLY

Whether to use read-only mode, we choose to read and write. Set: 0.

3)              _FS_MINIMIZE

This setting is to select whether to cut out some of the functions specific to those cropping, you can view the following setup instructions, full-featured model that we used here. Set: 0.

4)              _USE_STRFUNC

This is used to set whether to support the string class operation, we choose to use. To: 1.

5)              _USE_MKFS

Use the format to use, here we choose to use. To: 1.

6)              _USE_FASTSEEK

 

Use enable fast positioning, we choose to use. To: 1.

7)              _USE_LABEL

Whether to enable disk label function. Use can also, do not use can be. We use here. To: 1.

8)              _USE_FORWARD

This is set in the TINY model, here we use the standard mode, ignore it.

9)              _CODE_PAGE

这个用于设置语言类型。我们使用的中文。设置为:936

10) _USE_LFN

该选项用于设置是否支持长文件名(还需要_CODE_PAGE 支持),取值 范围为 0~3。0,表示不支持长文件名,1~3 是支持长文件名,但是存储地方 不一样。我们这里就默认使用 FATFS 本身的存储方式了。设置为:1。

11) _MAX_LFN

设置最大文件名长度,我们直接设置最大。设置为:255。

12) _LFN_UNICODE

是否使用 FATFS 的字符编码。我们不使用。设置为:0

13) _FS_RPATH

这里也是一些函数裁剪,我们这里设置为:1。

14) _VOLUMES

这里设置的是支持的卷轴数量,我们挂载 SD 卡,有时候可以挂载下

FLASH,所以这里我们设置为两个:2。

15) _MAX_SS

这里是设置扇区缓冲的最大值,我们设置为:512。

16) _MULTI_PARTITION

是否使用多重分区分配。我们这里设置为:0。

17) _USE_ERASE 使用使用扇区擦除。我们这里不那么麻烦,想使用的时候在设置。设置 为:0。

18) _WORD_ACCESS

这里定义使用权限。一般不使用。我们设置为:0。

19) _FS_REENTRANT

20) _FS_TIMEOUT

21) _SYNC_t

22) _FS_LOCK

这几个设置,我们都没有使用到,所以直接保持默认状态就好。

4、 diskio.c 函数介绍

(1)disk_initialize()函数

2)              disk_status()函数

3、disk_read()函数

4)              disk_write()函数

5)              disk_ioctl()函数

6)              get_fattime()函数 

 

三、fats的使用

我们首先需要添加SPI通信协议,之后我们根据自己所要使用的模块,更改ffconf.h文件,以及 diskio.c 里面的函数就可以正常使用了。

 

最后,看到我这篇文章的朋友,如果我的文章真的帮助到了你,记得帮我点个赞,如果希望和我共同学习,共同交流,可以关注我一下。本人QQ:2992789432

发布了45 篇原创文章 · 获赞 96 · 访问量 1万+

Guess you like

Origin blog.csdn.net/qq_40831778/article/details/102737382