Skip to content

Commit 4337295

Browse files
authored
Merge pull request #26 from espressif/master
Release 2.0.1
2 parents cae60af + b94b38c commit 4337295

15 files changed

+144
-74
lines changed

.github/scripts/check-cmakelists.sh

+1-1
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@ git submodule update --init --recursive
1515
REPO_SRCS=`find cores/esp32/ libraries/ -name 'examples' -prune -o -name '*.c' -print -o -name '*.cpp' -print | sort`
1616

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

2020
if ! diff -u0 --label "Repo Files" --label "srcs" <(echo "$REPO_SRCS") <(echo "$CMAKE_SRCS"); then
2121
echo "Source files in repo (-) and source files in CMakeLists.txt (+) don't match"

CMakeLists.txt

+24
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
1+
# Check ESP-IDF version and error out if it is not in the supported range.
2+
#
3+
# Note for arduino-esp32 developers: to bypass the version check locally,
4+
# set ARDUINO_SKIP_IDF_VERSION_CHECK environment variable to 1. For example:
5+
# export ARDUINO_SKIP_IDF_VERSION_CHECK=1
6+
# idf.py build
7+
8+
set(min_supported_idf_version "4.4.0")
9+
set(max_supported_idf_version "4.4.99")
10+
set(idf_version "${IDF_VERSION_MAJOR}.${IDF_VERSION_MINOR}.${IDF_VERSION_PATCH}")
11+
12+
if ("${idf_version}" AND NOT "$ENV{ARDUINO_SKIP_IDF_VERSION_CHECK}")
13+
if (idf_version VERSION_LESS min_supported_idf_version)
14+
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
15+
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
16+
"but an older version is detected: ${idf_version}.")
17+
endif()
18+
if (idf_version VERSION_GREATER max_supported_idf_version)
19+
message(FATAL_ERROR "Arduino-esp32 can be used with ESP-IDF versions "
20+
"between ${min_supported_idf_version} and ${max_supported_idf_version}, "
21+
"but a newer version is detected: ${idf_version}.")
22+
endif()
23+
endif()
24+
125
set(CORE_SRCS
226
cores/esp32/base64.cpp
327
cores/esp32/cbuf.cpp

README.md

+2-13
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,15 @@
1-
# Arduino core for the ESP32
1+
# Arduino core for the ESP32, ESP32-S2 and ESP32-C3
22

3-
[![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)
3+
![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)
44

55
### 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)
66

77
## Contents
88

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

14-
### ESP32-S2 and ESP32-C3 Support
15-
16-
If you want to test ESP32-S2 and/or ESP32-C3 through the board manager, please use the development release link:
17-
18-
```
19-
https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_dev_index.json
20-
```
21-
22-
Now you can install the latest 2.0.0 version from the boards manager.
23-
2413
### Development Status
2514

2615
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/)

cores/esp32/esp32-hal-ledc.c

+19
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@
1717
#include "freertos/task.h"
1818
#include "freertos/semphr.h"
1919
#include "esp32-hal-matrix.h"
20+
#include "soc/soc_caps.h"
2021
#include "soc/ledc_reg.h"
2122
#include "soc/ledc_struct.h"
2223
#include "driver/periph_ctrl.h"
@@ -331,3 +332,21 @@ double ledcChangeFrequency(uint8_t chan, double freq, uint8_t bit_num)
331332
double res_freq = _ledcSetupTimerFreq(chan, freq, bit_num);
332333
return res_freq;
333334
}
335+
336+
static int8_t pin_to_channel[SOC_GPIO_PIN_COUNT] = { 0 };
337+
static int cnt_channel = SOC_LEDC_CHANNEL_NUM;
338+
void analogWrite(uint8_t pin, int value) {
339+
// Use ledc hardware for internal pins
340+
if (pin < SOC_GPIO_PIN_COUNT) {
341+
if (pin_to_channel[pin] == 0) {
342+
if (!cnt_channel) {
343+
log_e("No more analogWrite channels available! You can have maximum %u", SOC_LEDC_CHANNEL_NUM);
344+
return;
345+
}
346+
pin_to_channel[pin] = cnt_channel--;
347+
ledcAttachPin(pin, cnt_channel);
348+
ledcSetup(cnt_channel, 1000, 8);
349+
}
350+
ledcWrite(pin_to_channel[pin] - 1, value);
351+
}
352+
}

