mirror of
https://github.com/espressif/esp-idf.git
synced 2024-10-05 20:47:46 -04:00
esp_adc: fix dead code reported by coverity
This commit is contained in:
parent
9d0c72aad0
commit
5dbae0c2cd
@ -346,7 +346,7 @@ static IRAM_ATTR bool s_adc_dma_intr(adc_continuous_ctx_t *adc_digi_ctx)
|
||||
//ringbuffer overflow
|
||||
if (adc_digi_ctx->cbs.on_pool_ovf) {
|
||||
adc_continuous_evt_data_t edata = {};
|
||||
if (adc_digi_ctx->cbs.on_conv_done(adc_digi_ctx, &edata, adc_digi_ctx->user_data)) {
|
||||
if (adc_digi_ctx->cbs.on_pool_ovf(adc_digi_ctx, &edata, adc_digi_ctx->user_data)) {
|
||||
need_yield |= true;
|
||||
}
|
||||
}
|
||||
|
@ -21,27 +21,27 @@ static const char *TAG = "adc_lock";
|
||||
static _lock_t adc1_lock;
|
||||
static _lock_t adc2_lock;
|
||||
|
||||
esp_err_t adc_lock_acquire(adc_unit_t unit_mask)
|
||||
esp_err_t adc_lock_acquire(adc_unit_t adc_unit)
|
||||
{
|
||||
if (unit_mask & ADC_UNIT_1) {
|
||||
if (adc_unit == ADC_UNIT_1) {
|
||||
_lock_acquire(&adc1_lock);
|
||||
}
|
||||
|
||||
if (unit_mask & ADC_UNIT_2) {
|
||||
if (adc_unit == ADC_UNIT_2) {
|
||||
_lock_acquire(&adc2_lock);
|
||||
}
|
||||
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t adc_lock_release(adc_unit_t unit_mask)
|
||||
esp_err_t adc_lock_release(adc_unit_t adc_unit)
|
||||
{
|
||||
if (unit_mask & ADC_UNIT_2) {
|
||||
if (adc_unit == ADC_UNIT_2) {
|
||||
ESP_RETURN_ON_FALSE(((uint32_t *)adc2_lock != NULL), ESP_ERR_INVALID_STATE, TAG, "adc2 lock release without acquiring");
|
||||
_lock_release(&adc2_lock);
|
||||
}
|
||||
|
||||
if (unit_mask & ADC_UNIT_1) {
|
||||
if (adc_unit == ADC_UNIT_1) {
|
||||
ESP_RETURN_ON_FALSE(((uint32_t *)adc1_lock != NULL), ESP_ERR_INVALID_STATE, TAG, "adc1 lock release without acquiring");
|
||||
_lock_release(&adc1_lock);
|
||||
}
|
||||
@ -49,15 +49,15 @@ esp_err_t adc_lock_release(adc_unit_t unit_mask)
|
||||
return ESP_OK;
|
||||
}
|
||||
|
||||
esp_err_t adc_lock_try_acquire(adc_unit_t unit_mask)
|
||||
esp_err_t adc_lock_try_acquire(adc_unit_t adc_unit)
|
||||
{
|
||||
if (unit_mask & ADC_UNIT_1) {
|
||||
if (adc_unit == ADC_UNIT_1) {
|
||||
if (_lock_try_acquire(&adc1_lock) == -1) {
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
}
|
||||
|
||||
if (unit_mask & ADC_UNIT_2) {
|
||||
if (adc_unit == ADC_UNIT_2) {
|
||||
if (_lock_try_acquire(&adc2_lock) == -1) {
|
||||
return ESP_ERR_TIMEOUT;
|
||||
}
|
||||
|
@ -20,25 +20,25 @@ extern "C" {
|
||||
*
|
||||
* @note If any of the locks are taken, this API will wait until the lock is successfully acquired.
|
||||
*
|
||||
* @param[in] unit_mask ADC unit mask
|
||||
* @param[in] adc_unit ADC unit ID
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: On success
|
||||
*/
|
||||
esp_err_t adc_lock_acquire(adc_unit_t unit_mask);
|
||||
esp_err_t adc_lock_acquire(adc_unit_t adc_unit);
|
||||
|
||||
/**
|
||||
* @brief Release ADC lock by unit
|
||||
*
|
||||
* The lock releasing sequence will be: ..., ADC2, ADC1
|
||||
*
|
||||
* @param[in] unit_mask ADC unit mask
|
||||
* @param[in] adc_unit ADC unit ID
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: On success
|
||||
* - ESP_ERR_INVALID_STATE: The lock(s) isn't acquired yet
|
||||
*/
|
||||
esp_err_t adc_lock_release(adc_unit_t unit_mask);
|
||||
esp_err_t adc_lock_release(adc_unit_t adc_unit);
|
||||
|
||||
/**
|
||||
* @brief Try to acquire ADC lock by unit
|
||||
@ -47,13 +47,13 @@ esp_err_t adc_lock_release(adc_unit_t unit_mask);
|
||||
*
|
||||
* @note If any of the locks are taken, this API will return immediately with an error `ESP_ERR_TIMEOUT`
|
||||
*
|
||||
* @param[in] unit_mask ADC unit mask
|
||||
* @param[in] adc_unit ADC unit ID
|
||||
*
|
||||
* @return
|
||||
* - ESP_OK: On success
|
||||
* - ESP_ERR_TIMEOUT: Lock(s) is taken already
|
||||
*/
|
||||
esp_err_t adc_lock_try_acquire(adc_unit_t unit_mask);
|
||||
esp_err_t adc_lock_try_acquire(adc_unit_t adc_unit);
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user