MCU:ESP32S3
CSDK:ESP-IDFV5.0.1
报错情况:
- 首先创建了一个自己的组件库max31856,目录结构如下:
- 之后在驱动文件中调用了基础库:
#include "driver/spi_master.h"
- 之后编写CMakeLists.txt文件如下:
idf_component_register(SRCS "src/max31856.c"
INCLUDE_DIRS "src"
)
- 最后编译发现如下报错:
fatal error: driver/spi_master.h: No such file or directory
15 | #include "driver/spi_master.h"
| ^~~~~~~~~~~~~~~~~~~~~
compilation terminated.
解决方法:
- 在CMakeLists.txt文件中添加:
REQUIRES driver
idf_component_register(SRCS "src/max31856.c"
REQUIRES driver
INCLUDE_DIRS "src"
)
- 效果:完美解决