cores/esp32/esp32-hal.h

+2
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,8 @@ void yield(void);
9090
#include "esp32-hal-psram.h"
9191
#include "esp32-hal-cpu.h"
9292

93+
void analogWrite(uint8_t pin, int value);
94+
9395
//returns chip temperature in Celsius
9496
float temperatureRead();
9597

docs/source/esp-idf_component.rst

+1-2
Original file line numberDiff line numberDiff line change
@@ -10,8 +10,7 @@ For a simplified method, see `lib-builder <lib_builder>`_.
1010
Installation
1111
------------
1212

13-
.. note::
14-
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.
13+
.. 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.
1514

1615
- Download and install `ESP-IDF <https://github.com/espressif/esp-idf>`_.
1716
- Create blank idf project (from one of the examples).

docs/source/libraries.rst

+61-41
Original file line numberDiff line numberDiff line change
@@ -7,49 +7,69 @@ Here is where the Libraries API's descriptions are located:
77
Supported Peripherals
88
---------------------
99

10-
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.
10+
Currently, the Arduino ESP32 supports the following peripherals with Arduino APIs.
1111

12-
+-------------+-------------+---------+--------------------+
13-
| Peripheral | Arduino API | ESP-IDF | Comment |
14-
+=============+=============+=========+====================+
15-
| ADC | Yes | Yes | |
16-
+-------------+-------------+---------+--------------------+
17-
| DAC | No | No | |
18-
+-------------+-------------+---------+--------------------+
19-
| GPIO | Yes | Yes | |
20-
+-------------+-------------+---------+--------------------+
21-
| SDIO/SPI | Yes | Yes | |
22-
+-------------+-------------+---------+--------------------+
23-
| I2C | Yes | Yes | |
24-
+-------------+-------------+---------+--------------------+
25-
| I2S | No | Yes | In Development |
26-
+-------------+-------------+---------+--------------------+
27-
| Wi-Fi | Yes | Yes | |
28-
+-------------+-------------+---------+--------------------+
29-
| Bluetooth | Yes | Yes | |
30-
+-------------+-------------+---------+--------------------+
31-
| RMT | Yes | Yes | |
32-
+-------------+-------------+---------+--------------------+
33-
| Touch | Yes | Yes | ESP32 & ESP32-S2 |
34-
+-------------+-------------+---------+--------------------+
35-
| Timer | Yes | Yes | |
36-
+-------------+-------------+---------+--------------------+
37-
| UART | Yes | Yes | |
38-
+-------------+-------------+---------+--------------------+
39-
| Hall Sensor | Yes | Yes | Only for ESP32 |
40-
+-------------+-------------+---------+--------------------+
41-
| LEDC | Yes | Yes | |
42-
+-------------+-------------+---------+--------------------+
43-
| Motor PWM | No | No | |
44-
+-------------+-------------+---------+--------------------+
45-
| TWAI | No | No | |
46-
+-------------+-------------+---------+--------------------+
47-
| Ethernet | Yes | Yes | Only for ESP32 |
48-
+-------------+-------------+---------+--------------------+
49-
| USB | Yes | Yes | Only for ESP32-S2 |
50-
+-------------+-------------+---------+--------------------+
12+
+---------------+---------------+---------------+---------------+-------------------------------+
13+
| Peripheral | ESP32 | ESP32-S2 | ESP32-C3 | Comments |
14+
+===============+===============+===============+===============+===============================+
15+
| ADC | Yes | Yes | Yes | |
16+
+---------------+---------------+---------------+---------------+-------------------------------+
17+
| Bluetooth | Yes | Not Supported | Not Supported | Bluetooth Classic |
18+
+---------------+---------------+---------------+---------------+-------------------------------+
19+
| BLE | Yes | Not Supported | Yes | |
20+
+---------------+---------------+---------------+---------------+-------------------------------+
21+
| DAC | Yes | Yes | Not Supported | |
22+
+---------------+---------------+---------------+---------------+-------------------------------+
23+
| Ethernet | Yes | Not Supported | Not Supported | (*) |
24+
+---------------+---------------+---------------+---------------+-------------------------------+
25+
| GPIO | Yes | Yes | Yes | |
26+
+---------------+---------------+---------------+---------------+-------------------------------+
27+
| Hall Sensor | Yes | Not Supported | Not Supported | |
28+
+---------------+---------------+---------------+---------------+-------------------------------+
29+
| I2C | Yes | Yes | Yes | |
30+
+---------------+---------------+---------------+---------------+-------------------------------+
31+
| I2S | No | No | No | WIP |
32+
+---------------+---------------+---------------+---------------+-------------------------------+
33+
| LEDC | Yes | Yes | Yes | |
34+
+---------------+---------------+---------------+---------------+-------------------------------+
35+
| Motor PWM | No | Not Supported | Not Supported | |
36+
+---------------+---------------+---------------+---------------+-------------------------------+
37+
| Pulse Counter | No | No | No | |
38+
+---------------+---------------+---------------+---------------+-------------------------------+
39+
| RMT | Yes | Yes | Yes | |
40+
+---------------+---------------+---------------+---------------+-------------------------------+
41+
| SDIO | No | No | No | |
42+
+---------------+---------------+---------------+---------------+-------------------------------+
43+
| SPI | Yes | Yes | Yes | |
44+
+---------------+---------------+---------------+---------------+-------------------------------+
45+
| Timer | Yes | Yes | Yes | |
46+
+---------------+---------------+---------------+---------------+-------------------------------+
47+
| Temp. Sensor | Not Supported | Yes | Yes | |
48+
+---------------+---------------+---------------+---------------+-------------------------------+
49+
| Touch | Yes | Yes | Not Supported | |
50+
+---------------+---------------+---------------+---------------+-------------------------------+
51+
| TWAI | No | No | No | |
52+
+---------------+---------------+---------------+---------------+-------------------------------+
53+
| UART | Yes | Yes | Yes | |
54+
+---------------+---------------+---------------+---------------+-------------------------------+
55+
| USB | Not Supported | Yes | Yes | ESP32-C3 only CDC/JTAG |
56+
+---------------+---------------+---------------+---------------+-------------------------------+
57+
| Wi-Fi | Yes | Yes | Yes | |
58+
+---------------+---------------+---------------+---------------+-------------------------------+
5159

