@@ -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::
270271Timers
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
286290Virtual timers are not currently supported on this port.
287291
@@ -383,7 +387,7 @@ for more details.
383387
384388Use 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
406419ESP 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
419439A maximum number of PWM channels (Pins) are available on the ESP32 - 16 channels,
420440but 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+
527550For 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
536569Software SPI bus
537570----------------
0 commit comments