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 
#include 
#include 
#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");
    }
}

你可能感兴趣的:(RTOS)