esp32/machine_adc: Make ADC 2 optional.
Signed-off-by: IhorNehrutsa <IhorNehrutsa@gmail.com>
This commit is contained in:
parent
6d799378ba
commit
32a2c87813
@ -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) {
|
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) {
|
if (self->block->unit_id == ADC_UNIT_1) {
|
||||||
err = adc1_config_channel_atten(self->channel_id, atten);
|
err = adc1_config_channel_atten(self->channel_id, atten);
|
||||||
} else {
|
} else {
|
||||||
|
#if SOC_ADC_PERIPH_NUM >= 2
|
||||||
err = adc2_config_channel_atten(self->channel_id, atten);
|
err = adc2_config_channel_atten(self->channel_id, atten);
|
||||||
|
#endif
|
||||||
}
|
}
|
||||||
if (err != ESP_OK) {
|
if (err != ESP_OK) {
|
||||||
mp_raise_ValueError(MP_ERROR_TEXT("invalid atten"));
|
mp_raise_ValueError(MP_ERROR_TEXT("invalid atten"));
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user