RT-Thread--外部 flash 掛載 fatfs 文件系統

外部 flash 掛載 fatfs 文件系統

/*
 * Copyright (c) 2006-2018, RT-Thread Development Team
 *
 * SPDX-License-Identifier: Apache-2.0
 *
 * Change Logs:
 * Date           Author       Notes
 * 2020-04-28     tyustli      first version
 */

#include <rtthread.h>
#include <rtdevice.h>
#include <board.h>
#include "dfs_file.h"
#include "drv_spi.h"
#include "spi_flash_sfud.h"

int main(int argc, char *argv[])
{
    __HAL_RCC_GPIOB_CLK_ENABLE();
    rt_hw_spi_device_attach("spi1", "spi10", GPIOB, GPIO_PIN_14);

    if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10"))
    {
        return -RT_ERROR;
    };

    dfs_mkfs("elm", "W25Q128");

    if (dfs_mount("W25Q128", "/", "elm", 0, 0) == RT_EOK)
    {
        rt_kprintf("onchip elm filesystem mount to '/'\n");
    }
    else
    {
        rt_kprintf("onchip elm filesystem mount to '/' failed!\n");
    }
}

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章