Skip to content

Commit 7f99618

Browse files
committed
Merge branch 'bugfix/fix_rf_state_error_when_read_adc' into 'master'
fix(adc): fix rf state error when read adc See merge request sdk/ESP8266_RTOS_SDK!1578
2 parents a768f1c + c8a0241 commit 7f99618

File tree

1 file changed

+8
-1
lines changed
  • components/esp8266/driver

1 file changed

+8
-1
lines changed

components/esp8266/driver/adc.c

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
#include <stdint.h>
1717
#include <string.h>
1818
#include "freertos/FreeRTOS.h"
19+
#include "freertos/task.h"
1920
#include "freertos/semphr.h"
2021
#include "esp_attr.h"
2122
#include "esp_err.h"
@@ -51,7 +52,9 @@ esp_err_t adc_read(uint16_t *data)
5152
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
5253

5354
if (adc_handle->config.mode == ADC_READ_TOUT_MODE) {
55+
vTaskSuspendAll();
5456
ret = test_tout(0);
57+
xTaskResumeAll();
5558

5659
if (ret != 0xFFFF) {
5760
// 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)
6366
}
6467
}
6568
} else if (adc_handle->config.mode == ADC_READ_VDD_MODE) {
69+
vTaskSuspendAll();
6670
ret = phy_get_vdd33();
71+
xTaskResumeAll();
6772

6873
if (ret != 0xFFFF) {
6974
// 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)
8691
uint16_t ret;
8792

8893
xSemaphoreTake(adc_handle->adc_mux, portMAX_DELAY);
94+
vTaskSuspendAll();
8995
phy_adc_read_fast(data, len, adc_handle->config.clk_div);
96+
xTaskResumeAll();
9097

9198
for (i = 0; i < len; i++) {
9299
ret = data[i];
@@ -146,4 +153,4 @@ esp_err_t adc_init(adc_config_t *config)
146153
}
147154

148155
return ESP_OK;
149-
}
156+
}

0 commit comments

Comments
 (0)