pcnt/driver: Add module reset before enabling
This commit is contained in:
parent
aeda8e0c8f
commit
2d08f86958
1 changed files with 5 additions and 0 deletions
|
@ -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);
|
||||
|
|
Loading…
Reference in a new issue