mirror of
https://github.com/espressif/ESP8266_RTOS_SDK.git
synced 2025-08-06 15:15:15 +08:00
fix(adc): fix rf state error when read adc
This commit is contained in:
@ -16,6 +16,7 @@
|
|||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include "freertos/FreeRTOS.h"
|
#include "freertos/FreeRTOS.h"
|
||||||
|
#include "freertos/task.h"
|
||||||
#include "freertos/semphr.h"
|
#include "freertos/semphr.h"
|
||||||
#include "esp_attr.h"
|
#include "esp_attr.h"
|
||||||
#include "esp_err.h"
|
#include "esp_err.h"
|
||||||
@ -51,7 +52,9 @@ esp_err_t adc_read(uint16_t *data)
|
|||||||
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
|
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
|
||||||
|
|
||||||
if (adc_handle->config.mode == ADC_READ_TOUT_MODE) {
|
if (adc_handle->config.mode == ADC_READ_TOUT_MODE) {
|
||||||
|
vTaskSuspendAll();
|
||||||
ret = test_tout(0);
|
ret = test_tout(0);
|
||||||
|
xTaskResumeAll();
|
||||||
|
|
||||||
if (ret != 0xFFFF) {
|
if (ret != 0xFFFF) {
|
||||||
// The working voltage of ADC is designed according to 1.1v. Later, the actual working voltage of ADC is increased to 1.2v, so this scale is added.
|
// The working voltage of ADC is designed according to 1.1v. Later, the actual working voltage of ADC is increased to 1.2v, so this scale is added.
|
||||||
@ -63,7 +66,9 @@ esp_err_t adc_read(uint16_t *data)
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (adc_handle->config.mode == ADC_READ_VDD_MODE) {
|
} else if (adc_handle->config.mode == ADC_READ_VDD_MODE) {
|
||||||
|
vTaskSuspendAll();
|
||||||
ret = phy_get_vdd33();
|
ret = phy_get_vdd33();
|
||||||
|
xTaskResumeAll();
|
||||||
|
|
||||||
if (ret != 0xFFFF) {
|
if (ret != 0xFFFF) {
|
||||||
// The working voltage of ADC is designed according to 1.1v. Later, the actual working voltage of ADC is increased to 1.2v, so this scale is added.
|
// The working voltage of ADC is designed according to 1.1v. Later, the actual working voltage of ADC is increased to 1.2v, so this scale is added.
|
||||||
@ -86,7 +91,9 @@ esp_err_t adc_read_fast(uint16_t *data, uint16_t len)
|
|||||||
uint16_t ret;
|
uint16_t ret;
|
||||||
|
|
||||||
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
|
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
|
||||||
|
vTaskSuspendAll();
|
||||||
phy_adc_read_fast(data, len, adc_handle->config.clk_div);
|
phy_adc_read_fast(data, len, adc_handle->config.clk_div);
|
||||||
|
xTaskResumeAll();
|
||||||
|
|
||||||
for (i = 0; i < len; i++) {
|
for (i = 0; i < len; i++) {
|
||||||
ret = data[i];
|
ret = data[i];
|
||||||
|
Reference in New Issue
Block a user