Skip to content

Commit 0bbd067

Browse files
committed
Revert ADC calibration removal, complete merge
1 parent c624c1e commit 0bbd067

File tree

3 files changed

+9
-16
lines changed

3 files changed

+9
-16
lines changed

ports/esp32s2/Makefile

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -77,6 +77,7 @@ INC += -I../../supervisor/shared/usb
7777
INC += -isystem esp-idf
7878
INC += -isystem esp-idf/components/driver/include
7979
INC += -isystem esp-idf/components/hal/esp32s2/include
80+
INC += -isystem esp-idf/components/driver/esp32s2/include
8081
INC += -isystem esp-idf/components/hal/include
8182

8283
INC += -isystem esp-idf/components/freertos/include/freertos
@@ -97,10 +98,6 @@ INC += -isystem esp-idf/components/newlib/platform_include
9798
INC += -isystem esp-idf/components/lwip/lwip/src/include
9899
INC += -isystem esp-idf/components/lwip/port/esp32/include
99100
INC += -isystem esp-idf/components/lwip/include/apps/sntp
100-
<<<<<<< HEAD
101-
=======
102-
INC += -isystem esp-idf/components/hal/include
103-
>>>>>>> esp32-update-idf
104101
INC += -isystem esp-idf/components/soc/include
105102
INC += -isystem esp-idf/components/soc/src/esp32s2/include
106103
INC += -isystem esp-idf/components/soc/soc/include

ports/esp32s2/common-hal/analogio/AnalogIn.c

Lines changed: 7 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -29,9 +29,9 @@
2929
#include "py/runtime.h"
3030
#include "supervisor/shared/translate.h"
3131

32-
#include "driver/adc.h"
33-
// TODO: Add when ESP-IDF is updated latest version
34-
// #include "esp-idf/components/esp_adc_cal/include/esp_adc_cal.h"
32+
#include "components/driver/include/driver/adc_common.h"
33+
34+
#include "components/esp_adc_cal/include/esp_adc_cal.h"
3535

3636
#include "shared-bindings/microcontroller/Pin.h"
3737

@@ -69,10 +69,9 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
6969
adc2_config_channel_atten((adc2_channel_t)self->pin->adc_channel, ATTENUATION);
7070
}
7171

72-
// TODO: esp_adc_cal is only available in the latest version of the esp-idf. Enable when we update.
7372
// Automatically select calibration process depending on status of efuse
74-
// esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
75-
// esp_adc_cal_characterize(self->pin->adc_index, ATTENUATION, DATA_WIDTH, DEFAULT_VREF, adc_chars);
73+
esp_adc_cal_characteristics_t *adc_chars = calloc(1, sizeof(esp_adc_cal_characteristics_t));
74+
esp_adc_cal_characterize(self->pin->adc_index, ATTENUATION, DATA_WIDTH, DEFAULT_VREF, adc_chars);
7675

7776
uint32_t adc_reading = 0;
7877
//Multisampling
@@ -91,11 +90,8 @@ uint16_t common_hal_analogio_analogin_get_value(analogio_analogin_obj_t *self) {
9190
adc_reading /= NO_OF_SAMPLES;
9291

9392
// This corrects non-linear regions of the ADC range with a LUT, so it's a better reading than raw
94-
// Enable when ESP-IDF is updated
95-
//uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_chars);
96-
//return voltage * ((1 << 16) - 1)/3300;
97-
98-
return adc_reading;
93+
uint32_t voltage = esp_adc_cal_raw_to_voltage(adc_reading, adc_chars);
94+
return voltage * ((1 << 16) - 1)/3300;
9995
}
10096

10197
float common_hal_analogio_analogin_get_reference_voltage(analogio_analogin_obj_t *self) {

ports/esp32s2/common-hal/analogio/AnalogIn.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@
2929

3030
#include "common-hal/microcontroller/Pin.h"
3131

32-
#include "esp-idf/components/soc/include/hal/adc_types.h"
32+
#include "components/soc/include/hal/adc_types.h"
3333
#include "FreeRTOS.h"
3434
#include "freertos/semphr.h"
3535
#include "py/obj.h"

0 commit comments

Comments
 (0)