Skip to content

Release 2.0.1 #26

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

Merged
merged 11 commits into from
Nov 9, 2021
2 changes: 1 addition & 1 deletion .github/scripts/check-cmakelists.sh
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ git submodule update --init --recursive
REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`

# find all source files named in CMakeLists.txt COMPONENT_SRCS
CMAKE_SRCS=`cmake --trace-expand -C CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort`
CMAKE_SRCS=`cmake --trace-expand -P CMakeLists.txt 2>&1 | grep set\(srcs | cut -d'(' -f3 | sed 's/ )//' | sed 's/srcs //' | tr ' ;' '\n' | sort`

if ! diff -u0 --label "Repo Files" --label "srcs" <(echo "$REPO_SRCS") <(echo "$CMAKE_SRCS"); then
echo "Source files in repo (-) and source files in CMakeLists.txt (+) don't match"
Expand Down
24 changes: 24 additions & 0 deletions CMakeLists.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,27 @@
# Check ESP-IDF version and error out if it is not in the supported range.
#
# Note for arduino-esp32 developers: to bypass the version check locally,
# set ARDUINO_SKIP_IDF_VERSION_CHECK environment variable to 1. For example:
# export ARDUINO_SKIP_IDF_VERSION_CHECK=1
# idf.py build

set(min_supported_idf_version "4.4.0")
set(max_supported_idf_version "4.4.99")
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")

if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
if (idf_version VERSION_LESS min_supported_idf_version)
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
"but an older version is detected: ${idf_version}.")
endif()
if (idf_version VERSION_GREATER max_supported_idf_version)
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
"but a newer version is detected: ${idf_version}.")
endif()
endif()

set(CORE_SRCS
cores/esp32/base64.cpp
cores/esp32/cbuf.cpp
Expand Down
15 changes: 2 additions & 13 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,26 +1,15 @@
# Arduino core for the ESP32
# Arduino core for the ESP32, ESP32-S2 and ESP32-C3

[![Build Status](https://travis-ci.org/espressif/arduino-esp32.svg?branch=master)](https://travis-ci.org/espressif/arduino-esp32) ![](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![Documentation Status](https://readthedocs.com/projects/espressif-arduino-esp32/badge/?version=latest)](https://docs.espressif.com/projects/arduino-esp32/en/latest/?badge=latest)
![Build Status](https://github.com/espressif/arduino-esp32/workflows/ESP32%20Arduino%20CI/badge.svg) [![Documentation Status](https://readthedocs.com/projects/espressif-arduino-esp32/badge/?version=latest)](https://docs.espressif.com/projects/arduino-esp32/en/latest/?badge=latest)

### Need help or have a question? Join the chat at [![https://gitter.im/espressif/arduino-esp32](https://badges.gitter.im/espressif/arduino-esp32.svg)](https://gitter.im/espressif/arduino-esp32?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)

## Contents

- [ESP32-S2 and ESP32-C3 Support](#esp32-s2-and-esp32-c3-support)
- [Development Status](#development-status)
- [Decoding Exceptions](#decoding-exceptions)
- [Issue/Bug report template](#issuebug-report-template)

### ESP32-S2 and ESP32-C3 Support

If you want to test ESP32-S2 and/or ESP32-C3 through the board manager, please use the development release link:

```
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
```

Now you can install the latest 2.0.0 version from the boards manager.

### Development Status

Latest Stable Release [![Release Version](https://img.shields.io/github/release/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Release Date](https://img.shields.io/github/release-date/espressif/arduino-esp32.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/) [![Downloads](https://img.shields.io/github/downloads/espressif/arduino-esp32/latest/total.svg?style=plastic)](https://github.com/espressif/arduino-esp32/releases/latest/)
Expand Down
19 changes: 19 additions & 0 deletions cores/esp32/esp32-hal-ledc.c
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
#include "freertos/task.h"
#include "freertos/semphr.h"
#include "esp32-hal-matrix.h"
#include "soc/soc_caps.h"
#include "soc/ledc_reg.h"
#include "soc/ledc_struct.h"
#include "driver/periph_ctrl.h"
Expand Down Expand Up @@ -331,3 +332,21 @@ double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
return res_freq;
}

static int8_t pin_to_channel[SOC_GPIO_PIN_COUNT] = { 0 };
static int cnt_channel = SOC_LEDC_CHANNEL_NUM;
void analogWrite(uint8_t pin, int value) {
// Use ledc hardware for internal pins
if (pin < SOC_GPIO_PIN_COUNT) {
if (pin_to_channel[pin] == 0) {
if (!cnt_channel) {
log_e("No more analogWrite channels available! You can have maximum %u", SOC_LEDC_CHANNEL_NUM);
return;
}
pin_to_channel[pin] = cnt_channel--;
ledcAttachPin(pin, cnt_channel);
ledcSetup(cnt_channel, 1000, 8);
}
ledcWrite(pin_to_channel[pin] - 1, value);
}
}
2 changes: 2 additions & 0 deletions cores/esp32/esp32-hal.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,8 @@ void yield(void);
#include "esp32-hal-psram.h"
#include "esp32-hal-cpu.h"

void analogWrite(uint8_t pin, int value);

//returns chip temperature in Celsius
float temperatureRead();

Expand Down
3 changes: 1 addition & 2 deletions docs/source/esp-idf_component.rst
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,7 @@ For a simplified method, see `lib-builder <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).
Expand Down
102 changes: 61 additions & 41 deletions docs/source/libraries.rst
Original file line number Diff line number Diff line change
Expand Up @@ -7,49 +7,69 @@ Here is where the Libraries API's descriptions are located:
Supported Peripherals
---------------------

