forked from espressif/esp-idf
feat(adc): added an API to flush the continuous driver pool
This commit is contained in:
committed by
Armando (Dou Yiwen)
parent
eb8883cc20
commit
73c9182581
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2016-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2016-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -613,6 +613,21 @@ esp_err_t adc_continuous_register_event_callbacks(adc_continuous_handle_t handle
|
|||||||
return ESP_OK;
|
return ESP_OK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
esp_err_t adc_continuous_flush_pool(adc_continuous_handle_t handle)
|
||||||
|
{
|
||||||
|
ESP_RETURN_ON_FALSE(handle, ESP_ERR_INVALID_ARG, ADC_TAG, "invalid argument");
|
||||||
|
ESP_RETURN_ON_FALSE(handle->fsm == ADC_FSM_INIT, ESP_ERR_INVALID_STATE, ADC_TAG, "ADC continuous mode isn't in the init state, it's started already");
|
||||||
|
|
||||||
|
size_t actual_size = 0;
|
||||||
|
uint8_t *old_data = NULL;
|
||||||
|
|
||||||
|
while ((old_data = xRingbufferReceiveUpTo(handle->ringbuf_hdl, &actual_size, 0, handle->ringbuf_size))) {
|
||||||
|
vRingbufferReturnItem(handle->ringbuf_hdl, old_data);
|
||||||
|
}
|
||||||
|
|
||||||
|
return ESP_OK;
|
||||||
|
}
|
||||||
|
|
||||||
esp_err_t adc_continuous_io_to_channel(int io_num, adc_unit_t * const unit_id, adc_channel_t * const channel)
|
esp_err_t adc_continuous_io_to_channel(int io_num, adc_unit_t * const unit_id, adc_channel_t * const channel)
|
||||||
{
|
{
|
||||||
return adc_io_to_channel(io_num, unit_id, channel);
|
return adc_io_to_channel(io_num, unit_id, channel);
|
||||||
|
@@ -1,5 +1,5 @@
|
|||||||
/*
|
/*
|
||||||
* SPDX-FileCopyrightText: 2015-2022 Espressif Systems (Shanghai) CO LTD
|
* SPDX-FileCopyrightText: 2015-2023 Espressif Systems (Shanghai) CO LTD
|
||||||
*
|
*
|
||||||
* SPDX-License-Identifier: Apache-2.0
|
* SPDX-License-Identifier: Apache-2.0
|
||||||
*/
|
*/
|
||||||
@@ -198,6 +198,20 @@ esp_err_t adc_continuous_stop(adc_continuous_handle_t handle);
|
|||||||
*/
|
*/
|
||||||
esp_err_t adc_continuous_deinit(adc_continuous_handle_t handle);
|
esp_err_t adc_continuous_deinit(adc_continuous_handle_t handle);
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Flush the driver internal pool
|
||||||
|
*
|
||||||
|
* @note This API is not supposed to be called in an ISR context
|
||||||
|
*
|
||||||
|
* @param[in] handle ADC continuous mode driver handle
|
||||||
|
*
|
||||||
|
* @return
|
||||||
|
* - ESP_ERR_INVALID_STATE Driver state is invalid, you should call this API when it's in init state
|
||||||
|
* - ESP_ERR_INVALID_ARG: Invalid arguments
|
||||||
|
* - ESP_OK On success
|
||||||
|
*/
|
||||||
|
esp_err_t adc_continuous_flush_pool(adc_continuous_handle_t handle);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Get ADC channel from the given GPIO number
|
* @brief Get ADC channel from the given GPIO number
|
||||||
*
|
*
|
||||||
|
Reference in New Issue
Block a user