52-
Some peripherals are not available for all ESP32 families. To see more details about it, see the corresponding datasheet.
60+
Notes
61+
^^^^^
62+
63+
(*) SPI Ethernet is supported by all ESP32 families and RMII only for ESP32.
64+
65+
.. 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.
66+
67+
Datasheet
68+
^^^^^^^^^
69+
70+
* `ESP32 <https://www.espressif.com/sites/default/files/documentation/esp32_datasheet_en.pdf>`_
71+
* `ESP32-S2 <https://www.espressif.com/sites/default/files/documentation/esp32-s2_datasheet_en.pdf>`_
72+
* `ESP32-C3 <https://www.espressif.com/sites/default/files/documentation/esp32-c3_datasheet_en.pdf>`_
5373

5474
APIs
5575
----

libraries/Ethernet/src/ETH.cpp

+6-1
Original file line numberDiff line numberDiff line change
@@ -368,6 +368,10 @@ bool ETHClass::begin(uint8_t phy_addr, int power, int mdc, int mdio, eth_phy_typ
368368
log_e("esp_eth_init error: %d", err);
369369
}
370370
#endif
371+
// holds a few microseconds to let DHCP start and enter into a good state
372+
// FIX ME -- adresses issue https://github.com/espressif/arduino-esp32/issues/5733
373+
delay(50);
374+
371375
return true;
372376
}
373377

