Prvni ulozeni z chegewara githubu

This commit is contained in:
2023-02-25 16:13:53 +01:00
commit 01eb80dfe2
3279 changed files with 638407 additions and 0 deletions

View File

@ -0,0 +1,38 @@
##################################
Compile Arduino libs with ESP_LOGx
##################################
There are 2 primary approaches and both of them involve editing file ``configs/defconfig.common``.
Edit the file directly and then build.
Later you can ``git restore configs/defconfig.common`` to go back.
Copy the file ``cp configs/defconfig.common configs/defconfig.debug`` and edit the debug version.
``vim configs/defconfig.common`` or ``vim configs/defconfig.debug``
Edit **line 44** containing by default ``CONFIG_LOG_DEFAULT_LEVEL_ERROR=y`` to one of the following lines depending on your desired log level:
.. code-block:: bash
CONFIG_LOG_DEFAULT_LEVEL_NONE=y # No output
CONFIG_LOG_DEFAULT_LEVEL_ERROR=y # Errors - default
CONFIG_LOG_DEFAULT_LEVEL_WARN=y # Warnings
CONFIG_LOG_DEFAULT_LEVEL_INFO=y # Info
CONFIG_LOG_DEFAULT_LEVEL_DEBUG=y # Debug
CONFIG_LOG_DEFAULT_LEVEL_VERBOSE=y # Verbose
Then simply build the libs for all SoCs or one specific SoC. Note that building for all SoCs takes a lot of time, so if you are working only with specific SoC(s), build only for those.
.. note::
If you have copied the ``defconfig`` file and the debug settings are in file ``configs/defconfig.debug`` add flag ``debug`` to compilation command.
Example : ``./build.sh debug``
- **Option 1**: Build for all SoCs: ``./build.sh``
- **Option 2**: Build for one SoC: ``./build.sh -t <soc>``. The exact text to choose the SoC:
- ``esp32``
- ``esp32s2``
- ``esp32c3``
- ``esp32s3``
- Example: ``./build.sh -t esp32``
- A wrong format or non-existing SoC will result in the error sed: can't read sdkconfig: No such file or directory

View File

