Skip to content

Commit 4114c66

Browse files
[Docs] Add Migration guide + some API updates (espressif#8716)
* Update sigmadelta docs * minor docs updates * Added migration guide to docs * Update Introduction to migration guide * update formatting * fix typo * Add BLE breaking changes * Apply changes from code review by @lucasssvaz Co-authored-by: Lucas Saavedra Vaz <lucassvaz@yahoo.com.br> * uart migration * added RMT and UART + links fix * fix renamed BLE examples * Apply suggestions from code review by @lucasssvaz Co-authored-by: Lucas Saavedra Vaz <lucassvaz@yahoo.com.br> * Change UART driver changes to HardwareSerial changes * update sigmadelta * BLE and examples update + rename --------- Co-authored-by: Lucas Saavedra Vaz <lucassvaz@yahoo.com.br>
1 parent 4b3aebe commit 4114c66

File tree

7 files changed

+239
-32
lines changed

7 files changed

+239
-32
lines changed

docs/source/api/ble.rst

+2-2
Original file line numberDiff line numberDiff line change
@@ -15,13 +15,13 @@ To get started with BLE, you can try:
1515
BLE Scan
1616
********
1717

18-
.. literalinclude:: ../../../libraries/BLE/examples/BLE_scan/BLE_scan.ino
18+
.. literalinclude:: ../../../libraries/BLE/examples/Scan/Scan.ino
1919
:language: arduino
2020

2121
BLE UART
2222
********
2323

24-
.. literalinclude:: ../../../libraries/BLE/examples/BLE_uart/BLE_uart.ino
24+
.. literalinclude:: ../../../libraries/BLE/examples/UART/UART.ino
2525
:language: arduino
2626

2727
Complete list of `BLE examples <https://github.com/espressif/arduino-esp32/tree/master/libraries/BLE/examples>`_.

docs/source/api/ledc.rst

+5-1
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,7 @@ ESP32-S2 8
1717
ESP32-S3 8
1818
ESP32-C3 6
1919
ESP32-C6 6
20+
ESP32-H2 6
2021
========= =======================
2122

2223
Arduino-ESP32 LEDC API
@@ -125,10 +126,13 @@ This function is used to detach the pin from LEDC.
125126

126127
.. code-block:: arduino
127128
128-
void ledcDetach(uint8_t pin);
129+
bool ledcDetach(uint8_t pin);
129130
130131
* ``pin`` select LEDC pin.
131132

133+
This function returns ``true`` if detaching was successful.
134+
If ``false`` is returned, an error occurred and the pin was not detached.
135+
132136
ledcChangeFrequency
133137
*******************
134138

docs/source/api/sigmadelta.rst

+22-28
Original file line numberDiff line numberDiff line change
@@ -14,67 +14,61 @@ ESP32 SoC Number of SigmaDelta channels
1414
========= =============================
1515
ESP32 8
1616
ESP32-S2 8
17-
ESP32-C3 4
1817
ESP32-S3 8
18+
ESP32-C3 4
19+
ESP32-C6 4
20+
ESP32-H2 4
1921
========= =============================
2022

2123
Arduino-ESP32 SigmaDelta API
2224
----------------------------
2325

24-
sigmaDeltaSetup
25-
***************
26+
sigmaDeltaAttach
27+
****************
2628

27-
This function is used to setup the SigmaDelta channel frequency and resolution.
29+
This function is used to set up the SigmaDelta channel with the selected frequency and attach it to the selected pin.
2830

2931
.. code-block:: arduino
3032
31-
uint32_t sigmaDeltaSetup(uint8_t pin, uint8_t channel, uint32_t freq);
33+
bool sigmaDeltaAttach(uint8_t pin, uint32_t freq);
3234
3335
* ``pin`` select GPIO pin.
34-
* ``channel`` select SigmaDelta channel.
3536
* ``freq`` select frequency.
3637

3738
* range is 1-14 bits (1-20 bits for ESP32).
3839

39-
This function will return ``frequency`` configured for the SigmaDelta channel.
40-
If ``0`` is returned, error occurs and the SigmaDelta channel was not configured.
40+
This function returns ``true`` if the configuration was successful.
41+
If ``false`` is returned, an error occurred and the SigmaDelta channel was not configured.
4142

4243
sigmaDeltaWrite
4344
***************
4445

45-
This function is used to set duty for the SigmaDelta channel.
46-
47-
.. code-block:: arduino
48-
49-
void sigmaDeltaWrite(uint8_t channel, uint8_t duty);
50-
51-
* ``channel`` select SigmaDelta channel.
52-
* ``duty`` select duty to be set for selected channel.
53-
54-
sigmaDeltaRead
55-
**************
56-
57-
This function is used to get configured duty for the SigmaDelta channel.
46+
This function is used to set duty for the SigmaDelta pin.
5847

5948
.. code-block:: arduino
6049
61-
uint8_t sigmaDeltaRead(uint8_t channel)
50+
bool sigmaDeltaWrite(uint8_t pin, uint8_t duty);
6251
63-
* ``channnel`` select SigmaDelta channel.
52+
* ``pin`` selects the GPIO pin.
53+
* ``duty`` selects the duty to be set for selected pin.
6454

65-
This function will return ``duty`` configured for the selected SigmaDelta channel.
55+
This function returns ``true`` if setting the duty was successful.
56+
If ``false`` is returned, error occurs and duty was not set.
6657

67-
sigmaDeltaDetachPin
68-
*******************
58+
sigmaDeltaDetach
59+
****************
6960

70-
This function is used to detach pin from SigmaDelta.
61+
This function is used to detach a pin from SigmaDelta and deinitialize the channel that was attached to the pin.
7162

7263
.. code-block:: arduino
7364
74-
void sigmaDeltaDetachPin(uint8_t pin);
65+
bool sigmaDeltaDetach(uint8_t pin);
7566
7667
* ``pin`` select GPIO pin.
7768

69+
This function returns ``true`` if detaching was successful.
70+
If ``false`` is returned, an error occurred and pin was not detached.
71+
7872
Example Applications
7973
********************
8074

docs/source/api/timer.rst

+3-1
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,10 @@ ESP32 SoC Number of timers
1414
========= ================
1515
ESP32 4
1616
ESP32-S2 4
17-
ESP32-C3 2
1817
ESP32-S3 4
18+
ESP32-C3 2
19+
ESP32-C6 2
20+
ESP32-H2 2
1921
========= ================
2022

2123
Arduino-ESP32 Timer API

docs/source/index.rst

+1
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@ Here you will find all the relevant information about the project.
1616
Guides <guides/guides>
1717
Tutorials <tutorials/tutorials>
1818
Advanced Utilities <advanced_utils>
19+
Migration Guides <migration_guides/migration_guides>
1920
FAQ <faq>
2021
Troubleshooting <troubleshooting>
2122
Contributing <contributing>
+196
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,196 @@
1+
#########################
2+
Migration from 2.x to 3.0
3+
#########################
4+
5+
Introduction
6+
------------
7+
8+
This is a guide to highlight **breaking changes** in the API and to help the migration of projects from versions 2.X (based on ESP-IDF 4.4) to version 3.0 (based on ESP-IDF 5.1) of the Arduino ESP32 core.
9+
10+
All the examples on the version 3.0.0 were updated to be compatible to the new API. The old examples from the versions below 3.0.0 will be not compatible with the version 3.0.0 or newer releases.
11+
12+
For more information about all changes and new features, check project `RELEASE NOTES <https://github.com/espressif/arduino-esp32/releases>`_.
13+
14+
ADC
15+
---
16+
17+
Removed APIs
18+
************
19+
20+
* ``analogSetClockDiv``
21+
* ``adcAttachPin``
22+
* ``analogSetVRefPin``
23+
24+
BLE
25+
---
26+
27+
Changes in APIs
28+
***************
29+
30+
* Changed APIs return and parameter type from ``std::string`` to Arduino style ``String``.
31+
* Changed UUID data type from ``uint16_t`` to ``BLEUUID`` class.
32+
* ``BLEScan::start`` and ``BLEScan::getResults`` methods return type changed from ``BLEScanResults`` to ``BLEScanResults*``.
33+
34+
Hall Sensor
35+
-----------
36+
37+
Hall sensor is no longer supported.
38+
39+
Removed APIs
40+
************
41+
42+
* ``hallRead``
43+
44+
I2S
45+
---
46+
47+
The I2S driver has been completely redesigned and refactored to use the new ESP-IDF driver.
48+
For more information about the new API, check :doc:`/api/i2s`.
49+
50+
LEDC
51+
----
52+
53+
The LEDC API has been changed in order to support the Peripheral Manager and make it easier to use, as LEDC channels are now automatically assigned to pins.
54+
For more information about the new API, check :doc:`/api/ledc`.
55+
56+
Removed APIs
57+
************
58+
59+
* ``ledcSetup``
60+
* ``ledcAttachPin``
61+
62+
New APIs
63+
********
64+
65+
* ``ledcAttach`` used to set up the LEDC pin (merged ``ledcSetup`` and ``ledcAttachPin`` functions).
66+
* ``timerGetFrequency`` used to get the actual frequency of the timer.
67+
* ``timerAttachInterruptArg`` used to attach the interrupt to a timer using arguments.
68+
69+
Changes in APIs
70+
***************
71+
72+
* ``ledcDetachPin`` renamed to ``ledcDetach``.
73+
* In all functions, input parameter ``channel`` has been changed to ``pin``.
74+
75+
RMT
76+
---
77+
78+
For more information about the new API, check :doc:`/api/rmt`.
79+
80+
Removed APIs
81+
************
82+
83+
* ``_rmtDumpStatus``
84+
* ``rmtSetTick``
85+
* ``rmtWriteBlocking``
86+
* ``rmtEnd``
87+
* ``rmtBeginReceive``
88+
* ``rmtReadData``
89+
90+
New APIs
91+
********
92+
93+
* ``rmtWriteAsync``
94+
* ``rmtTransmitCompleted``
95+
* ``rmtSetRxMinThreshold``
96+
97+
98+
Changes in APIs
99+
***************
100+
101+
* In all functions, input parameter ``rmt_obj_t* rmt`` has been changed to ``int pin``.
102+
* ``rmtInit`` return parameter changed to bool.
103+
* ``rmtInit`` input parameter ``bool tx_not_rx`` has been changed to ``rmt_ch_dir_t channel_direction``.
104+
* ``rmtInit`` new input parameter ``uint32_t frequency_Hz`` to set frequency of RMT channel (as function ``rmtSetTick`` was removed).
105+
* ``rmtWrite`` now sending data in blocking mode. It only returns after sending all data or through a timeout. For Async mode use the new ``rmtWriteAsync`` function.
106+
* ``rmtWrite`` new input parameter ``uint32_t timeout_ms``.
107+
* ``rmtLoop`` renamed to ``rmtWriteLooping``.
108+
* ``rmtRead`` input parameters changed to ``int pin, rmt_data_t* data, size_t *num_rmt_symbols, uint32_t timeout_ms``.
109+
* ``rmtReadAsync`` input parameters changed to ``int pin, rmt_data_t* data, size_t *num_rmt_symbols``.
110+
* ``rmtSetRxThreshold`` renamed to ``rmtSetRxMaxThreshold`` and input parameter ``uint32_t value`` has been changed to ``uint16_t idle_thres_ticks``.
111+
* ``rmtSetCarrier`` input parameters ``uint32_t low, uint32_t high`` have been changed to ``uint32_t frequency_Hz, float duty_percent``.
112+
113+
SigmaDelta
114+
----------
115+
116+
SigmaDelta has been refactored to use the new ESP-IDF driver.
117+
For more information about the new API, check :doc:`/api/sigmadelta`.
118+
119+
Removed APIs
120+
************
121+
122+
* ``sigmaDeltaSetup``
123+
* ``sigmaDeltaRead``
124+
125+
New APIs
126+
********
127+
128+
* ``sigmaDeltaAttach`` used to set up the SigmaDelta pin (channel is acquired automatically).
129+
* ``timerGetFrequency`` used to get the actual frequency of the timer.
130+
* ``timerAttachInterruptArg`` used to attach the interrupt to a timer using arguments.
131+
132+
Changes in APIs
133+
***************
134+
135+
* ``sigmaDeltaDetachPin`` renamed to ``sigmaDeltaDetach``.
136+
* ``sigmaDeltaWrite`` input parameter ``channel`` has been changed to ``pin``.
137+
138+
Timer
139+
-----
140+
141+
Timer has been refactored to use the new ESP-IDF driver and its API got simplified. For more information about the new API check :doc:`/api/timer`.
142+
143+
Removed APIs
144+
************
145+
146+
* ``timerGetConfig``
147+
* ``timerSetConfig``
148+
* ``timerSetDivider``
149+
* ``timerSetCountUp``
150+
* ``timerSetAutoReload``
151+
* ``timerGetDivider``
152+
* ``timerGetCountUp``
153+
* ``timerGetAutoReload``
154+
* ``timerAlarmEnable``
155+
* ``timerAlarmDisable``
156+
* ``timerAlarmWrite``
157+
* ``timerAlarmEnabled``
158+
* ``timerAlarmRead``
159+
* ``timerAlarmReadMicros``
160+
* ``timerAlarmReadSeconds``
161+
* ``timerAttachInterruptFlag``
162+
163+
New APIs
164+
********
165+
166+
* ``timerAlarm`` used to set up Alarm for the timer and enable it automatically (merged ``timerAlarmWrite`` and ``timerAlarmEnable`` functions).
167+
* ``timerGetFrequency`` used to get the actual frequency of the timer.
168+
* ``timerAttachInterruptArg`` used to attach the interrupt to a timer using arguments.
169+
170+
Changes in APIs
171+
***************
172+
173+
* ``timerBegin`` has now only 1 parameter (frequency). There is an automatic calculation of the divider using different clock sources
174+
to achieve the selected frequency.
175+
* ``timerAttachInterrupt`` has now only 2 parameters. The ``edge`` parameter has been removed.
176+
177+
UART (HardwareSerial)
178+
---------------------
179+
180+
Changes in APIs
181+
***************
182+
183+
* ``setHwFlowCtrlMode`` input parameter ``uint8_t mode`` has been changed to ``SerialHwFlowCtrl mode``.
184+
* ``setMode`` input parameter ``uint8_t mode`` has been changed to ``SerialMode mode``.
185+
186+
Functional changes
187+
******************
188+
189+
* It is now possible to detach UART0 pins by calling ``end()`` with no previous call of ``begin()``.
190+
* It is now possible to call ``setPins()`` before ``begin()`` or in any order.
191+
* ``setPins(``) will detach any previous pins that have been changed.
192+
* ``begin(baud, rx, tx)`` will detach any previous attached pins.
193+
* ``setPins()`` or ``begin(baud, rx, tx)`` when called at first, will detach console RX0/TX0, attached in boot.
194+
* Any pin set as -1 in ``begin()`` or ``setPins()`` won't be changed nor detached.
195+
* ``begin(baud)`` will not change any pins that have been set before this call, through a previous ``begin(baud, rx, tx)`` or ``setPin()``.
196+
* If the application only uses RX or TX, ``begin(baud, -1, tx)`` or ``begin(baud, rx)`` will change only the assigned pin and keep the other unchanged.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
################
2+
Migration Guides
3+
################
4+
5+
.. toctree::
6+
:caption: Migration Guides:
7+
:maxdepth: 1
8+
:glob:
9+
10+
*

0 commit comments

Comments
 (0)