pcnt/driver: Add module reset before enabling

This commit is contained in:
Konstantin Kondrashov 2019-05-14 20:01:35 +08:00 committed by KonstantinKondrashov
parent 051d2fbdd5
commit 46e918cfa1

View File

@ -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);