- idf_component_register(SRCS "cledlight.c"
- INCLUDE_DIRS "include")
first of all, I don't have much experience in programming the ESP32 a the moment.
So the answer for my problem could be simple.
Currently, I have ESP-IDF v5.2 installed on my ubuntu host under the directory ~esp/esp-idf/.
Next to this directory I have created a simple esp-blinki-project with the command `idf.py create-project bliki`.
The main `blinki.c` includes among others `#include driver/gpio.h`.
When I use the comman `idf.py build` and `idf.py flash`, everithing works fine.
A LED, which is connected to the ESP32-Board, goes on and off... .
Now the Problem:
Next to my simple esp-blinki-project I created a new project to get experience with the use of own written components.
I used the the commands:
- idf.py create-project blinki-03
- Created the sub directory components for my component cledlight.
- mkdir components
- cd components
- idf.py create-component cledlight
The file cledlight.c includes among other includes `#include driver/gpio.h`.
When I try to build the project with the comman `idf.py build` I get the error message `fatal error: driver/gpio.h: No such file or directory`.
My attempts to include the esp-idf components (gpio.h ...) in the CMake-Files have so far been unsuccessful.
(I hope this post will be readable )
I would be very greatful if someone could help me.
Here you can see the code of the component cledlight:
[1] cledlight.c
- #include <stdio.h>
- #include "cledlight.h"
- #include "freertos/FreeRTOS.h"
- #include "freertos/task.h"
- #include "driver/gpio.h"
- void config_blink(void){
- gpio_set_direction(GPIO_NUM_5, GPIO_MODE_DEF_OUTPUT);
- }
- void blink_on(void){
- gpio_set_level(GPIO_NUM_5, 1);
- vTaskDelay(2000 / portTICK_PERIOD_MS);
- gpio_set_level(GPIO_NUM_5, 0);
- vTaskDelay(2000 / portTICK_PERIOD_MS);
- }
- void config_blink(void);
- void blink_on(void);
[4] blinki-03.c
- #include <stdio.h>
- #include "cledlight.h"
- void app_main(void)
- {
- config_blink();
- while(1){
- blink_on();
- }
- }
- idf_component_register(SRCS "blinki-03.c"
- INCLUDE_DIRS ".")
[6] CMakeLists.txt
- # For more information about build system see
- # https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html
- # The following five lines of boilerplate have to be in your project's
- # CMakeLists in this exact order for cmake to work correctly
- cmake_minimum_required(VERSION 3.16)
- include($ENV{IDF_PATH}/tools/cmake/project.cmake)
- project(blinki-03)