大家开始玩MSP430的开发板,介绍一个精简版文件系统---Petit FatFs文件系统
[复制链接]
Petit FatFs 是FatFs 的精简版,专为 RAM较小的单片机设计
Features- Very small RAM consumption (44 bytes work area + certain stack).
- Very small code size (2K-4K bytes).
- Supports FAT32.
- Single volume and Single file.
- File write function with some restrictions.
Application InterfacePetit FatFs module provides following functions.
链接:http://elm-chan.org/fsw/ff/00index_p.html
下面转一篇网友的移植心得:
首先 MSP430与 SD卡的接口,见TI 官方例程: Interfacing the MSP430 With MMC/SD Flash Memory Cards (Rev. B)
www.ti.com/lit/an/slaa281b/slaa281b.pdf
http://www.ti.com/mcu/docs/litab ... =1&familyId=342
MSP430F2274与SD 接口:
P3.7---------->CS
P3.5 MISO--->DO
P3.4 MOSI--->DI
P3.0 CLK----->SCLK
首先将SD卡 或者 microSD(TF卡)或者 MMC卡 格式化成 FAT(FAT16);
在根目录创建 文本文件,比如 abc.txt 内容为 Hello World
读取abc.txt 的代码为:
void main (void)
{
WDTCTL = WDTPW + WDTHOLD; // Stop watchdog timer
BCSCTL1 = CALBC1_16MHZ;
DCOCTL = CALDCO_16MHZ;
spi_initialize();
disk_initialize();
pf_mount(&fs);
pf_open("abc.txt");
pf_read(Line, sizeof(Line), &s1);
写入代码为
pf_open("abc.txt");
res= pf_write(towrite, sizeof(towrite), &s2);
注意:写入文件,只能写入原文件大小的数据,不能大于,这是 Petit FatFs 的功能所限。
打开根目录下名为 hello的文件夹,并显示文件夹中文件的代码为
res= pf_opendir(&dir, "hello");
pf_readdir(&dir, &fno);
原文链接:http://www.amobbs.com/thread-5461789-1-1.html
|