@ -0,0 +1,334 @@
#####################################
Documentation Contribution Guidelines
#####################################
Introduction
------------
This is a guideline for the Arduino ESP32 project documentation. The idea for this guideline is to show how to start collaborating on the project.
The guideline works to give you the directions and to keep the documentation more concise, helping users to better understand the structure.
About Documentation
-------------------
We all know how important documentation is. This project is no different.
This documentation was created in a collaborative and open way, letting everyone contribute, from a small typo fix to a new chapter writing. We try to motivate our community by giving all the support needed through this guide.
The documentation is in **English only**. Future translations can be added when we finish the essential content in English first.
How to Collaborate
------------------
Everyone with some knowledge to share is welcome to collaborate.
One thing you need to consider is the fact that your contribution must be concise and assertive since it will be used by people developing projects. The information is very important for everyone, be sure you are not making the developer's life harder!
Documentation Guide
-------------------
This documentation is based on the `Sphinx`_ with `reStructuredText`_ and hosted by `ReadTheDocs`_.
If you want to get started with `Sphinx`_, see the official documentation:
* `Documentation Index <https://www.sphinx-doc.org/en/master/usage/restructuredtext/index.html>`_
* `Basics <https://www.sphinx-doc.org/en/master/usage/restructuredtext/basics.html>`_
* `Directives <https://www.sphinx-doc.org/en/master/usage/restructuredtext/directives.html>`_
First Steps
***********
Before starting your collaboration, you need to get the documentation source code from the Arduino-ESP32 project.
* **Step 1** - Fork the `Arduino-ESP32`_ to your GitHub account.
* **Step 2** - Check out the recently created fork.
* **Step 3** - Create a new branch for the changes/addition to the docs.
* **Step 4** - Write!
Requirements
************
To properly work with the documentation, you need to install some packages in your system.
.. code-block::
pip install -U Sphinx
pip install -r requirements.txt
The requirements file is under the ``docs`` folder.
Using Visual Studio Code
************************
If you are using the Visual Studio Code, you can install some extensions to help you while writing documentation.
`reStructuredText Pack <https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext-pack>`_
We also recommend you install to grammar check extension to help you to review English grammar.
`Grammarly <https://marketplace.visualstudio.com/items?itemName=znck.grammarly>`_
Building
********
To build the documentation and generate the HTLM files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the `build/html` folder.
.. code-block::
make html
This step is essential to ensure that there are no syntax errors and also to see the final result.
If everything is ok, you will see some output logs similar to this one:
.. code-block::
Running Sphinx v2.3.1
loading pickled environment... done
building [mo]: targets for 0 po files that are out of date
building [html]: targets for 35 source files that are out of date
updating environment: [extensions changed ('sphinx_tabs.tabs')] 41 added, 3 changed, 0 removed
reading sources... [100%] tutorials/tutorials
looking for now-outdated files... none found
pickling environment... done
checking consistency... done
preparing documents... done
writing output... [100%] tutorials/tutorials
generating indices... genindexdone
writing additional pages... searchdone
copying images... [100%] tutorials/../_static/tutorials/peripherals/tutorial_peripheral_diagram.png
copying static files... ... done
copying extra files... done
dumping search index in English (code: en)... done
dumping object inventory... done
build succeeded.
The HTML pages are in build/html.
Sections
--------
The Arduino ESP32 is structured in some sections to make it easier to maintain. Here is a brief description of this structure.
API
***
In this section, you will include all the documentation about drivers, libraries, and any other related to the core.
In this section, we do not add general information. For more general information, we have sections for other related parts, like the FAQ, library builder, troubleshooting, etc.
Boards
******
Here is the place to add any special guide on the development boards, pin layout, schematics, and any other relevant content.
Common
******
In this folder, you can add all common information used in several different places. This helps to make documentation easily maintainable.
Guides
******
This is the place to add the guides for common applications, IDEs configuration, and any other information that can be used as a guideline.
Tutorials
*********
If you want to add a specific tutorial related to the Arduino core for ESP32, this is the place. The intention is not to create a blog or a demo area, but this can be used to add some complex description or to add some more information about APIs.
Images and Assets
*****************
All the files used on the documentation must be stored in the ``_static`` folder. Be sure that the content used is not with any copyright restriction.
Documentation Rules
-------------------
Here are some guidelines to help you. We also recommend copying a sample file from the same category you are creating.
This will help you to follow the structure as well as to get inspired.
Basic Structure
***************
To help you create a new section from scratch, we recommend you include this structure in your content if it applies.
* **About** - Brief description of the document.
* Description of the peripheral, driver, protocol, including all different modes and configurations.
* **API** - Description of each public function, macros, and structs.
* **Basic Usage**
* **Example Application**
About Section
^^^^^^^^^^^^^
In this section, you need to add a brief description of the API. If you are describing a peripheral API, you should explain a little bit about the peripheral and the working modes, if it's applicable.
API Functions
^^^^^^^^^^^^^
To add a new function description, you must know that the users only have access to the public functions.
Here is an example of how to add the function description from `I2C API <https://docs.espressif.com/projects/arduino-esp32/en/latest/api/i2c.html>`_:
.. code-block::
setPins
^^^^^^^
This function is used to define the ``SDA`` and ``SCL`` pins.
.. note:: Call this function before ``begin`` to change the pins from the default ones.
.. code-block:: arduino
bool setPins(int sdaPin, int sclPin);
* ``sdaPin`` sets the GPIO to be used as the I2C peripheral data line.
* ``sclPin`` sets the GPIO to be used as the I2C peripheral clock line.
The default pins may vary from board to board. On the *Generic ESP32* the default I2C pins are:
* ``sdaPin`` **GPIO21**
* ``sclPin`` **GPIO22**
This function will return ``true`` if the peripheral was configured correctly.
Be sure to include a very comprehensive description, add all the parameters in and out, and describe the desired output.
If the function uses a specific structure, you can also describe the structure in the same function block or add a specific section if the structure is shared with other functions.
Basic Usage
^^^^^^^^^^^
Some APIs are more complex to use or require more steps in order to configure or initialize. If the API is not straightforward in terms of usability, please consider adding a how-to-use section describing all the steps to get the API configured.
Here is an example:
.. code-block::
Basic Usage
^^^^^^^^^^^
To start using I2C as slave mode on the Arduino, the first step is to include the ``Wire.h`` header to the sketch.
.. code-block:: arduino
#include "Wire.h"
Before calling ``begin``, you must create two callback functions to handle the communication with the master device.
.. code-block:: arduino
Wire.onReceive(onReceive);
and
.. code-block:: arduino
Wire.onRequest(onRequest);
The ``onReceive`` will handle the request from the ``master`` device upon a slave read request and the ``onRequest`` will handle the answer to the master.
Now, we can start the peripheral configuration by calling ``begin`` function with the device address.
.. code-block:: arduino
Wire.begin((uint8_t)I2C_DEV_ADDR);
By using ``begin`` without any arguments, all the settings will be done by using the default values. To set the values on your own, see the function description. This function is described here: `i2c begin`_
Example Application
^^^^^^^^^^^^^^^^^^^
It is very important to include at least one application example or a code snippet to help people using the API.
If the API does not have any application example, you can embed the code directly. However, if the example is available, you must include it as a literal block.
.. code-block::
.. literalinclude:: ../../../libraries/WiFi/examples/WiFiAccessPoint/WiFiAccessPoint.ino
:language: arduino
Sphinx Basics
-------------
Heading Levels
**************
The heading levels used on this documentation are:
* **H1**: - (Dash)
* **H2**: * (Asterisk)
* **H3**: ^ (Circumflex)
* **H4**: # (Sharp)
Code Block
**********
To add a code block, you can use the following structure:
.. code-block::
.. code-block:: arduino
bool begin(); //Code example
Links
*****
To include links to external content, you can use two ways.
* First option:
.. code-block::
`Arduino Wire Library`_
_Arduino Wire Library: https://www.arduino.cc/en/reference/wire
* Second option:
.. code-block::
`Arduino Wire Library <https://www.arduino.cc/en/reference/wire>`_
Images
******
To include images in the docs, first, add all the files into the ``_static`` folder with a filename that makes sense for the topic.
After that, you can use the following structure to include the image in the docs.
.. code-block::
.. figure:: ../_static/arduino_i2c_master.png
:align: center
:width: 720
:figclass: align-center
You can adjust the ``width`` according to the image size.
Be sure the file size does not exceed 600kB.
Support
*******
If you need support on the documentation, you can ask a question in the discussion `here <https://github.com/espressif/arduino-esp32/discussions>`_.
Additional Guidelines
---------------------
If you want to contribute with code on the Arduino ESP32 core, be sure to follow the `ESP-IDF Documenting Code <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/contribute/documenting-code.html>`_ as a reference.
.. _Arduino-ESP32: https://github.com/espressif/arduino-esp32
.. _Sphinx: https://www.sphinx-doc.org/en/master/
.. _ReadTheDocs: https://readthedocs.org/
.. _reStructuredText: https://docutils.sourceforge.io/rst.html

