Skip to content

Commit 3d26557

Browse files
authored
Merge branch 'micropython:master' into esp32_bitstream
2 parents e85fa96 + 5f058e9 commit 3d26557

File tree

300 files changed

+5964
-1998
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

300 files changed

+5964
-1998
lines changed

docs/develop/natmod.rst

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -81,7 +81,14 @@ Linker limitation: the native module is not linked against the symbol table of t
8181
full MicroPython firmware. Rather, it is linked against an explicit table of exported
8282
symbols found in ``mp_fun_table`` (in ``py/nativeglue.h``), that is fixed at firmware
8383
build time. It is thus not possible to simply call some arbitrary HAL/OS/RTOS/system
84-
function, for example.
84+
function, for example, unless that resides at a fixed address. In that case, the path
85+
of a linkerscript containing a series of symbol names and their fixed address can be
86+
passed to ``mpy_ld.py`` via the ``--externs`` command line argument. That way symbols
87+
appearing in the linkerscript will take precedence over what is provided from object
88+
files, but at the moment the object files' implementation will still reside in the
89+
final MPY file. The linkerscript parser is limited in its capabilities, and is
90+
currently used only for parsing the ESP8266 port ROM symbols list (see
91+
``ports/esp8266/boards/eagle.rom.addr.v6.ld``).
8592

8693
New symbols can be added to the end of the table and the firmware rebuilt.
8794
The symbols also need to be added to ``tools/mpy_ld.py``'s ``fun_table`` dict in the

docs/esp32/quickref.rst

Lines changed: 49 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ Required keyword arguments for the constructor:
148148
- ``mdc`` and ``mdio`` - :class:`machine.Pin` objects (or integers) specifying
149149
the MDC and MDIO pins.
150150
- ``phy_type`` - Select the PHY device type. Supported devices are
151+
``PHY_GENERIC``,
151152
``PHY_LAN8710``, ``PHY_LAN8720``, ``PHY_IP101``, ``PHY_RTL8201``,
152153
``PHY_DP83848``, ``PHY_KSZ8041`` and ``PHY_KSZ8081``. These values are all
153154
constants defined in the ``network`` module.
@@ -270,8 +271,10 @@ Use the :mod:`time <time>` module::
270271
Timers
271272
------
272273

273-
The ESP32 port has four hardware timers. Use the :ref:`machine.Timer <machine.Timer>` class
274-
with a timer ID from 0 to 3 (inclusive)::
274+
The ESP32 port has one, two or four hardware timers, depending on the ESP32 device type.
275+
There is 1 timer for ESP32C2, 2 timers for ESP32C4, ESP32C6 and ESP32H4, and
276+
4 timers otherwise. Use the :ref:`machine.Timer <machine.Timer>` class
277+
with a timer ID of 0, 0 and 1, or from 0 to 3 (inclusive)::
275278

276279
from machine import Timer
277280

@@ -281,7 +284,8 @@ with a timer ID from 0 to 3 (inclusive)::
281284
tim1 = Timer(1)
282285
tim1.init(period=2000, mode=Timer.PERIODIC, callback=lambda t:print(1))
283286

284-
The period is in milliseconds.
287+
The period is in milliseconds. When using UART.IRQ_RXIDLE, timer 0 is needed for
288+
the IRQ_RXIDLE mechanism and must not be used otherwise.
285289

286290
Virtual timers are not currently supported on this port.
287291

@@ -383,7 +387,7 @@ for more details.
383387

384388
Use the :ref:`machine.PWM <machine.PWM>` class::
385389

386-
from machine import Pin, PWM
390+
from machine import Pin, PWM, lightsleep
387391

388392
pwm0 = PWM(Pin(0), freq=5000, duty_u16=32768) # create PWM object from a pin
389393
freq = pwm0.freq() # get current frequency
@@ -393,7 +397,7 @@ Use the :ref:`machine.PWM <machine.PWM>` class::
393397
pwm0.duty(256) # set duty cycle from 0 to 1023 as a ratio duty/1023, (now 25%)
394398

