Skip to content

Commit 45cc7d1

Browse files
authored
Merge branch 'master' into uart-stdfunc
2 parents a1f8cfb + c2e5957 commit 45cc7d1

File tree

32 files changed

+2095
-120
lines changed

32 files changed

+2095
-120
lines changed

.github/workflows/test_selfhosted_runner.yml

Lines changed: 0 additions & 28 deletions
This file was deleted.

boards.txt

Lines changed: 438 additions & 1 deletion
Large diffs are not rendered by default.

cores/esp32/esp32-hal-log.h

Lines changed: 6 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,11 @@ extern "C"
3838
#else
3939
#define ARDUHAL_LOG_LEVEL CORE_DEBUG_LEVEL
4040
#ifdef USE_ESP_IDF_LOG
41+
#ifndef LOG_LOCAL_LEVEL
4142
#define LOG_LOCAL_LEVEL CORE_DEBUG_LEVEL
4243
#endif
4344
#endif
45+
#endif
4446

4547
#ifndef CONFIG_ARDUHAL_LOG_COLORS
4648
#define CONFIG_ARDUHAL_LOG_COLORS 0
@@ -158,7 +160,7 @@ void log_print_buf(const uint8_t *b, size_t len);
158160
#define isr_log_e(format, ...) ets_printf(ARDUHAL_LOG_FORMAT(E, format), ##__VA_ARGS__)
159161
#define log_buf_e(b,l) do{ARDUHAL_LOG_COLOR_PRINT(E);log_print_buf(b,l);ARDUHAL_LOG_COLOR_PRINT_END;}while(0)
160162
#else
161-
#define log_e(format, ...) do {log_to_esp(TAG, ESP_LOG_ERROR, format, ##__VA_ARGS__);}while(0)
163+
#define log_e(format, ...) do {ESP_LOG_LEVEL_LOCAL(ESP_LOG_ERROR, TAG, format, ##__VA_ARGS__);}while(0)
162164
#define isr_log_e(format, ...) do {ets_printf(LOG_FORMAT(E, format), esp_log_timestamp(), TAG, ##__VA_ARGS__);}while(0)
163165
#define log_buf_e(b,l) do {ESP_LOG_BUFFER_HEXDUMP(TAG, b, l, ESP_LOG_ERROR);}while(0)
164166
#endif
@@ -187,9 +189,9 @@ void log_print_buf(const uint8_t *b, size_t len);
187189
#include "esp_log.h"
188190

189191
#ifdef USE_ESP_IDF_LOG
190-
#ifndef TAG
191-
#define TAG "ARDUINO"
192-
#endif
192+
//#ifndef TAG
193+
//#define TAG "ARDUINO"
194+
//#endif
193195
//#define log_n(format, ...) myLog(ESP_LOG_NONE, format, ##__VA_ARGS__)
194196
#else
195197
#ifdef CONFIG_ARDUHAL_ESP_LOG

cores/esp32/esp32-hal-timer.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,7 +58,7 @@ bool timerGetAutoReload(hw_timer_t *timer);
5858

5959
void timerAlarmEnable(hw_timer_t *timer);
6060
void timerAlarmDisable(hw_timer_t *timer);
61-
void timerAlarmWrite(hw_timer_t *timer, uint64_t interruptAt, bool autoreload);
61+
void timerAlarmWrite(hw_timer_t *timer, uint64_t alarm_value, bool autoreload);
6262

6363
bool timerAlarmEnabled(hw_timer_t *timer);
6464
uint64_t timerAlarmRead(hw_timer_t *timer);

docs/requirements.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@
33
#
44
# matplotlib is currently required only by the script generate_chart.py
55
sphinx-copybutton==0.3.0
6+
sphinx-tabs==3.2.0

docs/source/_static/logo_arduino.png

22.5 KB
Loading

docs/source/_static/logo_pio.png

25.4 KB
Loading

docs/source/api/adc.rst