Currently, the Arduino ESP32 supports the following peripherals with Arduino style. Some other peripherals are not supported yet, but it's supported using ESP-IDF style.
Currently, the Arduino ESP32 supports the following peripherals with Arduino APIs.

+-------------+-------------+---------+--------------------+
| Peripheral | Arduino API | ESP-IDF | Comment |
+=============+=============+=========+====================+
| ADC | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| DAC | No | No | |
+-------------+-------------+---------+--------------------+
| GPIO | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| SDIO/SPI | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| I2C | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| I2S | No | Yes | In Development |
+-------------+-------------+---------+--------------------+
| Wi-Fi | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| Bluetooth | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| RMT | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| Touch | Yes | Yes | ESP32 & ESP32-S2 |
+-------------+-------------+---------+--------------------+
| Timer | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| UART | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| Hall Sensor | Yes | Yes | Only for ESP32 |
+-------------+-------------+---------+--------------------+
| LEDC | Yes | Yes | |
+-------------+-------------+---------+--------------------+
| Motor PWM | No | No | |
+-------------+-------------+---------+--------------------+
| TWAI | No | No | |
+-------------+-------------+---------+--------------------+
| Ethernet | Yes | Yes | Only for ESP32 |
+-------------+-------------+---------+--------------------+
| USB | Yes | Yes | Only for ESP32-S2 |
+-------------+-------------+---------+--------------------+
+---------------+---------------+---------------+---------------+-------------------------------+
| Peripheral | ESP32 | ESP32-S2 | ESP32-C3 | Comments |
+===============+===============+===============+===============+===============================+
| ADC | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Bluetooth | Yes | Not Supported | Not Supported | Bluetooth Classic |
+---------------+---------------+---------------+---------------+-------------------------------+
| BLE | Yes | Not Supported | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| DAC | Yes | Yes | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Ethernet | Yes | Not Supported | Not Supported | (*) |
+---------------+---------------+---------------+---------------+-------------------------------+
| GPIO | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Hall Sensor | Yes | Not Supported | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| I2C | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| I2S | No | No | No | WIP |
+---------------+---------------+---------------+---------------+-------------------------------+
| LEDC | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Motor PWM | No | Not Supported | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Pulse Counter | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| RMT | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| SDIO | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| SPI | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Timer | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Temp. Sensor | Not Supported | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| Touch | Yes | Yes | Not Supported | |
+---------------+---------------+---------------+---------------+-------------------------------+
| TWAI | No | No | No | |
+---------------+---------------+---------------+---------------+-------------------------------+
| UART | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+
| USB | Not Supported | Yes | Yes | ESP32-C3 only CDC/JTAG |
+---------------+---------------+---------------+---------------+-------------------------------+
| Wi-Fi | Yes | Yes | Yes | |
+---------------+---------------+---------------+---------------+-------------------------------+

