diff --git a/ports/esp32s2/Makefile b/ports/esp32s2/Makefile index 56f0d46a31..55d6e91d44 100644 --- a/ports/esp32s2/Makefile +++ b/ports/esp32s2/Makefile @@ -188,7 +188,7 @@ SRC_C += \ lib/utils/pyexec.c \ lib/utils/stdout_helpers.c \ lib/utils/sys_stdio_mphal.c \ - peripherals/pcnt_handler.c \ + peripherals/pcnt.c \ peripherals/pins.c \ peripherals/rmt.c \ supervisor/shared/memory.c diff --git a/ports/esp32s2/common-hal/countio/Counter.c b/ports/esp32s2/common-hal/countio/Counter.c index 4357624733..81f9f7ad2a 100644 --- a/ports/esp32s2/common-hal/countio/Counter.c +++ b/ports/esp32s2/common-hal/countio/Counter.c @@ -42,7 +42,8 @@ void common_hal_countio_counter_construct(countio_counter_obj_t* self, .neg_mode = PCNT_COUNT_DIS, // Keep the counter value on the negative edge }; // Initialize PCNT unit - pcnt_handler_init(&pcnt_config); + // This also sets pcnt_config.unit + peripherals_pcnt_init(&pcnt_config); self->pin = pin->number; self->unit = pcnt_config.unit; @@ -57,7 +58,7 @@ void common_hal_countio_counter_deinit(countio_counter_obj_t* self) { return; } reset_pin_number(self->pin); - pcnt_handler_deinit(&self->unit); + peripherals_pcnt_deinit(&self->unit); } mp_int_t common_hal_countio_counter_get_count(countio_counter_obj_t* self) { diff --git a/ports/esp32s2/common-hal/countio/Counter.h b/ports/esp32s2/common-hal/countio/Counter.h index 63d1eb98b2..20fe5b83e6 100644 --- a/ports/esp32s2/common-hal/countio/Counter.h +++ b/ports/esp32s2/common-hal/countio/Counter.h @@ -28,7 +28,7 @@ #define MICROPY_INCLUDED_ESP32S2_COMMON_HAL_COUNTIO_COUNTER_H #include "py/obj.h" -#include "pcnt_handler.h" +#include "peripherals/pcnt.h" typedef struct { mp_obj_base_t base; diff --git a/ports/esp32s2/peripherals/pcnt_handler.c b/ports/esp32s2/peripherals/pcnt.c similarity index 94% rename from ports/esp32s2/peripherals/pcnt_handler.c rename to ports/esp32s2/peripherals/pcnt.c index 5a0cc9a7c2..e7eb32c1d1 100644 --- a/ports/esp32s2/peripherals/pcnt_handler.c +++ b/ports/esp32s2/peripherals/pcnt.c @@ -24,7 +24,7 @@ * THE SOFTWARE. */ -#include "pcnt_handler.h" +#include "peripherals/pcnt.h" #include "py/runtime.h" #include "supervisor/shared/translate.h" @@ -34,7 +34,7 @@ static uint8_t pcnt_state[4]; -void pcnt_handler_init(pcnt_config_t* pcnt_config) { +void peripherals_pcnt_init(pcnt_config_t* pcnt_config) { // Look for available pcnt unit for (uint8_t i = 0; i<=3; i++) { if (pcnt_state[i] == PCNT_UNIT_INACTIVE) { @@ -61,7 +61,7 @@ void pcnt_handler_init(pcnt_config_t* pcnt_config) { pcnt_counter_resume(pcnt_config->unit); } -void pcnt_handler_deinit(pcnt_unit_t* unit) { +void peripherals_pcnt_deinit(pcnt_unit_t* unit) { pcnt_state[*unit] = PCNT_UNIT_INACTIVE; *unit = PCNT_UNIT_MAX; } diff --git a/ports/esp32s2/peripherals/pcnt_handler.h b/ports/esp32s2/peripherals/pcnt.h similarity index 92% rename from ports/esp32s2/peripherals/pcnt_handler.h rename to ports/esp32s2/peripherals/pcnt.h index f44ee1f830..64072501cb 100644 --- a/ports/esp32s2/peripherals/pcnt_handler.h +++ b/ports/esp32s2/peripherals/pcnt.h @@ -29,7 +29,7 @@ #include "driver/pcnt.h" -extern void pcnt_handler_init(pcnt_config_t* pcnt_config); -extern void pcnt_handler_deinit(pcnt_unit_t* unit); +extern void peripherals_pcnt_init(pcnt_config_t* pcnt_config); +extern void peripherals_pcnt_deinit(pcnt_unit_t* unit); #endif // MICROPY_INCLUDED_ESP32S2_PERIPHERALS_PCNT_HANDLER_H