搜索
bottom↓
回复: 4

求教傻孩子 Petit FatFs 的写函数 pf_write() 数据写不进去,求高手解脱,求例程

[复制链接]

出0入0汤圆

发表于 2012-3-7 18:42:32 | 显示全部楼层 |阅读模式
Petit FatFs  的写函数 pf_write() 数据写不进去,求高手解脱,求例程  其他函数功能都好使  就是写不进去  求高手 给解释几句呗  非常感谢  分享个例程  就万分感谢了
 

出0入0汤圆

发表于 2012-3-7 18:59:53 | 显示全部楼层
kao 2位论坛的大侠 都要出来给你解答问题//////

出0入0汤圆

 楼主| 发表于 2012-3-7 19:24:52 | 显示全部楼层
抱歉啊  我就随便问问啊  希望能大家百忙之中 能抽空 看下我的小问题。

出0入0汤圆

发表于 2012-4-5 17:30:25 | 显示全部楼层
需要详细阅读官网中关于pf_write的说明:
File write operation must be done in following sequence.

1.pf_lseek(ofs); read/write pointer must be moved to sector bundary prior to initiate write operation or it will be rounded-down to the sector boundary.
2.pf_write(buff, btw, &bw); Initiate write operation. Write first data to the file.
3.pf_write(buff, btw, &bw); Write next data. Any other file function cannot be used while a write operation is in progress.
4.pf_write(0, 0, &bw); Finalize the write operation. If read/write pointer is not on the sector boundary, left bytes in the sector will be filled with zero.

出0入0汤圆

发表于 2012-4-5 17:31:15 | 显示全部楼层
以下是我测试的一个小例程,供参考,可能不一定全面:

//The following module is to write bytes to txt file.
//Note:it use the new string to replace all of the old bytes.
//For example:the old bytes:123456789abcefg
//                                     123456789
//                  the new string:Hello world!
//                  The result:Hello world!
//                                 Hello world!
    rc = pf_open("write.txt");
    pf_lseek(rc);  
    for (;;)
    {
        rc = pf_write("Hello world!\r\n", 14, &bw);
        if (rc || !bw) break;
    }
    rc = pf_write(0, 0, &bw);           //Finalize the write operation.
    ClearLED3;
    while(1);
回帖提示: 反政府言论将被立即封锁ID 在按“提交”前,请自问一下:我这样表达会给举报吗,会给自己惹麻烦吗? 另外:尽量不要使用Mark、顶等没有意义的回复。不得大量使用大字体和彩色字。【本论坛不允许直接上传手机拍摄图片,浪费大家下载带宽和论坛服务器空间,请压缩后(图片小于1兆)才上传。压缩方法可以在微信里面发给自己(不要勾选“原图),然后下载,就能得到压缩后的图片】。另外,手机版只能上传图片,要上传附件需要切换到电脑版(不需要使用电脑,手机上切换到电脑版就行,页面底部)。
您需要登录后才可以回帖 登录 | 注册

本版积分规则

手机版|Archiver|amobbs.com 阿莫电子技术论坛 ( 粤ICP备2022115958号, 版权所有:东莞阿莫电子贸易商行 创办于2004年 (公安交互式论坛备案:44190002001997 ) )

GMT+8, 2024-5-5 13:54

© Since 2004 www.amobbs.com, 原www.ourdev.cn, 原www.ouravr.com

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