Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[DOCS] Editing usage of Arduino as a component in ESP-IDF #5896

Merged
merged 3 commits into from
Nov 22, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 24 additions & 8 deletions docs/source/esp-idf_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,15 @@ Arduino as a ESP-IDF component
ESP32 Arduino lib-builder
-------------------------

For a simplified method, see `lib-builder <lib_builder>`_.
For a simplified method, see `lib-builder <https://github.com/espressif/esp32-arduino-lib-builder>`_.

Installation
------------

.. note:: Latest Arduino Core ESP32 version is now compatible with [ESP-IDF v4.4](https://github.com/espressif/esp-idf/tree/release/v4.4). Please consider this compability when using Arduino as component in ESP-IDF.
.. note:: Latest Arduino Core ESP32 version is now compatible with `ESP-IDF v4.4 <https://github.com/espressif/esp-idf/tree/release/v4.4>`_. Please consider this compability when using Arduino as component in ESP-IDF.

- Download and install `ESP-IDF <https://github.com/espressif/esp-idf>`_.
- Create blank idf project (from one of the examples).
- Create blank idf project (use sample_project from /examples/get-started) or choose one of the examples.
P-R-O-C-H-Y marked this conversation as resolved.
Show resolved Hide resolved
- In the project folder, create a new folder called `components` and clone this repository inside the new created folder.

.. code-block:: bash
Expand All @@ -26,10 +26,19 @@ Installation
cd ../.. && \
idf.py menuconfig

Option 1. Using Arduino setup() and loop()
******************************************

- The `idf.py menuconfig` has some Arduino options.
- On `Autostart Arduino setup and loop on boot`.
- If you enable these options, your main.cpp should be formated like any other sketch.
- Turn on `Autostart Arduino setup and loop on boot`.
- In main folder rename file `main.c` to `main.cpp`.
- In main folder open file `CMakeList.txt` and change `main.c` to `main.cpp` as described below.

.. code-block:: bash

idf_component_register(SRCS "main.cpp" INCLUDE_DIRS ".")

- Your main.cpp should be formated like any other sketch.

.. code-block:: c

Expand All @@ -45,14 +54,17 @@ Installation
delay(1000);
}

- Otherwise, you need to implement ```app_main()``` and call ```initArduino();``` in it.
Option 2. Using IDF appmain()
P-R-O-C-H-Y marked this conversation as resolved.
Show resolved Hide resolved
*****************************

- You need to implement ``app_main()`` and call ``initArduino();`` in it.

Keep in mind that setup() and loop() will not be called in this case.
If you plan to base your code on examples provided in `examples <https://github.com/espressif/esp-idf/tree/master/examples>`_, please make sure to move the app_main() function in main.cpp from the files in the example.

.. code-block:: cpp

//file: main.cpp
//file: main.c or main.cpp
#include "Arduino.h"

extern "C" void app_main()
Expand All @@ -69,7 +81,11 @@ If you plan to base your code on examples provided in `examples <https://github.
- If enabled, WiFi will start with the last known configuration
- Otherwise it will wait for WiFi.begin

- ```idf.py -p <your-board-serial-port> flash monitor``` will build, upload and open serial monitor to your board
Build, flash and monitor
************************

- For both options use command ``idf.py -p <your-board-serial-port> flash monitor``
- It will build, upload and open serial monitor to your board.

Logging To Serial
-----------------
Expand Down