Skip to content

Commit 32a2c87

Browse files
IhorNehrutsadpgeorge
authored andcommitted
esp32/machine_adc: Make ADC 2 optional.
Signed-off-by: IhorNehrutsa <IhorNehrutsa@gmail.com>
1 parent 6d79937 commit 32a2c87

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

ports/esp32/machine_adc.c

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,11 +148,13 @@ static void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_p
148148
}
149149

150150
static void madc_atten_helper(const machine_adc_obj_t *self, mp_int_t atten) {
151-
esp_err_t err;
151+
esp_err_t err = ESP_FAIL;
152152
if (self->block->unit_id == ADC_UNIT_1) {
153153
err = adc1_config_channel_atten(self->channel_id, atten);
154154
} else {
155+
#if SOC_ADC_PERIPH_NUM >= 2
155156
err = adc2_config_channel_atten(self->channel_id, atten);
157+
#endif
156158
}
157159
if (err != ESP_OK) {
158160
mp_raise_ValueError(MP_ERROR_TEXT("invalid atten"));

0 commit comments

Comments
 (0)