Seeed_Arduino_FS

2025-12-11 0 946

Seeed-Arduino-fs

介绍

Arduino的轻量级FATF端口。该库包含通过SPI驱动SD卡的例程。文件系统部分是通用的,这意味着您可以轻松地将其移植到其他类型的内存中,例如QSPI Flash,Emmc,等。

一个示例包含在Seeed_arduino_sfud中

用法

该代码已在WIO终端进行了测试。

Seeed_Arduino_FS.h>

#define LOG Serial
#define DEV SD

#ifdef _SAMD21_
#define SDCARD_SS_PIN 1
#define SDCARD_SPI SPI
#endif

void setup() {
LOG.begin(115200);
pinMode(5, OUTPUT);
digitalWrite(5, HIGH);
while (!LOG) {};
while (!DEV.begin(SDCARD_SS_PIN,SDCARD_SPI,4000000UL)) {
LOG.println("Card Mount Failed");
return;
}

LOG.println("initialization done.");

// open the file. note that only one file can be open at a time,
// so you have to close this one before opening another.

File RootWrite = DEV.open("/hello.txt", "w");
// File RootWrite = DEV.open("/hello.txt", FILE_WRITE);

// if the file opened okay, write to it:
if (RootWrite) {
LOG.print("Writing to hello.txt…");
RootWrite.println("hello 1, 2, 3.");
// close the file:
RootWrite.close();
LOG.println("done.");
} else {
// if the file didn\’t open, print an error:
LOG.println("error opening hello.txt");
}

// re-open the file for reading:
File RootRead= DEV.open("/hello.txt");
if (RootRead) {
LOG.println("hello.txt:");

// read from the file until there\’s nothing else in it:
while (RootRead.available()) {
LOG.write(RootRead.read());
}
// close the file:
RootRead.close();
} else {
// if the file didn\’t open, print an error:
LOG.println("error opening hello.txt");
}
}

void loop() {
// nothing happens after setup
}
\”>

# include < Seeed_Arduino_FS .h >

# define LOG Serial
# define DEV SD

# ifdef _SAMD21_
# define SDCARD_SS_PIN 1
# define SDCARD_SPI SPI
# endif 