Lines changed: 208 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,208 @@
1+
###
2+
ADC
3+
###
4+
5+
About
6+
-----
7+
8+
ADC (analog to digital converter) is a very common peripheral used to convert an analog signal such as voltage
9+
to a digital form so that it can be read and processed by a microcontroller.
10+
11+
ADCs are very useful in control and monitoring applications since most sensors
12+
(e.g., temperature, pressure, force) produce analogue output voltages.
13+
14+
.. note:: Each SoC or module has a different number of ADC's with a different number of channels and pins availible. Refer to datasheet of each board for more info.
15+
16+
Arduino-ESP32 ADC API
17+
---------------------
18+
19+
ADC common API
20+
**************
21+
22+
analogRead
23+
^^^^^^^^^^
24+
25+
This function is used to get the ADC raw value for a given pin/ADC channel.
26+
27+
.. code-block:: arduino
28+
29+
uint16_t analogRead(uint8_t pin);
30+
31+
* ``pin`` GPIO pin to read analog value
32+
33+
This function will return analog raw value.
34+
35+
analogReadMillivolts
36+
^^^^^^^^^^^^^^^^^^^^
37+
38+
This function is used to get ADC value for a given pin/ADC channel in millivolts.
39+
40+
.. code-block:: arduino
41+
42+
uint32_t analogReadMilliVolts(uint8_t pin);
43+
44+
* ``pin`` GPIO pin to read analog value
45+
46+
This function will return analog value in millivolts.
47+
48+
analogReadResolution
49+
^^^^^^^^^^^^^^^^^^^^
50+
51+
This function is used to set the resolution of ``analogRead`` return value. Default is 12 bits (range from 0 to 4096)
52+
for all chips except ESP32S3 where default is 13 bits (range from 0 to 8192).
53+
When different resolution is set, the values read will be shifted to match the given resolution.
54+
55+
Range is 1 - 16 .The default value will be used, if this function is not used.
56+
57+
.. note:: For the ESP32, the resolution is between 9 to12 and it will change the ADC hardware resolution. Else value will be shifted.
58+
59+
.. code-block:: arduino
60+
61+
void analogReadResolution(uint8_t bits);
62+
63+
* ``bits`` sets analog read resolution
64+
65+
analogSetClockDiv
66+
^^^^^^^^^^^^^^^^^
67+
68+
This function is used to set the divider for the ADC clock.
69+
70+
Range is 1 - 255. Default value is 1.
71+
72+
.. code-block:: arduino
73+
74+
void analogSetClockDiv(uint8_t clockDiv);
75+
76+
* ``clockDiv`` sets the divider for ADC clock.
77+
78+
analogSetAttenuation
79+
^^^^^^^^^^^^^^^^^^^^
80+
81+
This function is used to set the attenuation for all channels.
82+
83+
Input voltages can be attenuated before being input to the ADCs.
84+
There are 4 available attenuation options, the higher the attenuation is, the higher the measurable input voltage could be.
85+
86+
The measurable input voltage differs for each chip, see table below for detailed information.
87+
88+
.. tabs::
89+
90+
.. tab:: ESP32
91+
92+
===================== ===========================================
93+
Attenuation Measurable input voltage range
94+
===================== ===========================================
95+
``ADC_ATTEN_DB_0`` 100 mV ~ 950 mV
96+
``ADC_ATTEN_DB_2_5`` 100 mV ~ 1250 mV
97+
``ADC_ATTEN_DB_6`` 150 mV ~ 1750 mV
98+
``ADC_ATTEN_DB_11`` 150 mV ~ 2450 mV
99+
===================== ===========================================
100+
101+
.. tab:: ESP32-S2
102+
103+
===================== ===========================================
104+
Attenuation Measurable input voltage range
105+
===================== ===========================================
106+
``ADC_ATTEN_DB_0`` 0 mV ~ 750 mV
107+
``ADC_ATTEN_DB_2_5`` 0 mV ~ 1050 mV
108+
``ADC_ATTEN_DB_6`` 0 mV ~ 1300 mV
109+
``ADC_ATTEN_DB_11`` 0 mV ~ 2500 mV
110+
===================== ===========================================
111+
112+
.. tab:: ESP32-C3
113+
114+
===================== ===========================================
115+
Attenuation Measurable input voltage range
116+
===================== ===========================================
117+
``ADC_ATTEN_DB_0`` 0 mV ~ 750 mV
118+
``ADC_ATTEN_DB_2_5`` 0 mV ~ 1050 mV
119+
``ADC_ATTEN_DB_6`` 0 mV ~ 1300 mV
120+
``ADC_ATTEN_DB_11`` 0 mV ~ 2500 mV
121+
===================== ===========================================
122+
123+
.. tab:: ESP32-S3
124+
125+
===================== ===========================================
126+
Attenuation Measurable input voltage range
127+
===================== ===========================================
128+
``ADC_ATTEN_DB_0`` 0 mV ~ 950 mV
129+
``ADC_ATTEN_DB_2_5`` 0 mV ~ 1250 mV
130+
``ADC_ATTEN_DB_6`` 0 mV ~ 1750 mV
131+
``ADC_ATTEN_DB_11`` 0 mV ~ 3100 mV
132+
===================== ===========================================
133+
134+
.. code-block:: arduino
135+
136+
void analogSetAttenuation(adc_attenuation_t attenuation);
137+
138+
* ``attenuation`` sets the attenuation.
139+
140+
analogSetPinAttenuation
141+
^^^^^^^^^^^^^^^^^^^^^^^
142+
143+
This function is used to set the attenuation for a specific pin/ADC channel. For more information refer to `analogSetAttenuation`_.
144+
145+
.. code-block:: arduino
146+
147+
void analogSetPinAttenuation(uint8_t pin, adc_attenuation_t attenuation);
148+
149+
* ``pin`` selects specific pin for attenuation settings.
150+
* ``attenuation`` sets the attenuation.
151+
152+
adcAttachPin
153+
^^^^^^^^^^^^
154+
155+
This function is used to attach the pin to ADC (it will also clear any other analog mode that could be on)
156+
157+
.. code-block:: arduino
158+
159+
bool adcAttachPin(uint8_t pin);
160+
161+
This function will return ``true`` if configuration is successful. Else returns ``false``.
162+
163+
ADC API specific for ESP32 chip
164+
*******************************
165+
166+
analogSetWidth
167+
^^^^^^^^^^^^^^
168+
169+
This function is used to set the hardware sample bits and read resolution.
170+
Default is 12bit (0 - 4095).
171+
Range is 9 - 12.
172+
173+
.. code-block:: arduino
174+
175+
void analogSetWidth(uint8_t bits);
176+
177+
analogSetVRefPin
178+
^^^^^^^^^^^^^^^^
179+
180+
This function is used to set pin to use for ADC calibration if the esp is not already calibrated (pins 25, 26 or 27).
181+
182+
.. code-block:: arduino
183+
184+
void analogSetVRefPin(uint8_t pin);
185+
186+
* ``pin`` GPIO pin to set VRefPin for ADC calibration
187+
188+
hallRead
189+
^^^^^^^^
190+
191+
This function is used to get the ADC value of the HALL sensor conneted to pins 36(SVP) and 39(SVN).
192+
193+
.. code-block:: arduino
194+
195+
int hallRead();
196+
197+
This function will return the hall sensor value.
198+
199+
200+
Example Applications
201+
********************
202+
203+
Here is an example of how to use the ADC.
204+
205+
.. literalinclude:: ../../../libraries/ESP32/examples/AnalogRead/AnalogRead.ino
206+
:language: arduino
207+
208+
Or you can run Arduino example 01.Basics -> AnalogReadSerial.

