Browse Source

esp32/machine_adc: Make ADC 2 optional.

Signed-off-by: IhorNehrutsa <IhorNehrutsa@gmail.com>
pull/11869/head
IhorNehrutsa 11 months ago
committed by Damien George
parent
commit
32a2c87813
  1. 4
      ports/esp32/machine_adc.c

4
ports/esp32/machine_adc.c

@ -148,11 +148,13 @@ static void mp_machine_adc_print(const mp_print_t *print, mp_obj_t self_in, mp_p
}
static void madc_atten_helper(const machine_adc_obj_t *self, mp_int_t atten) {
esp_err_t err;
esp_err_t err = ESP_FAIL;
if (self->block->unit_id == ADC_UNIT_1) {
err = adc1_config_channel_atten(self->channel_id, atten);
} else {
#if SOC_ADC_PERIPH_NUM >= 2
err = adc2_config_channel_atten(self->channel_id, atten);
#endif
}
if (err != ESP_OK) {
mp_raise_ValueError(MP_ERROR_TEXT("invalid atten"));

Loading…
Cancel
Save