View File

@ -0,0 +1,10 @@
######
Guides
######
.. toctree::
:caption: Guides:
:maxdepth: 1
:glob:
*

View File

@ -0,0 +1,256 @@
######################
Arduino IDE Tools Menu
######################
Introduction
------------
This guide is a walkthrough of the Arduino IDE configuration menu for the ESP32 System on Chip (SoC's). In this guide, you will see the most relevant configuration
to get your project optimized and working.
Since some boards and SoC's may vary in terms of hardware configuration, be sure you know all the board characteristics that you are using, like flash memory size, SoC variant (ESP32 family), PSRAM, etc.
.. note:: To help you identify the characteristics, you can see the `Espressif Product Selector`_.
Arduino IDE
-----------
The Arduino IDE is widely used for ESP32 on Arduino development and offers a wide variety of configurations.
Tools Menu
----------
To properly configure your project build and flash, some settings must be done in order to get it compiled and flashed without any issues.
Some boards are natively supported and almost no configuration is required. However, if your is not yet supported or you have a custom board, you need to configure the environment by yourself.
For more details or to add a new board, see the `boards.txt`_ file.
Generic Options
---------------
Most of the options are available for every ESP32 family. Some options will be available only for specific targets, like the USB configuration.
Board
*****
This option is the target board and must be selected in order to get all the default configuration settings. Once you select the correct board, you will see that some configurations will be automatically selected, but be aware that some boards can have multiple versions (i.e different flash sizes).
To select the board, go to ``Tools -> Board -> ESP32 Arduino`` and select the target board.
If your board is not present on this list, you can select the generic ``ESP32-XX Dev Module``.
Currently, we have one generic development module for each of the supported targets.
If the board selected belongs to another SoC family, you will see the following information at the build output:
``A fatal error occurred: This chip is ESP32 not ESP32-S2. Wrong --chip argument?``
Upload Speed
************
To select the flashing speed, change the ``Tools -> Upload Speed``. This value will be used for flashing the code to the device.
.. note:: If you have issues while flashing the device at high speed, try to decrease this value. This could be due to the external serial-to-USB chip limitations.
CPU Frequency
*************
On this option, you can select the CPU clock frequency. This option is critical and must be selected according to the high-frequency crystal present on the board and the radio usage (Wi-Fi and Bluetooth).
In some applications, reducing the CPU clock frequency is recommended in order to reduce power consumption.
If you don't know why you should change this frequency, leave the default option.
Flash Frequency
***************
Use this function to select the flash memory frequency. The frequency will be dependent on the memory model.
* **40MHz**
* **80MHz**
If you don't know if your memory supports **80Mhz**, you can try to upload the sketch using the **80MHz** option and watch the log output via the serial monitor.
.. note:: In some boards/SoC, the flash frequency is automatically selected according to the flash mode. In some cases (i.e ESP32-S3), the flash frequency is up to 120MHz.
Flash Mode
**********
This option is used to select the SPI communication mode with the flash memory.
Depending on the application, this mode can be changed in order to increase the flash communication speed.
* **QIO** - Quad I/O Fast Read
* Four SPI pins are used to write to the flash and to read from the flash.
* **DIO** - Dual I/O Fast Read
* Two SPI pins are used to write to the flash and to read from the flash.
* **QOUT** - Quad Output Fast Read
* Four SPI pins are used to read the flash data.
* **DOUT** - Dual Output Fast Read
* Two SPI pins are used to read flash data.
* **OPI** - Octal I/O
* Eight SPI pins are used to write and to read from the flash.
If you don't know how the board flash is physically connected or the flash memory model, try the **QIO** at **80MHz** first.
Flash Size
**********
This option is used to select the flash size. The flash size should be selected according to the flash model used on your board.
* **2MB** (16Mb)
* **4MB** (32Mb)
* **8MB** (64Mb)
* **16MB** (128Mb)
If you choose the wrong size, you may have issues when selecting the partition scheme.
Embedded Flash
^^^^^^^^^^^^^^
Some SoC has embedded flash. The ESP32-S3 is a good example.
.. note:: Check the manufacturer part number of your SoC/module to see the right version.
Example: **ESP32-S3FH4R2**
This particular ESP32-S3 variant comes with 4MB Flash and 2MB PSRAM.
**Options for Embedded Flash**
* **Fx4** 4MB Flash (*QIO*)
* **Fx8** 8MB Flash (*QIO*)
* **V** 1.8V SPI
The **x** stands for the temperature range specification.
* **H** High Temperature (*-40 to 85ºC*)
* **N** Low Temeprature (*-40 to 65ºC*)
For more details, please see the corresponding datasheet at `Espressif Product Selector`_.
Partition Scheme
****************
This option is used to select the partition model according to the flash size and the resources needed, like storage area and OTA (Over The Air updates).
.. note:: Be careful selecting the right partition according to the flash size. If you select the wrong partition, the system will crash.
Core Debug Level
****************
This option is used to select the Arduino core debugging level to be printed to the serial debug.
* **None** - Prints nothing.
* **Error** - Only at error level.
* **Warning** - Only at warning level and above.
* **Info** - Only at info level and above.
* **Debug** - Only at debug level and above.
* **Verbose** - Prints everything.
PSRAM
*****
The PSRAM is an internal or external extended RAM present on some boards, modules or SoC.
This option can be used to ``Enable`` or ``Disable`` PSRAM. In some SoCs, you can select the PSRAM mode as the following.
* **QSPI PSRAM** - Quad PSRAM
* **OPI PSRAM** - Octal PSRAM
Embedded PSRAM
^^^^^^^^^^^^^^
Some SoC has embedded PSRAM. The ESP32-S3 is a good example.
Example: **ESP32-S3FH4R2**
This particular ESP32-S3 comes with 4MB Flash and 2MB PSRAM.
**Options for Embedded Flash and PSRAM**
* **R2** 2MB PSRAM (*QSPI*)
* **R8** 8MB PSRAM (*OPI*)
* **V** 1.8V SPI
The **x** stands for the temperature range specification.
* **H** High Temperature (*-40 to 85ºC*)
* **N** Low Temeprature (*-40 to 65ºC*)
For more details, please see the corresponding datasheet at `Espressif Product Selector`_.
Arduino Runs On
***************
This function is used to select the core that runs the Arduino core. This is only valid if the target SoC has 2 cores.
When you have some heavy task running, you might want to run this task on a different core than the Arduino tasks. For this reason, you have this configuration to select the right core.
Events Run On
*************
This function is also used to select the core that runs the Arduino events. This is only valid if the target SoC has 2 cores.
Erase All Flash Before Sketch Upload
************************************
This option selects the flash memory region to be erased before uploading the new sketch.
* **Disabled** - Upload the sketch without erasing all flash contents. (Default)
* **Enabled** - Erase all flash contents before uploading the sketch.
Port
****
This option is used to select the serial port to be used on the flashing and monitor.
USB Options
-----------
Some ESP32 families have a USB peripheral. This peripheral can be used for flashing and debugging.
To see the supported list for each SoC, see this section: `Libraries <../libraries.html>`_.
The USB option will be available only if the correct target is selected.
USB CDC On Boot
***************
The USB Communications Device Class, or USB CDC, is a class used for basic communication to be used as a regular serial controller (like RS-232).
This class is used for flashing the device without any other external device attached to the SoC.
This option can be used to ``Enable`` or ``Disable`` this function at the boot. If this option is ``Enabled``, once the device is connected via USB, one new serial port will appear in the list of the serial ports.
Use this new serial port for flashing the device.
This option can be used as well for debugging via the ``Serial Monitor`` using **CDC** instead of the **UART0**.
To use the UART as serial output, you can use ``Serial0.print("Hello World!");`` instead of ``Serial.print("Hello World!");`` which will be printed using USB CDC.
USB Firmware MSC On Boot
************************
The USB Mass Storage Class, or USB MSC, is a class used for storage devices, like a USB flash drive.
This option can be used to ``Enable`` or ``Disable`` this function at the boot. If this option is ``Enabled``, once the device is connected via USB, one new storage device will appear in the system as a storage drive.
Use this new storage drive to write and read files or to drop a new firmware binary to flash the device.
.. figure:: ../_static/usb_msc_drive.png
:align: center
:width: 720
:figclass: align-center
USB DFU On Boot
***************
The USB Device Firmware Upgrade is a class used for flashing the device through USB.
This option can be used to ``Enable`` or ``Disable`` this function at the boot. If this option is ``Enabled``, once the device is connected via USB, the device will appear as a USB DFU capable device.
.. _Espressif Product Selector: https://products.espressif.com/
.. _boards.txt: https://github.com/espressif/arduino-esp32/blob/master/boards.txt