docs/source/api/dac.rst

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
###
2+
DAC
3+
###
4+
5+
About
6+
-----
7+
8+
DAC (digital to analog converter) is a very common peripheral used to convert a digital signal to an
9+
analog form.
10+
11+
ESP32 and ESP32-S2 have two 8-bit DAC channels. The DAC driver allows these channels to be set to arbitrary voltages.
12+
13+
DACs can be used for generating a specific (and dynamic) reference voltage for external sensors,
14+
controlling transistors, etc.
15+
16+
========= ========= =========
17+
ESP32 SoC DAC_1 pin DAC_2 pin
18+
========= ========= =========
19+
ESP32 GPIO 25 GPIO 26
20+
ESP32-S2 GPIO 17 GPIO 18
21+
========= ========= =========
22+
23+
Arduino-ESP32 DAC API
24+
---------------------
25+
26+
dacWrite
27+
********
28+
29+
This function is used to set the DAC value for a given pin/DAC channel.
30+
31+
.. code-block:: arduino
32+
33+
void dacWrite(uint8_t pin, uint8_t value);
34+
35+
* ``pin`` GPIO pin.
36+
* ``value`` to be set. Range is 0 - 255 (equals 0V - 3.3V).
37+
38+
dacDisable
39+
**********
40+
41+
This function is used to disable DAC output on a given pin/DAC channel.
42+
43+
.. code-block:: arduino
44+
45+
void dacDisable(uint8_t pin);
46+
47+
* ``pin`` GPIO pin.

0 commit comments

Comments
 (0)