From 4be011785e1f4a46bde58ff370b091a1ab1c0549 Mon Sep 17 00:00:00 2001 From: Konstantin Kondrashov Date: Tue, 14 May 2019 20:01:35 +0800 Subject: [PATCH] pcnt/driver: Add module reset before enabling --- components/driver/pcnt.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/components/driver/pcnt.c b/components/driver/pcnt.c index 6fcc2b552..74846953b 100644 --- a/components/driver/pcnt.c +++ b/components/driver/pcnt.c @@ -59,6 +59,11 @@ esp_err_t pcnt_unit_config(const pcnt_config_t *pcnt_config) PCNT_CHECK((pcnt_config->pos_mode < PCNT_COUNT_MAX) && (pcnt_config->neg_mode < PCNT_COUNT_MAX), PCNT_COUNT_MODE_ERR_STR, ESP_ERR_INVALID_ARG); PCNT_CHECK((pcnt_config->hctrl_mode < PCNT_MODE_MAX) && (pcnt_config->lctrl_mode < PCNT_MODE_MAX), PCNT_CTRL_MODE_ERR_STR, ESP_ERR_INVALID_ARG); /*Enalbe hardware module*/ + static bool pcnt_enable = false; + if (pcnt_enable == false) { + periph_module_reset(PERIPH_PCNT_MODULE); + pcnt_enable = true; + } periph_module_enable(PERIPH_PCNT_MODULE); /*Set counter range*/ pcnt_set_event_value(unit, PCNT_EVT_H_LIM, pcnt_config->counter_h_lim);