• 大小: 21.11MB
    文件类型: .zip
    金币: 1
    下载: 0 次
    发布日期: 2023-07-08
  • 语言: 其他
  • 标签: SD卡  FATFS  STM32  

资源简介

完整的SD卡(spi)读写程序,完整的FATFS文件系统移植(支持STM32F4系列)

资源截图

代码片段和文件信息

/*------------------------------------------------------------/
/ Open or create a file in append mode
/------------------------------------------------------------*/

FRESULT open_append (
    FIL* fp            /* [OUT] File object to create */
    const char* path    /* [IN]  File name to be opened */

{
    FRESULT fr;

    /* Opens an existing file. If not exist creates a new file. */
    fr = f_open(fp path FA_WRITE | FA_OPEN_ALWAYS);
    if (fr == FR_OK) {
        /* Seek to end of the file to append data */
        fr = f_lseek(fp f_size(fp));
        if (fr != FR_OK)
            f_close(fp);
    }
    return fr;
}


int main (void)
{
    FRESULT fr;
    FATFS fs;
    FIL fil;

    /* Open or create a log file and ready to append */
    f_mount(&fs ““ 0);
    fr = open_append(&fil “logfile.txt“);
    if (fr != FR_OK) return 1;

    /* Append a line */
    f_printf(&fil “%02u/%02u/%u %2u:%02u\n“ Mday Mon Year Hour Min);

    /* Close the file */
    f_close(&fil);

    return 0;
}


 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----
     目录           0  2018-10-08 13:40  SDcard(spi)\CORE\
     文件       24423  2016-04-15 22:24  SDcard(spi)\CORE\cmsis_armcc.h
     文件      114498  2016-04-15 22:24  SDcard(spi)\CORE\core_cm4.h
     文件        3620  2016-04-15 22:24  SDcard(spi)\CORE\core_cmFunc.h
     文件        3636  2016-04-15 22:24  SDcard(spi)\CORE\core_cmInstr.h
     文件        3662  2016-04-15 22:24  SDcard(spi)\CORE\core_cmSimd.h
     文件       31694  2016-04-15 22:24  SDcard(spi)\CORE\startup_stm32f429xx.s
     目录           0  2018-10-08 13:40  SDcard(spi)\FATFS\
     目录           0  2018-10-10 17:26  SDcard(spi)\FATFS\doc\
     文件        3481  2016-04-18 16:54  SDcard(spi)\FATFS\doc\css_e.css
     文件        3896  2016-04-18 16:54  SDcard(spi)\FATFS\doc\css_j.css
     目录           0  2018-10-08 13:40  SDcard(spi)\FATFS\doc\img\
     文件        1063  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\app1.c
     文件        1609  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\app2.c
     文件        4134  2016-06-03 15:59  SDcard(spi)\FATFS\doc\img\app3.c
     文件       10371  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\app4.c
     文件        1414  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f1.png
     文件        1458  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f2.png
     文件        1039  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f3.png
     文件        2335  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f4.png
     文件        2479  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f5.png
     文件        1464  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f6.png
     文件       11388  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\f7.png
     文件       22722  2016-06-03 15:59  SDcard(spi)\FATFS\doc\img\funcs.png
     文件        5521  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\layers.png
     文件        3843  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\layers1.png
     文件        3741  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\layers2.png
     文件        2379  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\layers3.png
     文件      686662  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\mkfatimg.zip
     文件        7932  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\modules.png
     文件       19068  2016-04-18 16:54  SDcard(spi)\FATFS\doc\img\rwtest.png
............此处省略363个文件信息

评论

共有 条评论