Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/publishsizes.yml
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ jobs:
path: ./artifacts/sizes-report/pr_num.txt

- name: Report results
uses: P-R-O-C-H-Y/report-size-deltas@2043188c68f483a7b50527c4eacf609d05bb67a5 # sizes_v2
uses: P-R-O-C-H-Y/report-size-deltas@bea91d2c99ca80c88a883b39b1c4012f00ec3d09 # sizes_v2
with:
sketches-reports-source: ${{ env.SKETCHES_REPORTS_PATH }}
github-token: ${{ env.GITHUB_TOKEN }}
Expand Down
32 changes: 12 additions & 20 deletions cores/esp32/esp32-hal-spi.c
Original file line number Diff line number Diff line change
Expand Up @@ -79,16 +79,15 @@ struct spi_struct_t {

#if CONFIG_IDF_TARGET_ESP32S2
// ESP32S2
#define SPI_COUNT (3)
#define SPI_COUNT (2)

#define SPI_CLK_IDX(p) ((p == 0) ? SPICLK_OUT_MUX_IDX : ((p == 1) ? FSPICLK_OUT_MUX_IDX : ((p == 2) ? SPI3_CLK_OUT_MUX_IDX : 0)))
#define SPI_MISO_IDX(p) ((p == 0) ? SPIQ_OUT_IDX : ((p == 1) ? FSPIQ_OUT_IDX : ((p == 2) ? SPI3_Q_OUT_IDX : 0)))
#define SPI_MOSI_IDX(p) ((p == 0) ? SPID_IN_IDX : ((p == 1) ? FSPID_IN_IDX : ((p == 2) ? SPI3_D_IN_IDX : 0)))
#define SPI_CLK_IDX(p) ((p == 0) ? FSPICLK_OUT_MUX_IDX : ((p == 1) ? SPI3_CLK_OUT_MUX_IDX : 0))
#define SPI_MISO_IDX(p) ((p == 0) ? FSPIQ_OUT_IDX : ((p == 1) ? SPI3_Q_OUT_IDX : 0))
#define SPI_MOSI_IDX(p) ((p == 0) ? FSPID_IN_IDX : ((p == 1) ? SPI3_D_IN_IDX : 0))

#define SPI_SPI_SS_IDX(n) ((n == 0) ? SPICS0_OUT_IDX : ((n == 1) ? SPICS1_OUT_IDX : 0))
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : SPI3_CS0_OUT_IDX)))
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : FSPICS0_OUT_IDX)))
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_SPI_SS_IDX(n) : ((p == 1) ? SPI_SPI_SS_IDX(n) : ((p == 2) ? SPI_HSPI_SS_IDX(n) : 0)))
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : 0)))
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : 0)))
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))

#elif CONFIG_IDF_TARGET_ESP32S3
// ESP32S3
Expand All @@ -98,8 +97,8 @@ struct spi_struct_t {
#define SPI_MISO_IDX(p) ((p == 0) ? FSPIQ_OUT_IDX : ((p == 1) ? SPI3_Q_OUT_IDX : 0))
#define SPI_MOSI_IDX(p) ((p == 0) ? FSPID_IN_IDX : ((p == 1) ? SPI3_D_IN_IDX : 0))

#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : 0))
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : 0))
#define SPI_HSPI_SS_IDX(n) ((n == 0) ? SPI3_CS0_OUT_IDX : ((n == 1) ? SPI3_CS1_OUT_IDX : ((n == 2) ? SPI3_CS2_OUT_IDX : 0)))
#define SPI_FSPI_SS_IDX(n) ((n == 0) ? FSPICS0_OUT_IDX : ((n == 1) ? FSPICS1_OUT_IDX : ((n == 2) ? FSPICS2_OUT_IDX : 0)))
#define SPI_SS_IDX(p, n) ((p == 0) ? SPI_FSPI_SS_IDX(n) : ((p == 1) ? SPI_HSPI_SS_IDX(n) : 0))

