esp32/modesp32: Add esp32.PCNT class.

Add a new `esp32.PCNT` class that provides complete, low-level support to
the ESP32 PCNT pulse counting hardware units.

This can be used as a building block to implement the higher-level
`machine.Counter` and `machine.Encoder` classes.

This is enabled by default on all OG, S2, S3, C6 boards, but not on C3 (as
the PCNT peripheral is not supported).

Original implementation by: Jonathan Hogg <me@jonathanhogg.com>

Signed-off-by: Jim Mussared <jim.mussared@gmail.com>
Signed-off-by: Angus Gratton <angus@redyak.com.au>
This commit is contained in:
Jonathan Hogg
2023-08-15 13:03:45 +01:00
committed by Damien George
parent bf6f229cf3
commit c3f3339c87
7 changed files with 533 additions and 0 deletions

View File

@@ -299,6 +299,9 @@ static const mp_rom_map_elem_t esp32_module_globals_table[] = {
{ MP_ROM_QSTR(MP_QSTR_NVS), MP_ROM_PTR(&esp32_nvs_type) },
{ MP_ROM_QSTR(MP_QSTR_Partition), MP_ROM_PTR(&esp32_partition_type) },
#if MICROPY_PY_ESP32_PCNT
{ MP_ROM_QSTR(MP_QSTR_PCNT), MP_ROM_PTR(&esp32_pcnt_type) },
#endif
#if SOC_RMT_SUPPORTED
{ MP_ROM_QSTR(MP_QSTR_RMT), MP_ROM_PTR(&esp32_rmt_type) },
#endif