OpenEdv-开源电子网

 找回密码
 立即注册
正点原子全套STM32/Linux/FPGA开发资料,上千讲STM32视频教程免费下载...
查看: 15046|回复: 3

STM32读取SD卡 bin文件

[复制链接]

2

主题

4

帖子

0

精华

新手上路

积分
44
金钱
44
注册时间
2012-1-30
在线时间
3 小时
发表于 2012-2-5 08:24:10 | 显示全部楼层 |阅读模式

请问STM32读取SD卡 bin文件

由于BIN文件比较大 有32K 而STM32 SRAM 没有这么大 如果用 res=f_read(&file, buffer, sizeof(buffer), &br);  函数 因该没有这么大空间

不知有什么好的方法?

我的目的 BIN读取过来 通过IIC 写入从设备!相当于更新FW。

以下函数不知 有没有可以用到的。
/*--------------------------------------------------------------*/
/* FatFs module application interface                           */

FRESULT f_mount (BYTE, FATFS*);      /* Mount/Unmount a logical drive */
FRESULT f_open (FIL*, const TCHAR*, BYTE);   /* Open or create a file */
FRESULT f_read (FIL*, void*, UINT, UINT*);   /* Read data from a file */
FRESULT f_lseek (FIL*, DWORD);      /* Move file pointer of a file object */
FRESULT f_close (FIL*);        /* Close an open file object */
FRESULT f_opendir (DIR*, const TCHAR*);    /* Open an existing directory */
FRESULT f_readdir (DIR*, FILINFO*);     /* Read a directory item */
FRESULT f_stat (const TCHAR*, FILINFO*);   /* Get file status */
FRESULT f_write (FIL*, const void*, UINT, UINT*); /* Write data to a file */
FRESULT f_getfree (const TCHAR*, DWORD*, FATFS**); /* Get number of free clusters on the drive */
FRESULT f_truncate (FIL*);       /* Truncate file */
FRESULT f_sync (FIL*);        /* Flush cached data of a writing file */
FRESULT f_unlink (const TCHAR*);     /* Delete an existing file or directory */
FRESULT f_mkdir (const TCHAR*);      /* Create a new directory */
FRESULT f_chmod (const TCHAR*, BYTE, BYTE);   /* Change attriburte of the file/dir */
FRESULT f_utime (const TCHAR*, const FILINFO*);  /* Change timestamp of the file/dir */
FRESULT f_rename (const TCHAR*, const TCHAR*);  /* Rename/Move a file or directory */
FRESULT f_forward (FIL*, UINT(*)(const BYTE*,UINT), UINT, UINT*); /* Forward data to the stream */
FRESULT f_mkfs (BYTE, BYTE, UINT);     /* Create a file system on the drive */
FRESULT f_chdrive (BYTE);       /* Change current drive */
FRESULT f_chdir (const TCHAR*);      /* Change current directory */
FRESULT f_getcwd (TCHAR*, UINT);     /* Get current directory */
int f_putc (TCHAR, FIL*);       /* Put a character to the file */
int f_puts (const TCHAR*, FIL*);     /* Put a string to the file */
int f_printf (FIL*, const TCHAR*, ...);    /* Put a formatted string to the file */
TCHAR* f_gets (TCHAR*, int, FIL*);     /* Get a string from the file */

正点原子逻辑分析仪DL16劲爆上市
回复

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2012-2-5 10:21:34 | 显示全部楼层
回复【楼主位】xudongjhdd:
---------------------------------
你一次读512个字节,读取后写入IIC设备,这样循环读取30K/512次就读完了.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

2

主题

4

帖子

0

精华

新手上路

积分
44
金钱
44
注册时间
2012-1-30
在线时间
3 小时
 楼主| 发表于 2012-2-5 12:06:51 | 显示全部楼层
f_read(&file, buffer, sizeof(buffer), &br);   
用这个函数怎么控制呀  
第一次在首地址 第二次在512的字节处!...以此类推  文件指针 怎么调用
能否给个DEMO !
谢谢原子哥!
回复 支持 反对

使用道具 举报

530

主题

11万

帖子

34

精华

管理员

Rank: 12Rank: 12Rank: 12

积分
165371
金钱
165371
注册时间
2010-12-1
在线时间
2110 小时
发表于 2012-2-5 12:51:21 | 显示全部楼层
回复【3楼】xudongjhdd:
---------------------------------
百度.
我是开源电子网www.openedv.com站长,有关站务问题请与我联系。
正点原子STM32开发板购买店铺http://openedv.taobao.com
正点原子官方微信公众平台,点击这里关注“正点原子”
回复 支持 反对

使用道具 举报

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

本版积分规则



关闭

原子哥极力推荐上一条 /2 下一条

正点原子公众号

QQ|手机版|OpenEdv-开源电子网 ( 粤ICP备12000418号-1 )

GMT+8, 2025-2-24 20:18

Powered by OpenEdv-开源电子网

© 2001-2030 OpenEdv-开源电子网

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