perf: updated error checks
This commit is contained in:
1 parent
011c759809
commit
e05bc424cf
2 files changed
+53
-71
No files matched your search
@@ -8,6 +8,10 @@
|
|||||||
|
|
||||||
[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code.
|
[PVS-Studio](https://pvs-studio.com/pvs-studio/?utm_source=website&utm_medium=github&utm_campaign=open_source) - static analyzer for C, C++, C#, and Java code.
|
||||||
|
|
||||||
|
## Features
|
||||||
|
|
||||||
|
1. Support up to 8 inclinometers on one device.
|
||||||
|
|
||||||
## Attention
|
## Attention
|
||||||
|
|
||||||
1. For correct operation, please enable the following settings in the menuconfig:
|
1. For correct operation, please enable the following settings in the menuconfig:
|
||||||
|
|||||||
+49
-71
@@ -21,10 +21,8 @@ esp_err_t zh_inclinometer_init(const zh_inclinometer_init_config_t *config, zh_i
|
|||||||
ZH_LOGI("Inclinometer initialization started.");
|
ZH_LOGI("Inclinometer initialization started.");
|
||||||
ZH_ERROR_CHECK(config != NULL && handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer initialization failed. Invalid argument.");
|
ZH_ERROR_CHECK(config != NULL && handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer initialization failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(handle->is_initialized == false, ESP_ERR_INVALID_STATE, NULL, "Inclinometer initialization failed. Inclinometer is already initialized.");
|
ZH_ERROR_CHECK(handle->is_initialized == false, ESP_ERR_INVALID_STATE, NULL, "Inclinometer initialization failed. Inclinometer is already initialized.");
|
||||||
esp_err_t err = _zh_inclinometer_validate_config(config);
|
ZH_ERROR_CHECK(_zh_inclinometer_validate_config(config) == ESP_OK, ESP_FAIL, NULL, "Inclinometer initialization failed. Initial configuration check failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer initialization failed. Initial configuration check failed.");
|
ZH_ERROR_CHECK(_zh_inclinometer_pcnt_init(config, handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer initialization failed. PCNT initialization failed.");
|
||||||
err = _zh_inclinometer_pcnt_init(config, handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer initialization failed. PCNT initialization failed.");
|
|
||||||
handle->degrees_per_pulse = 360.0 / config->encoder_pulses;
|
handle->degrees_per_pulse = 360.0 / config->encoder_pulses;
|
||||||
handle->rotation = config->rotation;
|
handle->rotation = config->rotation;
|
||||||
handle->is_initialized = true;
|
handle->is_initialized = true;
|
||||||
@@ -37,16 +35,11 @@ esp_err_t zh_inclinometer_deinit(zh_inclinometer_handle_t *handle) // -V2008
|
|||||||
ZH_LOGI("Inclinometer deinitialization started.");
|
ZH_LOGI("Inclinometer deinitialization started.");
|
||||||
ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer deinitialization failed. Invalid argument.");
|
ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer deinitialization failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer deinitialization failed. Inclinometer not initialized.");
|
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer deinitialization failed. Inclinometer not initialized.");
|
||||||
esp_err_t err = pcnt_unit_stop(handle->pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_unit_stop(handle->pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer deinitialization failed. PCNT unit stop fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer deinitialization failed. PCNT unit stop fail.");
|
ZH_ERROR_CHECK(pcnt_unit_disable(handle->pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer deinitialization failed. PCNT unit disable fail.");
|
||||||
err = pcnt_unit_disable(handle->pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(handle->pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer deinitialization failed. PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer deinitialization failed. PCNT unit disable fail.");
|
ZH_ERROR_CHECK(pcnt_del_channel(handle->pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer deinitialization failed. PCNT delete channel fail.");
|
||||||
err = pcnt_del_channel(handle->pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(handle->pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer deinitialization failed. PCNT delete unit fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer deinitialization failed. PCNT delete channel fail.");
|
|
||||||
err = pcnt_del_channel(handle->pcnt_channel_b_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer deinitialization failed. PCNT delete channel fail.");
|
|
||||||
err = pcnt_del_unit(handle->pcnt_unit_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer deinitialization failed. PCNT delete unit fail.");
|
|
||||||
handle->is_initialized = false;
|
handle->is_initialized = false;
|
||||||
ZH_LOGI("Inclinometer deinitialization completed successfully.");
|
ZH_LOGI("Inclinometer deinitialization completed successfully.");
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
@@ -58,8 +51,7 @@ esp_err_t zh_inclinometer_get(zh_inclinometer_handle_t *handle, float *angle)
|
|||||||
ZH_ERROR_CHECK(handle != NULL && angle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer get position failed. Invalid argument.");
|
ZH_ERROR_CHECK(handle != NULL && angle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer get position failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer get position failed. Inclinometer not initialized.");
|
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer get position failed. Inclinometer not initialized.");
|
||||||
int pcnt_count = 0;
|
int pcnt_count = 0;
|
||||||
esp_err_t err = pcnt_unit_get_count(handle->pcnt_unit_handle, &pcnt_count);
|
ZH_ERROR_CHECK(pcnt_unit_get_count(handle->pcnt_unit_handle, &pcnt_count) == ESP_OK, ESP_FAIL, NULL, "Inclinometer get position failed. PCNT unit get count fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer get position failed. PCNT unit get count fail.");
|
|
||||||
float angle_temp = pcnt_count * handle->degrees_per_pulse;
|
float angle_temp = pcnt_count * handle->degrees_per_pulse;
|
||||||
*angle = (handle->rotation == true) ? angle_temp : ((angle_temp == 0) ? angle_temp : -angle_temp);
|
*angle = (handle->rotation == true) ? angle_temp : ((angle_temp == 0) ? angle_temp : -angle_temp);
|
||||||
ZH_LOGI("Inclinometer get position completed successfully.");
|
ZH_LOGI("Inclinometer get position completed successfully.");
|
||||||
@@ -71,8 +63,7 @@ esp_err_t zh_inclinometer_reset(zh_inclinometer_handle_t *handle)
|
|||||||
ZH_LOGI("Inclinometer reset started.");
|
ZH_LOGI("Inclinometer reset started.");
|
||||||
ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer reset failed. Invalid argument.");
|
ZH_ERROR_CHECK(handle != NULL, ESP_ERR_INVALID_ARG, NULL, "Inclinometer reset failed. Invalid argument.");
|
||||||
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer reset failed. Inclinometer not initialized.");
|
ZH_ERROR_CHECK(handle->is_initialized == true, ESP_FAIL, NULL, "Inclinometer reset failed. Inclinometer not initialized.");
|
||||||
esp_err_t err = pcnt_unit_clear_count(handle->pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_unit_clear_count(handle->pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "Inclinometer reset failed. PCNT unit clear count fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Inclinometer reset failed. PCNT unit clear count fail.");
|
|
||||||
ZH_LOGI("Inclinometer reset completed successfully.");
|
ZH_LOGI("Inclinometer reset completed successfully.");
|
||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
@@ -92,74 +83,61 @@ static esp_err_t _zh_inclinometer_pcnt_init(const zh_inclinometer_init_config_t
|
|||||||
.low_limit = -config->encoder_pulses,
|
.low_limit = -config->encoder_pulses,
|
||||||
};
|
};
|
||||||
pcnt_unit_handle_t pcnt_unit_handle = NULL;
|
pcnt_unit_handle_t pcnt_unit_handle = NULL;
|
||||||
esp_err_t err = pcnt_new_unit(&pcnt_unit_config, &pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_new_unit(&pcnt_unit_config, &pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT initialization failed.");
|
|
||||||
pcnt_glitch_filter_config_t pcnt_glitch_filter_config = {
|
pcnt_glitch_filter_config_t pcnt_glitch_filter_config = {
|
||||||
.max_glitch_ns = 1000,
|
.max_glitch_ns = 1000,
|
||||||
};
|
};
|
||||||
err = pcnt_unit_set_glitch_filter(pcnt_unit_handle, &pcnt_glitch_filter_config);
|
ZH_ERROR_CHECK(pcnt_unit_set_glitch_filter(pcnt_unit_handle, &pcnt_glitch_filter_config) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
|
||||||
pcnt_chan_config_t pcnt_chan_a_config = {
|
pcnt_chan_config_t pcnt_chan_a_config = {
|
||||||
.edge_gpio_num = config->a_gpio_number,
|
.edge_gpio_num = config->a_gpio_number,
|
||||||
.level_gpio_num = config->b_gpio_number,
|
.level_gpio_num = config->b_gpio_number,
|
||||||
};
|
};
|
||||||
pcnt_channel_handle_t pcnt_channel_a_handle = NULL;
|
pcnt_channel_handle_t pcnt_channel_a_handle = NULL;
|
||||||
err = pcnt_new_channel(pcnt_unit_handle, &pcnt_chan_a_config, &pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_new_channel(pcnt_unit_handle, &pcnt_chan_a_config, &pcnt_channel_a_handle) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
|
||||||
pcnt_chan_config_t pcnt_chan_b_config = {
|
pcnt_chan_config_t pcnt_chan_b_config = {
|
||||||
.edge_gpio_num = config->b_gpio_number,
|
.edge_gpio_num = config->b_gpio_number,
|
||||||
.level_gpio_num = config->a_gpio_number,
|
.level_gpio_num = config->a_gpio_number,
|
||||||
};
|
};
|
||||||
pcnt_channel_handle_t pcnt_channel_b_handle = NULL;
|
pcnt_channel_handle_t pcnt_channel_b_handle = NULL;
|
||||||
err = pcnt_new_channel(pcnt_unit_handle, &pcnt_chan_b_config, &pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_new_channel(pcnt_unit_handle, &pcnt_chan_b_config, &pcnt_channel_b_handle) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_channel_set_edge_action(pcnt_channel_a_handle, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD) == ESP_OK, ESP_FAIL,
|
||||||
err = pcnt_channel_set_edge_action(pcnt_channel_a_handle, PCNT_CHANNEL_EDGE_ACTION_DECREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_channel_set_level_action(pcnt_channel_a_handle, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_HOLD) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
err = pcnt_channel_set_level_action(pcnt_channel_a_handle, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_HOLD);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_channel_set_edge_action(pcnt_channel_b_handle, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
err = pcnt_channel_set_edge_action(pcnt_channel_b_handle, PCNT_CHANNEL_EDGE_ACTION_INCREASE, PCNT_CHANNEL_EDGE_ACTION_HOLD);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_channel_set_level_action(pcnt_channel_b_handle, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_HOLD) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
err = pcnt_channel_set_level_action(pcnt_channel_b_handle, PCNT_CHANNEL_LEVEL_ACTION_KEEP, PCNT_CHANNEL_LEVEL_ACTION_HOLD);
|
ZH_ERROR_CHECK(pcnt_unit_enable(pcnt_unit_handle) == ESP_OK, ESP_FAIL,
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_unit_clear_count(pcnt_unit_handle) == ESP_OK, ESP_FAIL,
|
||||||
err = pcnt_unit_enable(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_unit_disable(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT unit disable fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
ZH_ERROR_CHECK(pcnt_unit_start(pcnt_unit_handle) == ESP_OK, ESP_FAIL,
|
||||||
err = pcnt_unit_clear_count(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_unit_disable(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT unit disable fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_unit_disable(pcnt_unit_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_a_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT unit disable fail."); err = pcnt_del_channel(pcnt_channel_a_handle);
|
ZH_ERROR_CHECK(pcnt_del_channel(pcnt_channel_b_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete channel fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
ZH_ERROR_CHECK(pcnt_del_unit(pcnt_unit_handle) == ESP_OK, ESP_FAIL, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
|
||||||
err = pcnt_unit_start(pcnt_unit_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, err = pcnt_unit_disable(pcnt_unit_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT unit disable fail."); err = pcnt_del_channel(pcnt_channel_a_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_channel(pcnt_channel_b_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete channel fail."); err = pcnt_del_unit(pcnt_unit_handle);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "PCNT delete unit fail."), "PCNT initialization failed.");
|
|
||||||
if (config->pullup == false)
|
if (config->pullup == false)
|
||||||
{
|
{
|
||||||
err = gpio_pullup_dis((gpio_num_t)config->a_gpio_number);
|
ZH_ERROR_CHECK(gpio_pullup_dis((gpio_num_t)config->a_gpio_number) == ESP_OK, ESP_FAIL, NULL, "GPIO pullup disable fail.");
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Gpio pullup disable fail.");
|
ZH_ERROR_CHECK(gpio_pullup_dis((gpio_num_t)config->b_gpio_number) == ESP_OK, ESP_FAIL, NULL, "GPIO pullup disable fail.");
|
||||||
err = gpio_pullup_dis((gpio_num_t)config->b_gpio_number);
|
|
||||||
ZH_ERROR_CHECK(err == ESP_OK, err, NULL, "Gpio pullup disable fail.");
|
|
||||||
}
|
}
|
||||||
handle->pcnt_unit_handle = pcnt_unit_handle;
|
handle->pcnt_unit_handle = pcnt_unit_handle;
|
||||||
handle->pcnt_channel_a_handle = pcnt_channel_a_handle;
|
handle->pcnt_channel_a_handle = pcnt_channel_a_handle;
|
||||||
|
|||||||
Reference in new issue
Block a user