First time building code esp-idf in VScode
Posted: Tue Jul 20, 2021 4:22 am
Hello. I have decided to move from Arduino platform to ESP-IDF. I have started with a hello world program and I have created my own .c and .h files the same way I do for my Arduino projetcts:
setup.c:
setup.h
My project structure is as following:
https://ibb.co/zrRjpWZ
I have 2 questions:
1.I am including this header file in my main.c but for some reason I am not able to call this function as it is not recognised, and the error returned:
I have heard that I need to add the custom library to the cmakelists.txt but unsure how. Can someone clarify?
2. Once I clean the projects, it takes insanely long time to build the project. Why is that? I have expected esp-idf to be much faster than Arduino platform projects but it is about 10 times slower compile times. Compiling simple hello world program took 105 seconds :
https://ibb.co/G0xPzXj
setup.c:
Code: Select all
#include "setup.h"
void setupModem()
{
#ifdef MODEM_RST
// Keep reset high
gpio_config_t modem_pwr_conf;
modem_pwr_conf.intr_type = GPIO_PIN_INTR_DISABLE;
modem_pwr_conf.mode = GPIO_MODE_OUTPUT;
modem_pwr_conf.pin_bit_mask = (1 << MODEM_PWRKEY);
gpio_set_level(GPIO_NUM_4, 1);
#endif
gpio_config_t modem_rst_conf;
modem_rst_conf.intr_type = GPIO_PIN_INTR_DISABLE;
modem_rst_conf.mode = GPIO_MODE_OUTPUT;
modem_rst_conf.pin_bit_mask = (1 << MODEM_RST);
gpio_set_level(GPIO_NUM_5, 1);
// Turn on the Modem power first
// Pull down PWRKEY for more than 1 second according to manual requirements
gpio_set_level(GPIO_NUM_4, 1);
delay(100);
gpio_set_level(GPIO_NUM_4, 0);
delay(1000);
gpio_set_level(GPIO_NUM_4, 1);
// Initialize the indicator as an output
gpio_config_t modem_led_conf;
modem_led_conf.intr_type = GPIO_PIN_INTR_DISABLE;
modem_led_conf.mode = GPIO_MODE_OUTPUT;
modem_led_conf.pin_bit_mask = (1 << LED_GPIO);
gpio_set_level(GPIO_NUM_13, 0);
}
Code: Select all
#include "driver/gpio.h"
#define MODEM_RST GPIO_SEL_5
#define MODEM_PWRKEY GPIO_SEL_4
#define MODEM_POWER_ON GPIO_SEL_23
#define MODEM_TX GPIO_SEL_27
#define MODEM_RX GPIO_SEL_26
#define LED_GPIO GPIO_SEL_13
#define LED_ON HIGH
#define LED_OFF LOW
void setupModem();
My project structure is as following:
https://ibb.co/zrRjpWZ
I have 2 questions:
1.I am including this header file in my main.c but for some reason I am not able to call this function as it is not recognised, and the error returned:
Code: Select all
C:\Users\petrikas.lu\Documents\PlatformIO\Projects\210715-150937-espidf-hello-world/src/hello_world_main.c:19: undefined reference to `setupModem'
2. Once I clean the projects, it takes insanely long time to build the project. Why is that? I have expected esp-idf to be much faster than Arduino platform projects but it is about 10 times slower compile times. Compiling simple hello world program took 105 seconds :
https://ibb.co/G0xPzXj