Some peripherals are not available for all ESP32 families. To see more details about it, see the corresponding datasheet.
Notes
^^^^^

(*) SPI Ethernet is supported by all ESP32 families and RMII only for ESP32.

.. note:: Some peripherals are not available for all ESP32 families. To see more details about it, see the corresponding SoC at `Product Selector <https://products.espressif.com>`_ page.

Datasheet
^^^^^^^^^

* `ESP32 <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_
* `ESP32-S2 <https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf>`_
* `ESP32-C3 <https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf>`_

APIs
----
Expand Down
7 changes: 6 additions & 1 deletion libraries/Ethernet/src/ETH.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -368,6 +368,10 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
log_e("esp_eth_init error: %d", err);
}
#endif
// holds a few microseconds to let DHCP start and enter into a good state
// FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733
delay(50);

return true;
}

Expand Down Expand Up @@ -396,7 +400,8 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
if(err != ERR_OK){
log_e("STA IP could not be configured! Error: %d", err);
return false;
}
}

if(info.ip.addr){
staticIP = true;
} else {
Expand Down
20 changes: 14 additions & 6 deletions libraries/Wire/src/Wire.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -447,32 +447,40 @@ void TwoWire::flush(void)

uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop));
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), static_cast<bool>(sendStop));
}

uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity, uint8_t sendStop)
{
return requestFrom(address, static_cast<size_t>(quantity), static_cast<bool>(sendStop));
return requestFrom(address, static_cast<uint8_t>(quantity), static_cast<bool>(sendStop));
}

/* Added to match the Arduino function definition: https://github.com/arduino/ArduinoCore-API/blob/173e8eadced2ad32eeb93bcbd5c49f8d6a055ea6/api/HardwareI2C.h#L39
* See: https://github.com/arduino-libraries/ArduinoECCX08/issues/25
*/
size_t TwoWire::requestFrom(uint8_t address, size_t len, bool stopBit)
{
return requestFrom((uint16_t)address, (uint8_t)len, stopBit);
}

uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
}

uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity)
{
return requestFrom(address, static_cast<size_t>(quantity), true);
return requestFrom(address, static_cast<uint8_t>(quantity), true);
}

uint8_t TwoWire::requestFrom(int address, int quantity)
{
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
}

uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
{
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop)));
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), static_cast<bool>(sendStop)));
}

void TwoWire::beginTransmission(int address)
Expand Down
1 change: 1 addition & 0 deletions libraries/Wire/src/Wire.h
Original file line number Diff line number Diff line change
Expand Up @@ -95,6 +95,7 @@ class TwoWire: public Stream

uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
uint8_t requestFrom(uint16_t address, uint8_t size, uint8_t sendStop);
size_t requestFrom(uint8_t address, size_t len, bool stopBit);
uint8_t requestFrom(uint16_t address, uint8_t size);
uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
uint8_t requestFrom(uint8_t address, uint8_t size);
Expand Down
6 changes: 3 additions & 3 deletions package/package_esp32_index.template.json
Original file line number Diff line number Diff line change
Expand Up @@ -23,13 +23,13 @@
},
"boards": [
{
"name": "ESP32 Dev Module"
"name": "ESP32 Dev Board"
},
{
"name": "WEMOS LoLin32"
"name": "ESP32-S2 Dev Board"
},
{
"name": "WEMOS D1 MINI ESP32"
"name": "ESP32-C3 Dev Board"
}
],
"toolsDependencies": [
Expand Down
Loading