一、自定义文件组件使用xxxx.c xxxx.h
1: 控制端工程目录创建组件文件夹
》 idf.py -C components create-component User_led
2: 定义组件如果引用指定外部依赖库,当前文件的cmakelists.txt 添加 REQUIRES driver
idf_component_register(SRCS "uesr_led.c"INCLUDE_DIRS "include" "."#)REQUIRES driver)# 指定外部依赖库 main文件夹默认指定#PRIV_REQUIRES gpio)# 注意:
# REQUIRES driver demo_dir)#
# 自定义组件.c调用其他自定义组件demo_dir的函数,REQUIRES 后面直接加文件夹名即可
#上面说的是在main函数外自定义组件与相互引用(User_led的.c引用了espressif__led_strip的.c),需要定义REQUIRES driver espressif__led_strip。如果在main内定义的话是不要配置,编译时系统会自动识别引用组件的.c
举例:
1.station_example_main.c引用外部自定义组件uesr_led.c
注:cmakelists.txt 在man函数中不需要额外配置,编译时自动识别。