void setup () {
    LOG. begin ( 115200 );
    pinMode ( 5 , OUTPUT);
    digitalWrite ( 5 , HIGH);
    while (!LOG) {};
    while (!DEV. begin (SDCARD_SS_PIN,SDCARD_SPI, 4000000UL )) {
        LOG. println ( \" Card Mount Failed \" );
        return ;
    }

    LOG. println ( \" initialization done. \" );

    // open the file. note that only one file can be open at a time,
    // so you have to close this one before opening another.

    File RootWrite = DEV. open ( \" /hello.txt \" , \" w \" );
    // File RootWrite = DEV.open(\"/hello.txt\", FILE_WRITE);

    // if the file opened okay, write to it:
    if (RootWrite) {
        LOG. print ( \" Writing to hello.txt... \" );
        RootWrite. println ( \" hello 1, 2, 3. \" );
        // close the file:
        RootWrite. close ();
        LOG. println ( \" done. \" );
    } else {
        // if the file didn\'t open, print an error:
        LOG. println ( \" error opening hello.txt \" );
    }
    
    // re-open the file for reading:
    File RootRead= DEV. open ( \" /hello.txt \" );
    if (RootRead) {
        LOG. println ( \" hello.txt: \" );

        // read from the file until there\'s nothing else in it:
        while (RootRead. available ()) {
            LOG. write (RootRead. read ());
        }
        // close the file:
        RootRead. close ();
    } else {
        // if the file didn\'t open, print an error:
        LOG. println ( \" error opening hello.txt \" );
    }
}

void loop () {
    // nothing happens after setup
}

API参考

  • 布尔开始(UINT8_T SSPIN,SPICLASS&SP,INT HZ):配置SPI控制存储设备
DEV.begin(SDCARD_SS_PIN,SDCARD_SPI, 4000000UL )
// DEV.begin(104000000UL) //use qspi flash
  • sdcard_type_t cardtype():获取SD卡类型

注意:仅使用SD卡

    uint8_t cardType = DEV.cardType();
    if (cardType == CARD_NONE) {
        SERIAL. println ( \" No SD card attached \" );
        return ;
    }
  • sfud_type_t flashtype():获取flash类型

注意:仅与Flash一起工作

    uint8_t flashType = DEV.flashType();
    if (flashType == FLASH_NONE) {
        SERIAL. println ( \" No flash attached \" );
        return ;
    }
  • uint64_t cardsize():获取SD卡大小

注意:仅使用SD卡

    uint64_t cardSize = DEV.cardSize() / ( 1024 * 1024 );
    SERIAL.print( \" SD Card Size: \" );
    SERIAL.print(( uint32_t )cardSize);
    SERIAL.println( \" MB \" );
  • uint64_t flashsize():获取闪光灯大小

注意:仅与Flash一起工作

    uint32_t flashSize = DEV.flashSize() / ( 1024 * 1024 );
    SERIAL.print( \" flash Size: \" );
    SERIAL.print(( uint32_t )flashSize);
    SERIAL.println( \" MB \" );
  • uint64_t totalbytes():返回存储设备的总字节
    uint32_t totalBytes = DEV.totalBytes();
    SERIAL.print( \" Total space: \" );
    SERIAL.print(totalBytes / ( 1024 * 1024 ));
    SERIAL.println( \" MB \" );
  • uint64_t underbytes():返回存储设备的二手字节
    uint32_t usedBytes = DEV.usedBytes();
    SERIAL.print( \" Used space: \" );
    SERIAL.print(usedBytes / ( 1024 * 1024 ));
    SERIAL.println( \" MB \" );

该软件由Seeed Studio撰写
并获得MIT许可证的许可。检查许可证.txt以获取更多信息。

热烈欢迎为此软件做出贡献。您基本上可以做到这一点
分叉,进行修改然后提取请求(请按照上述链接
用于操作指南)。鼓励添加更改日志,并鼓励您的联系人到文件标头中。
感谢您的贡献。

Seeed Studio是一家位于中国深圳的开放硬件便利化公司。
受益于本地制造能力和方便的全球逻辑系统,
我们整合资源以服务新时代的创新时代。 Seeed也可以使用
全球分销商和合作伙伴推动开放硬件运动。

下载源码

通过命令行克隆项目:

git clone https://github.com/Seeed-Studio/Seeed_Arduino_FS.git

收藏 (0) 打赏

感谢您的支持,我会继续努力的!

打开微信/支付宝扫一扫,即可进行扫码打赏哦,分享从这里开始,精彩与您同在
点赞 (0)

申明:本文由第三方发布,内容仅代表作者观点,与本网站无关。对本文以及其中全部或者部分内容的真实性、完整性、及时性本站不作任何保证或承诺,请读者仅作参考,并请自行核实相关内容。本网发布或转载文章出于传递更多信息之目的,并不意味着赞同其观点或证实其描述,也不代表本网对其真实性负责。

左子网 建站资源 Seeed_Arduino_FS https://www.zuozi.net/35393.html

wondercms
上一篇: wondercms
Enduro
下一篇: Enduro
常见问题
  • 1、自动:拍下后,点击(下载)链接即可下载;2、手动:拍下后,联系卖家发放即可或者联系官方找开发者发货。
查看详情
  • 1、源码默认交易周期:手动发货商品为1-3天,并且用户付款金额将会进入平台担保直到交易完成或者3-7天即可发放,如遇纠纷无限期延长收款金额直至纠纷解决或者退款!;
查看详情
  • 1、描述:源码描述(含标题)与实际源码不一致的(例:货不对板); 2、演示:有演示站时,与实际源码小于95%一致的(但描述中有”不保证完全一样、有变化的可能性”类似显著声明的除外); 3、发货:不发货可无理由退款; 4、安装:免费提供安装服务的源码但卖家不履行的; 5、收费:价格虚标,额外收取其他费用的(但描述中有显著声明或双方交易前有商定的除外); 6、其他:如质量方面的硬性常规问题BUG等。 注:经核实符合上述任一,均支持退款,但卖家予以积极解决问题则除外。
查看详情
  • 1、左子会对双方交易的过程及交易商品的快照进行永久存档,以确保交易的真实、有效、安全! 2、左子无法对如“永久包更新”、“永久技术支持”等类似交易之后的商家承诺做担保,请买家自行鉴别; 3、在源码同时有网站演示与图片演示,且站演与图演不一致时,默认按图演作为纠纷评判依据(特别声明或有商定除外); 4、在没有”无任何正当退款依据”的前提下,商品写有”一旦售出,概不支持退款”等类似的声明,视为无效声明; 5、在未拍下前,双方在QQ上所商定的交易内容,亦可成为纠纷评判依据(商定与描述冲突时,商定为准); 6、因聊天记录可作为纠纷评判依据,故双方联系时,只与对方在左子上所留的QQ、手机号沟通,以防对方不承认自我承诺。 7、虽然交易产生纠纷的几率很小,但一定要保留如聊天记录、手机短信等这样的重要信息,以防产生纠纷时便于左子介入快速处理。
查看详情

相关文章

猜你喜欢
发表评论
暂无评论
官方客服团队

为您解决烦忧 - 24小时在线 专业服务