我按着官网的sd卡文件系统教程来的 添加了如下三个函数
void sd_mount(void *parameter)
{
while (1)
{
rt_thread_mdelay(500);
if(rt_device_find("sd0") != RT_NULL)
{
if (dfs_mount("sd0", "/C", "elm", 0, 0) == RT_EOK)
{
LOG_I("sd card mount to '/C'");
break;
}
else
{
LOG_W("sd card mount to '/C' failed!");
}
}
}
}
int stm32_sdcard_mount(void)
{
rt_thread_t tid;
tid = rt_thread_create("sd_mount", sd_mount, RT_NULL,
1024, RT_THREAD_PRIORITY_MAX - 2, 20);
if (tid != RT_NULL)
{
rt_thread_startup(tid);
}
else
{
LOG_E("create sd_mount thread err!");
}
return RT_EOK;
}
INIT_APP_EXPORT(stm32_sdcard_mount);
static int rt_hw_spi1_tfcard(void)
{
__HAL_RCC_GPIOC_CLK_ENABLE();
rt_hw_spi_device_attach("spi1", "spi10", GPIOC, GPIO_PIN_3);
LOG_I("sd card \r\n");
return msd_init("sd0", "spi10");
}
INIT_DEVICE_EXPORT(rt_hw_spi1_tfcard);
然后串口显示挂载失败
建议直接找到源码加Log分析
源码位置:
rt-thread/components/dfs/src/dfs_fs.c line of 214:
/**
* this function will mount a file system on a specified path.
*
* @param device_name the name of device which includes a file system.
* @param path the path to mount a file system
* @param filesystemtype the file system type
* @param rwflag the read/write etc. flag.
* @param data the private data(parameter) for this file system.
*
* @return 0 on successful or -1 on failed.
*/
int dfs_mount(const char *device_name,
const char *path,
const char *filesystemtype,
unsigned long rwflag,
const void *data)
加Log分析具体是哪个 return -1 的case
然后验证自己的代码
这里return了 请问这是什么问题
最后追踪到这里了好像是没找到到某个东西 直接return null