395399
duty_u16 = pwm0.duty_u16() # get current duty cycle, range 0-65535
396-
pwm0.duty_u16(2**16*3//4) # set duty cycle from 0 to 65535 as a ratio duty_u16/65535, (now 75%)
400+
pwm0.duty_u16(65536*3//4) # set duty cycle from 0 to 65535 as a ratio duty_u16/65535, (now 75%)
397401

398402
duty_ns = pwm0.duty_ns() # get current pulse width in ns
399403
pwm0.duty_ns(250_000) # set pulse width in nanoseconds from 0 to 1_000_000_000/freq, (now 25%)
@@ -402,19 +406,35 @@ Use the :ref:`machine.PWM <machine.PWM>` class::
402406

403407
pwm2 = PWM(Pin(2), freq=20000, duty=512) # create and configure in one go
404408
print(pwm2) # view PWM settings
409+
pwm2.deinit() # turn off PWM on the pin
410+
411+
pwm0 = PWM(Pin(0), duty_u16=16384) # The output is at a high level 25% of the time.
412+
pwm2 = PWM(Pin(2), duty_u16=16384, invert=1) # The output is at a low level 25% of the time.
413+
414+
pwm4 = PWM(Pin(4), lightsleep=True) # Allow PWM during light sleep mode
415+
416+
lightsleep(10*1000) # pwm0, pwm2 goes off, pwm4 stays on during 10s light sleep
417+
# pwm0, pwm2, pwm4 on after 10s light sleep
405418

406419
ESP chips have different hardware peripherals:
407420

408-
===================================================== ======== ======== ========
409-
Hardware specification ESP32 ESP32-S2 ESP32-C3
410-
----------------------------------------------------- -------- -------- --------
411-
Number of groups (speed modes) 2 1 1
412-
Number of timers per group 4 4 4
413-
Number of channels per group 8 8 6
414-
----------------------------------------------------- -------- -------- --------
415-
Different PWM frequencies (groups * timers) 8 4 4
416-
Total PWM channels (Pins, duties) (groups * channels) 16 8 6
417-
===================================================== ======== ======== ========
421+
======================================================= ======== ========= ==========
422+
Hardware specification ESP32 ESP32-S2, ESP32-C2,
423+
ESP32-S3, ESP32-C3,
424+
ESP32-P4 ESP32-C5,
425+
ESP32-C6,
426+
ESP32-H2
427+
------------------------------------------------------- -------- --------- ----------
428+
Number of groups (speed modes) 2 1 1
429+
Number of timers per group 4 4 4
430+
Number of channels per group 8 8 6
431+
------------------------------------------------------- -------- --------- ----------
432+
Different PWM frequencies = (groups * timers) 8 4 4
433+
Total PWM channels (Pins, duties) = (groups * channels) 16 8 6
434+
======================================================= ======== ========= ==========
435+
436+
In light sleep, the ESP32 PWM can only operate in low speed mode, so only 4 timers and
437+
8 channels are available.
418438

419439
A maximum number of PWM channels (Pins) are available on the ESP32 - 16 channels,
420440
but only 8 different PWM frequencies are available, the remaining 8 channels must
@@ -524,14 +544,27 @@ Legacy methods:
524544

525545
Equivalent to ``ADC.block().init(bits=bits)``.
526546

547+
The only chip that can switch resolution to a lower one is the normal esp32.
548+
The C2 & S3 are stuck at 12 bits, while the S2 is at 13 bits.
549+
527550
For compatibility, the ``ADC`` object also provides constants matching the
528-
supported ADC resolutions:
551+
supported ADC resolutions, per chip:
529552

553+
ESP32:
530554
- ``ADC.WIDTH_9BIT`` = 9
531555
- ``ADC.WIDTH_10BIT`` = 10
532556
- ``ADC.WIDTH_11BIT`` = 11
533557
- ``ADC.WIDTH_12BIT`` = 12
534558

559+
ESP32 C3 & S3:
560+
- ``ADC.WIDTH_12BIT`` = 12
561+
562+
ESP32 S2:
563+
- ``ADC.WIDTH_13BIT`` = 13
564+
565+
.. method:: ADC.deinit()
566+
567+
Provided to deinit the adc driver.
535568

536569
Software SPI bus
537570
----------------

0 commit comments

Comments
 (0)