Skip to content

Commit aca7a71

Browse files
LiKunZhmysterywolf
authored andcommitted
[bsp][nxp]增加了drv_filesystem_spi_flash驱动
1 parent 9cad5bd commit aca7a71

File tree

1 file changed

+19
-15
lines changed

1 file changed

+19
-15
lines changed

bsp/nxp/mcx/mcxn/frdm-mcxn947/board/ports/drv_filesystem_spi_flash.c

Lines changed: 19 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,12 @@
1010
*/
1111

1212
#include <rtthread.h>
13+
14+
#if defined(BSP_USING_SPI7) && defined(RT_USING_SFUD) && defined(RT_USING_DFS) && defined(RT_USING_DFS_ELMFAT)
1315
#include <dfs_elm.h>
1416
#include "spi_flash_sfud.h"
1517
#include "dfs_fs.h"
1618
#include "dfs.h"
17-
#include "dfs_elm.h"
1819
#include "dfs_file.h"
1920

2021
#if DFS_FILESYSTEMS_MAX < 4
@@ -23,7 +24,9 @@
2324
#if DFS_FILESYSTEM_TYPES_MAX < 4
2425
#error "Please define DFS_FILESYSTEM_TYPES_MAX more than 4"
2526
#endif
26-
27+
#if RT_DFS_ELM_MAX_SECTOR_SIZE == 512
28+
#define RT_DFS_ELM_MAX_SECTOR_SIZE 4096
29+
#endif
2730
#define DBG_TAG "app.filesystem_spi_flash"
2831
#define DBG_LVL DBG_INFO
2932
#include <rtdbg.h>
@@ -34,16 +37,16 @@
3437
#define W25Q64_SPI_FLASH_NAME "w25qxx"
3538

3639
rt_err_t rt_hw_spi_device_attach(const char *bus_name, const char *device_name, rt_uint32_t pin);
37-
40+
3841
static int filesystem_mount(void)
3942
{
4043
struct rt_spi_device *spi70 = (struct rt_spi_device *)rt_malloc(sizeof(struct rt_spi_device));
41-
42-
if(!spi70)
43-
{
44-
rt_kprintf("spi sample run failed! can't find %s device!\n","spi7");
44+
45+
if(!spi70)
46+
{
47+
rt_kprintf("spi sample run failed! can't find %s device!\n","spi7");
4548
return -RT_ERROR;
46-
}
49+
}
4750

4851
struct rt_spi_configuration cfg;
4952
cfg.data_width = 8;
@@ -52,23 +55,24 @@ static int filesystem_mount(void)
5255
rt_spi_configure(spi70, &cfg);
5356

5457
/* legcy issue */
55-
56-
//rt_spi_bus_attach_device_cspin(spi70, W25Q64_SPI_DEVICE_NAME, W25Q64_SPI_BUS_NAME, 96, RT_NULL);
58+
59+
// rt_spi_bus_attach_device_cspin(spi70, W25Q64_SPI_DEVICE_NAME, W25Q64_SPI_BUS_NAME, 96, RT_NULL);
5760
rt_hw_spi_device_attach(W25Q64_SPI_BUS_NAME, W25Q64_SPI_DEVICE_NAME, 96);
58-
61+
5962
if(RT_NULL == rt_sfud_flash_probe(W25Q64_SPI_FLASH_NAME, W25Q64_SPI_DEVICE_NAME))
6063
{
6164
rt_kprintf("Flash sfud Failed!\n");
6265
return -RT_ERROR;
63-
};
64-
66+
}
67+
// dfs_mkfs("elm", "W25Q64_SPI_FLASH_NAME");
6568
if(dfs_mount(W25Q64_SPI_FLASH_NAME, "/", "elm", 0, 0))
6669
{
6770
rt_kprintf("dfs mount dev:%s failed!\n", W25Q64_SPI_FLASH_NAME);
6871
return -RT_ERROR;
6972
}
70-
73+
7174
return RT_EOK;
72-
7375
}
7476
INIT_APP_EXPORT(filesystem_mount);
77+
78+
#endif /* BSP_USING_SPI7/RT_USING_SFUD/RT_USING_DFS/RT_USING_DFS_ELMFAT */

0 commit comments

Comments
 (0)