@@ -396,7 +400,8 @@ bool ETHClass::config(IPAddress local_ip, IPAddress gateway, IPAddress subnet, I
396400
if(err != ERR_OK){
397401
log_e("STA IP could not be configured! Error: %d", err);
398402
return false;
399-
}
403+
}
404+
400405
if(info.ip.addr){
401406
staticIP = true;
402407
} else {

libraries/Wire/src/Wire.cpp

+14-6
Original file line numberDiff line numberDiff line change
@@ -447,32 +447,40 @@ void TwoWire::flush(void)
447447

448448
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity, uint8_t sendStop)
449449
{
450-
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop));
450+
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), static_cast<bool>(sendStop));
451451
}
452452

453453
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity, uint8_t sendStop)
454454
{
455-
return requestFrom(address, static_cast<size_t>(quantity), static_cast<bool>(sendStop));
455+
return requestFrom(address, static_cast<uint8_t>(quantity), static_cast<bool>(sendStop));
456+
}
457+
458+
/* Added to match the Arduino function definition: https://github.com/arduino/ArduinoCore-API/blob/173e8eadced2ad32eeb93bcbd5c49f8d6a055ea6/api/HardwareI2C.h#L39
459+
* See: https://github.com/arduino-libraries/ArduinoECCX08/issues/25
460+
*/
461+
size_t TwoWire::requestFrom(uint8_t address, size_t len, bool stopBit)
462+
{
463+
return requestFrom((uint16_t)address, (uint8_t)len, stopBit);
456464
}
457465

458466
uint8_t TwoWire::requestFrom(uint8_t address, uint8_t quantity)
459467
{
460-
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
468+
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
461469
}
462470

463471
uint8_t TwoWire::requestFrom(uint16_t address, uint8_t quantity)
464472
{
465-
return requestFrom(address, static_cast<size_t>(quantity), true);
473+
return requestFrom(address, static_cast<uint8_t>(quantity), true);
466474
}
467475

468476
uint8_t TwoWire::requestFrom(int address, int quantity)
469477
{
470-
return requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), true);
478+
return requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), true);
471479
}
472480

473481
uint8_t TwoWire::requestFrom(int address, int quantity, int sendStop)
474482
{
475-
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<size_t>(quantity), static_cast<bool>(sendStop)));
483+
return static_cast<uint8_t>(requestFrom(static_cast<uint16_t>(address), static_cast<uint8_t>(quantity), static_cast<bool>(sendStop)));
476484
}
477485

478486
void TwoWire::beginTransmission(int address)

libraries/Wire/src/Wire.h

+1
Original file line numberDiff line numberDiff line change
@@ -95,6 +95,7 @@ class TwoWire: public Stream
9595

9696
uint8_t requestFrom(uint16_t address, uint8_t size, bool sendStop);
9797
uint8_t requestFrom(uint16_t address, uint8_t size, uint8_t sendStop);
98+
size_t requestFrom(uint8_t address, size_t len, bool stopBit);
9899
uint8_t requestFrom(uint16_t address, uint8_t size);
99100
uint8_t requestFrom(uint8_t address, uint8_t size, uint8_t sendStop);
100101
uint8_t requestFrom(uint8_t address, uint8_t size);

package/package_esp32_index.template.json

+3-3
Original file line numberDiff line numberDiff line change
@@ -23,13 +23,13 @@
2323
},
2424
"boards": [
2525
{
26-
"name": "ESP32 Dev Module"
26+
"name": "ESP32 Dev Board"
2727
},
2828
{
29-
"name": "WEMOS LoLin32"
29+
"name": "ESP32-S2 Dev Board"
3030
},
3131
{
32-
"name": "WEMOS D1 MINI ESP32"
32+
"name": "ESP32-C3 Dev Board"
3333
}
3434
],
3535
"toolsDependencies": [

0 commit comments

Comments
 (0)