Questions about libraries
-
- Posts: 1
- Joined: Sat Dec 23, 2017 6:18 am
Questions about libraries
I'm a newbie in programming embedded systems, therefore I have so many questions . When I opened the codes examples code from from GitHub (e.g. Hello World)(I'm using PlatformIO Atom), I saw many #includes that I don't understand why they are there, like: #include <stdio.h>
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "nvs_flash.h"
this example is for the hello world. Then, there is any pdf archive or list of the all ESP32 libraries, how they works and when I have to use them ?
I'm so sorry for the english, I'm learning english too.
#include "freertos/FreeRTOS.h"
#include "freertos/task.h"
#include "esp_system.h"
#include "nvs_flash.h"
this example is for the hello world. Then, there is any pdf archive or list of the all ESP32 libraries, how they works and when I have to use them ?
I'm so sorry for the english, I'm learning english too.
Re: Questions about libraries
When you want to call logic (functions) that aren't defined in your own application, you typically perform a #include which brings in the contents of the named file as though it existed within your own code. This included material includes such things as the declarations of functions that you can then call.
You would not include a header file if you weren't planning on calling the functions contained within.
Typically if you don't include a needed header file you will be told there is a problem at compile time and with some experience, you will start to recognize the errors as having missed include files.
The documentation for the ESP-IDF APIs can be found here:
http://esp-idf.readthedocs.io/en/latest/
Take a look at this one for example:
http://esp-idf.readthedocs.io/en/latest ... flash.html
As you become familiar with reading such documentation you will find that it names the header file you have to include:
http://esp-idf.readthedocs.io/en/latest ... eader-file
along with the functions and constants defined within.
You would not include a header file if you weren't planning on calling the functions contained within.
Typically if you don't include a needed header file you will be told there is a problem at compile time and with some experience, you will start to recognize the errors as having missed include files.
The documentation for the ESP-IDF APIs can be found here:
http://esp-idf.readthedocs.io/en/latest/
Take a look at this one for example:
http://esp-idf.readthedocs.io/en/latest ... flash.html
As you become familiar with reading such documentation you will find that it names the header file you have to include:
http://esp-idf.readthedocs.io/en/latest ... eader-file
along with the functions and constants defined within.
Free book on ESP32 available here: https://leanpub.com/kolban-ESP32
Re: Questions about libraries
Hello guys,
I have a some how the similar question:
In my understanderation in "*.h" files there are most of the time only "function prototypes" and "variable definitions". The real definitions of functions and declaration&initializations of variables are actually happend in "*.c" files. During the walk through of precompiler, all "#include <*.h>" will be replaced by the content of this header file. Say at last this would be a HUGE single file of nearlly all the source codes in it.
But how the "*.c" file get linked-in during this compile time?
Does that mean no matter I did or do not use the code in a "*.c" (which exist in my project directory), all the "*.c" will get compiled to its "*.o" version (Just like the ESP-IDF did for the first build) and later get "merged" (or just is appended to the end of the HUGE file)?
I have a some how the similar question:
In my understanderation in "*.h" files there are most of the time only "function prototypes" and "variable definitions". The real definitions of functions and declaration&initializations of variables are actually happend in "*.c" files. During the walk through of precompiler, all "#include <*.h>" will be replaced by the content of this header file. Say at last this would be a HUGE single file of nearlly all the source codes in it.
But how the "*.c" file get linked-in during this compile time?
Does that mean no matter I did or do not use the code in a "*.c" (which exist in my project directory), all the "*.c" will get compiled to its "*.o" version (Just like the ESP-IDF did for the first build) and later get "merged" (or just is appended to the end of the HUGE file)?
Re: Questions about libraries
I declare all the libraries I can use someday, so visual studio will always have the functions in Auto-Complete. This is very good because the libraries are only compiled into the code when using any, so declare them all and do not use them, it does not interfere with the final size of the file.
Caution: Flood libraries
Note: You need to change directory of ESP-IDF/Components if necessary.
Note 2: Here is probably all the files we will be using for a long time, including most of the core registry and library (IDF-API Reference) settings.
Caution: Flood libraries
Note: You need to change directory of ESP-IDF/Components if necessary.
Note 2: Here is probably all the files we will be using for a long time, including most of the core registry and library (IDF-API Reference) settings.
Code: Select all
//REG libraries
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/apb_ctrl_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/efuse_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/dport_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/gpio_sd_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/emac_ex_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/emac_reg_v2.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/frc_timer_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/gpio_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/mcpwm_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/hwcrypto_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/i2c_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/io_mux_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/ledc_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/rmt_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/pcnt_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/rtc_cntl_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/rtc_io_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/sdmmc_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/sens_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/spi_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/timer_group_reg.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/uart_reg.h>
//Arduino libraries
#include <C:/msys32/ESP32/ESP32/components/arduino/cores/esp32/Arduino.h>
#include <C:/msys32/ESP32/ESP32/components/arduino/libraries/WiFi/src/WiFi.h>
#include <C:/msys32/ESP32/ESP32/components/arduino/libraries/WiFi/src/WiFiClient.h>
#include <C:/msys32/ESP32/ESP32/components/arduino/libraries/WiFiClientSecure/src/WiFiClientSecure.h>
//IDF libraries
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_wifi.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/adc.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/dac.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/gpio.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/rtc_io.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/i2c.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/i2s.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/ledc.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/mcpwm.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/pcnt.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/rmt.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/sigmadelta.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/spi_common.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/spi_slave.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/timer.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/touch_pad.h>
#include <C:/msys32/ESP32/esp-idf/components/driver/include/driver/uart.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_wifi.h>
#include <C:/msys32/ESP32/esp-idf/components/nvs_flash/include/nvs_flash.h>
#include <C:/msys32/ESP32/esp-idf/components/vfs/include/esp_vfs.h>
#include <C:/msys32/ESP32/esp-idf/components/fatfs/src/esp_vfs_fat.h>
#include <C:/msys32/ESP32/esp-idf/components/spiffs/include/esp_spiffs.h>
#include <C:/msys32/ESP32/esp-idf/components/freertos/include/freertos/task.h>
#include <C:/msys32/ESP32/esp-idf/components/freertos/include/freertos/FreeRTOS.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_intr_alloc.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_task_wdt.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_int_wdt.h>
#include <C:/msys32/ESP32/esp-idf/components/app_update/include/esp_ota_ops.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_system.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/rom/rtc.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/soc.h>
#include <C:/msys32/ESP32/esp-idf/components/soc/esp32/include/soc/rtc.h>
#include <C:/msys32/ESP32/esp-idf/components/esp32/include/esp_attr.h>
#include <C:/msys32/ESP32/esp-idf/components/mbedtls/include/mbedtls/bignum.h>
#include <C:/msys32/ESP32/esp-idf/components/ulp/ulp.c>
Re: Questions about libraries
https://www.lurklurk.org/linkers/linkers.html#ccompilerGfast2 wrote: But how the "*.c" file get linked-in during this compile time?
Re: Questions about libraries
Hi WiFive,WiFive wrote:https://www.lurklurk.org/linkers/linkers.html#ccompilerGfast2 wrote: But how the "*.c" file get linked-in during this compile time?
This one is pretty neat! I've learned really TONS of things from there! Now I got another (meaningless) question:
Since command "nm" can list all contents in *.o file with their original name appeared in its source code respectively. Is that means if I decided to use very long names for those variables and functions in the *.o to "describe" what are in do, I have to live with a larger "*.o" or "*.bin" only for this?
Re: Questions about libraries
Hi WiFive,
Another awesome knowledge o file for "myBrain.elf" You are my linker!
But, I have another two extra questions:
1. How to fine tune these compiler flags in esp-idf. I know there are some simple ones can be found in make menuconfig. But how to add these "finer ones"
2. I understand gcc for different plattform is near identical. But for example for the bugs in rev.0 of esp32, man invent compiler flag to work around. Does some doc out there list all available flags for the esp32?
Cheers
Gfast2
Re: Questions about libraries
Hi WiFive,
For different reasons, I've read that page +3 times. It looks like I still not picked up all what I should in "myBrain.elf"
Nice feeling. I really appreciate & enjoy your awesome jobs!!!
Cheers
Gfast2
Who is online
Users browsing this forum: Google [Bot] and 121 guests