TT12-MCU/applications/w25q.c
murmur 61205128e8 fashlz --ok
ulog --ok
rtc --ok
flash --ok
2023-04-27 16:54:45 +08:00

60 lines
1.2 KiB
C

/*
* Copyright (c) 2006-2021, RT-Thread Development Team
*
* SPDX-License-Identifier: Apache-2.0
*
* Change Logs:
* Date Author Notes
* 2023-04-14 murmur the first version
*/
#include <rtthread.h>
//#define LOG_TAG "flash"
//#define LOG_LVL LOG_LVL_DBG
//#include <ulog.h>
#define DBG_TAG "main"
#define DBG_LVL DBG_LOG
#include <rtdbg.h>
#include "board.h"
#include <rtdevice.h>
int rt_hw_spi_flash_init(void)
{
__HAL_RCC_GPIOB_CLK_ENABLE();
__HAL_RCC_GPIOD_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOG, GPIO_PIN_8);
if (RT_NULL == rt_sfud_flash_probe("W25Q128", "spi10"))
{
rt_kprintf("sfud error.\n");
return -RT_ERROR;
};
rt_kprintf("sfud success.\n");
return RT_EOK;
}
/* 导出到自动初始化 */
INIT_COMPONENT_EXPORT(rt_hw_spi_flash_init);
void w25q128_mount(void)
{
// dfs_mkfs("elm", "W25Q128");
rt_device_t dev;
dev = rt_device_find("W25Q128");
if(dev != RT_NULL) {
if(dfs_mount("W25Q128", "/", "elm", 0, 0) == 0){
rt_kprintf("spi_flash mount to spi!\n");
} else {
rt_kprintf("spi_flash mount to spi failed!\n");
}
}
}
/* 导出到自动初始化 */
INIT_COMPONENT_EXPORT(w25q128_mount);