#elif CONFIG_IDF_TARGET_ESP32P4
Expand Down Expand Up @@ -151,11 +150,7 @@ struct spi_struct_t {
#define SPI_MUTEX_UNLOCK()
// clang-format off
static spi_t _spi_bus_array[] = {
#if CONFIG_IDF_TARGET_ESP32S2
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 1, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 2, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
#if CONFIG_IDF_TARGET_ESP32S2 ||CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), 1, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C2
Expand All @@ -179,11 +174,7 @@ static spi_t _spi_bus_array[] = {
#define SPI_MUTEX_UNLOCK() xSemaphoreGive(spi->lock)

static spi_t _spi_bus_array[] = {
#if CONFIG_IDF_TARGET_ESP32S2
{(volatile spi_dev_t *)(DR_REG_SPI1_BASE), NULL, 0, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 1, -1, -1, -1, -1, false},
{(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 2, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
#if CONFIG_IDF_TARGET_ESP32S2 || CONFIG_IDF_TARGET_ESP32S3 || CONFIG_IDF_TARGET_ESP32P4
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}, {(volatile spi_dev_t *)(DR_REG_SPI3_BASE), NULL, 1, -1, -1, -1, -1, false}
#elif CONFIG_IDF_TARGET_ESP32C2
{(volatile spi_dev_t *)(DR_REG_SPI2_BASE), NULL, 0, -1, -1, -1, -1, false}
Expand Down Expand Up @@ -621,6 +612,7 @@ void spiStopBus(spi_t *spi) {

spi_t *spiStartBus(uint8_t spi_num, uint32_t clockDiv, uint8_t dataMode, uint8_t bitOrder) {
if (spi_num >= SPI_COUNT) {
log_e("SPI bus index %d is out of range", spi_num);
return NULL;
}

Expand Down
12 changes: 3 additions & 9 deletions cores/esp32/esp32-hal-spi.h
Original file line number Diff line number Diff line change
Expand Up @@ -27,19 +27,13 @@ extern "C" {
#include <stdbool.h>

#define SPI_HAS_TRANSACTION

#ifdef CONFIG_IDF_TARGET_ESP32S2
#define FSPI 1 //SPI 1 bus. ESP32S2: for external memory only (can use the same data lines but different SS)
#define HSPI 2 //SPI 2 bus. ESP32S2: external memory or device - it can be matrixed to any pins
#define SPI2 2 // Another name for ESP32S2 SPI 2
#define SPI3 3 //SPI 3 bus. ESP32S2: device only - it can be matrixed to any pins
#elif CONFIG_IDF_TARGET_ESP32
#ifdef CONFIG_IDF_TARGET_ESP32
#define FSPI 1 //SPI 1 bus attached to the flash (can use the same data lines but different SS)
#define HSPI 2 //SPI 2 bus normally mapped to pins 12 - 15, but can be matrixed to any pins
#define VSPI 3 //SPI 3 bus normally attached to pins 5, 18, 19 and 23, but can be matrixed to any pins
#else
#define FSPI 0 // ESP32C2, C3, C6, H2, S3, P4 - SPI 2 bus
#define HSPI 1 // ESP32S3, P4 - SPI 3 bus
#define FSPI 0 // ESP32C2, C3, C6, H2, S2, S3, P4 - SPI 2 bus
#define HSPI 1 // ESP32S2, S3, P4 - SPI 3 bus
#endif

// This defines are not representing the real Divider of the ESP32
Expand Down
7 changes: 7 additions & 0 deletions docs/conf_common.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,12 @@

from esp_docs.conf_docs import * # noqa: F403,F401

# Used for substituting variables in the documentation
rst_prolog = """
.. |version| replace:: 3.2.0
.. |idf_version| replace:: 5.4
"""

languages = ["en"]

# idf_targets = [
Expand All @@ -27,6 +33,7 @@
extensions += [ # noqa: F405
"sphinx_copybutton",
"sphinx_tabs.tabs",
"sphinx_substitution_extensions", # For allowing substitutions inside code blocks
"esp_docs.esp_extensions.dummy_build_system",
]

Expand Down
4 changes: 2 additions & 2 deletions docs/en/contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,7 @@ Documentation
-------------

If you are contributing to the documentation, please follow the instructions described in the
`documentation guidelines <guides/docs_contributing>`_ to properly format and test your changes.
`documentation guidelines <guides/docs_contributing.html>`_ to properly format and test your changes.

Testing and CI
--------------
Expand Down Expand Up @@ -435,7 +435,7 @@ Documentation Checks
^^^^^^^^^^^^^^^^^^^^

The CI also checks the documentation for any compilation errors. This is important to ensure that the documentation layout is not broken.
To build the documentation locally, please refer to the `documentation guidelines <guides/docs_contributing>`_.
To build the documentation locally, please refer to the `documentation guidelines <guides/docs_contributing.html>`_.

Code Style Checks
^^^^^^^^^^^^^^^^^
Expand Down
10 changes: 6 additions & 4 deletions docs/en/esp-idf_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -14,9 +14,9 @@ For a simplified method, see `Installing using Boards Manager <https://docs.espr
If you plan to use these modified settings multiple times, for different projects and targets, you can recompile the Arduino core with the new settings using the Arduino Static Library Builder.
For more information, see the `Lib Builder documentation <lib_builder.html>`_.

.. note:: Latest Arduino Core ESP32 version (3.0.X) is now compatible with `ESP-IDF v5.1 <https://github.com/espressif/esp-idf/tree/release/v5.1>`_. Please consider this compatibility when using Arduino as a component in ESP-IDF.
.. note:: Latest Arduino Core ESP32 version (|version|) is now compatible with ESP-IDF v\ |idf_version|\ . Please consider this compatibility when using Arduino as a component in ESP-IDF.

For easiest use of Arduino framework as a ESP-IDF component, you can use the `IDF Component Manager <https://docs.espressif.com/projects/esp-idf/en/v5.1.4/esp32/api-guides/tools/idf-component-manager.html>`_ to add the Arduino component to your project.
For easiest use of Arduino framework as a ESP-IDF component, you can use the `IDF Component Manager <https://docs.espressif.com/projects/esp-idf/en/latest/esp32/api-guides/tools/idf-component-manager.html>`_ to add the Arduino component to your project.
This will automatically clone the repository and its submodules. You can find the Arduino component in the `ESP Registry <https://components.espressif.com/components/espressif/arduino-esp32>`_ together with dependencies list and examples.

Installation
Expand All @@ -32,14 +32,16 @@ Installing using IDF Component Manager
To add the Arduino component to your project using the IDF Component Manager, run the following command in your project directory:

.. code-block:: bash
:substitutions:

idf.py add-dependency "espressif/arduino-esp32^3.0.2"
idf.py add-dependency "espressif/arduino-esp32^|version|"

Or you can start a new project from a template with the Arduino component:

.. code-block:: bash
:substitutions:

idf.py create-project-from-example "espressif/arduino-esp32^3.0.2:hello_world"
idf.py create-project-from-example "espressif/arduino-esp32^|version|:hello_world"

Manual installation of Arduino framework
****************************************
Expand Down
13 changes: 5 additions & 8 deletions docs/en/guides/docs_contributing.rst
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ Before starting your collaboration, you need to get the documentation source cod
Requirements
************

To properly work with the documentation, you need to install some packages in your system.
To build the documentation properly, you need to install some packages in your system. Note that depending on
your system, you may need to use a virtual environment to install the packages.

.. code-block::

pip install -U Sphinx
pip install -r requirements.txt

The requirements file is under the ``docs`` folder.
Expand All @@ -62,17 +62,14 @@ Using Visual Studio Code
************************

If you are using the Visual Studio Code, you can install some extensions to help you while writing documentation.
For reStructuredText, you can install the `reStructuredText Pack <https://marketplace.visualstudio.com/items?itemName=lextudio.restructuredtext-pack>`_ extension.

`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>`_
We also recommend you to install some grammar check extension to help you to review English grammar.

Building
********

To build the documentation and generate the HTML files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the `_build/en/generic/html` folder.
To build the documentation and generate the HTML files, you can use the following command inside the ``docs`` folder. After a successful build, you can check the files inside the ``_build/en/generic/html`` folder.

.. code-block::

Expand Down
1 change: 1 addition & 0 deletions docs/en/index.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ Welcome to ESP32 Arduino Core's documentation
#############################################

Here you will find all the relevant information about the project.
This documentation is valid for the Arduino Core for ESP32 version |version| based on ESP-IDF |idf_version|.

.. note::
This is a work in progress documentation and we will appreciate your help! We are looking for contributors!
Expand Down
16 changes: 10 additions & 6 deletions docs/en/lib_builder.rst
Original file line number Diff line number Diff line change
Expand Up @@ -293,8 +293,9 @@ You have two options to run the Docker image to build the libraries. Manually or
To run the Docker image manually, use the following command from the root of the ``arduino-esp32`` repository:

.. code-block:: bash
:substitutions:

docker run --rm -it -v $PWD:/arduino-esp32 -e TERM=xterm-256color espressif/esp32-arduino-lib-builder:release-v5.1
docker run --rm -it -v $PWD:/arduino-esp32 -e TERM=xterm-256color espressif/esp32-arduino-lib-builder:release-v|idf_version|

This will start the Lib Builder UI for compiling the libraries. The above command explained:

Expand All @@ -304,7 +305,7 @@ This will start the Lib Builder UI for compiling the libraries. The above comman
- ``-t`` Allocate a pseudo-TTY;
- ``-e TERM=xterm-256color``: Optional. Sets the terminal type to ``xterm-256color`` to display colors correctly;
- ``-v $PWD:/arduino-esp32``: Optional. Mounts the current folder at ``/arduino-esp32`` inside the container. If not provided, the container will not copy the compiled libraries to the host machine;
- ``espressif/esp32-arduino-lib-builder:release-v5.1``: uses Docker image ``espressif/esp32-arduino-lib-builder`` with tag ``release-v5.1``.
- :substitution-code:`espressif/esp32-arduino-lib-builder:release-v|idf_version|`: uses Docker image ``espressif/esp32-arduino-lib-builder`` with tag :substitution-code:`release-v|idf_version|`.
The ``latest`` tag is implicitly added by Docker when no tag is specified. It is recommended to use a specific version tag to ensure reproducibility of the build process.

.. warning::
Expand All @@ -324,24 +325,27 @@ By default the docker container will run the user interface script. If you want
For example, to run a terminal inside the container, you can run:

.. code-block:: bash
:substitutions:

docker run -it espressif/esp32-arduino-lib-builder:release-v5.1 /bin/bash
docker run -it espressif/esp32-arduino-lib-builder:release-v|idf_version| /bin/bash

Running the Docker image using the provided run script will depend on the host OS.
Use the following command from the root of the ``arduino-esp32`` repository to execute the image in a Linux or macOS environment for
the ``release-v5.1`` tag:
the :substitution-code:`release-v|idf_version|` tag:

.. code-block:: bash
:substitutions:

curl -LJO https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v5.1/tools/docker/run.sh
curl -LJO https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v|idf_version|/tools/docker/run.sh
chmod +x run.sh
./run.sh $PWD

For Windows, use the following command in PowerShell from the root of the ``arduino-esp32`` repository:

.. code-block:: powershell
:substitutions:

Invoke-WebRequest -Uri "https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v5.1/tools/docker/run.ps1" -OutFile "run.ps1"
Invoke-WebRequest -Uri "https://raw.githubusercontent.com/espressif/esp32-arduino-lib-builder/refs/heads/release/v|idf_version|/tools/docker/run.ps1" -OutFile "run.ps1"
.\run.ps1 $pwd

As the script is unsigned, you may need to change the execution policy of the current session before running the script.
Expand Down
2 changes: 2 additions & 0 deletions docs/requirements.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
sphinx==4.5.0
esp-docs>=1.4.0
sphinx-copybutton==0.5.0
sphinx-tabs==3.2.0
numpydoc==1.5.0
standard-imghdr==3.13.0
Sphinx-Substitution-Extensions==2022.2.16
4 changes: 3 additions & 1 deletion libraries/SD/src/SD.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,9 @@ bool SDFS::begin(uint8_t ssPin, SPIClass &spi, uint32_t frequency, const char *m
return true;
}

spi.begin();
if (!spi.begin()) {
return false;
}

_pdrv = sdcard_init(ssPin, &spi, frequency);
if (_pdrv == 0xFF) {
Expand Down
1 change: 1 addition & 0 deletions libraries/SPI/src/SPI.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -74,6 +74,7 @@ bool SPIClass::begin(int8_t sck, int8_t miso, int8_t mosi, int8_t ss) {

_spi = spiStartBus(_spi_num, _div, SPI_MODE0, SPI_MSBFIRST);
if (!_spi) {
log_e("SPI bus %d start failed.", _spi_num);
return false;
}

Expand Down
12 changes: 11 additions & 1 deletion libraries/WiFi/src/WiFiGeneric.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -252,13 +252,23 @@ static bool wifiHostedInit() {
if (!hosted_initialized) {
hosted_initialized = true;
struct esp_hosted_sdio_config conf = INIT_DEFAULT_HOST_SDIO_CONFIG();
#ifdef BOARD_HAS_SDIO_ESP_HOSTED
conf.pin_clk.pin = BOARD_SDIO_ESP_HOSTED_CLK;
conf.pin_cmd.pin = BOARD_SDIO_ESP_HOSTED_CMD;
conf.pin_d0.pin = BOARD_SDIO_ESP_HOSTED_D0;
conf.pin_d1.pin = BOARD_SDIO_ESP_HOSTED_D1;
conf.pin_d2.pin = BOARD_SDIO_ESP_HOSTED_D2;
conf.pin_d3.pin = BOARD_SDIO_ESP_HOSTED_D3;
conf.pin_reset.pin = BOARD_SDIO_ESP_HOSTED_RESET;
#else
conf.pin_clk.pin = CONFIG_ESP_SDIO_PIN_CLK;
conf.pin_cmd.pin = CONFIG_ESP_SDIO_PIN_CMD;
conf.pin_d0.pin = CONFIG_ESP_SDIO_PIN_D0;
conf.pin_d1.pin = CONFIG_ESP_SDIO_PIN_D1;
conf.pin_d2.pin = CONFIG_ESP_SDIO_PIN_D2;
conf.pin_d3.pin = CONFIG_ESP_SDIO_PIN_D3;
//conf.pin_rst.pin = CONFIG_ESP_SDIO_GPIO_RESET_SLAVE;
conf.pin_reset.pin = CONFIG_ESP_SDIO_GPIO_RESET_SLAVE;
#endif
// esp_hosted_sdio_set_config() will fail on second attempt but here temporarily to not cause exception on reinit
if (esp_hosted_sdio_set_config(&conf) != ESP_OK || esp_hosted_init() != ESP_OK) {
log_e("esp_hosted_init failed!");
Expand Down
Loading