/* * Copyright (c) 2006-2023, RT-Thread Development Team * * SPDX-License-Identifier: Apache-2.0 * * Change Logs: * Date Author Notes * 2018-11-27 zylx first version */ #include #include #include #include #include #include #ifdef BSP_USING_SPI_FLASH #include "spi_flash.h" #include "spi_flash_sfud.h" static int rt_hw_spi_flash_init(void) { rt_hw_spi_device_attach("spi1", "spi10", 24); // CS:PB8 if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10")) { return -RT_ERROR; }; return RT_EOK; } INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init); #if defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) #include #define BLK_DEV_NAME "W25Q128" int mnt_init(void) { rt_thread_delay(RT_TICK_PER_SECOND); if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0) { rt_kprintf("file system initialization done!\n"); } else { if(dfs_mkfs("elm", BLK_DEV_NAME) == 0) { if (dfs_mount(BLK_DEV_NAME, "/", "elm", 0, 0) == 0) { rt_kprintf("file system initialization done!\n"); } else { rt_kprintf("file system initialization failed!\n"); } } } return 0; } INIT_ENV_EXPORT(mnt_init); #endif /* defined(RT_USING_DFS_ELMFAT) && !defined(BSP_USING_SDCARD) */ #endif /* BSP_USING_SPI_FLASH */