adc: fix out of bound read

when SOC_ADC_PERIPH_NUM==1, the adc_unit should only be assigned with 0
This commit is contained in:
morris 2023-06-09 11:41:16 +08:00
parent f9cf8db97e
commit 3d7f7c32e3

View File

@ -104,7 +104,7 @@ static void adc_dma_intr_handler(void *arg);
static int8_t adc_digi_get_io_num(adc_unit_t adc_unit, uint8_t adc_channel)
{
assert(adc_unit <= SOC_ADC_PERIPH_NUM);
assert(adc_unit < SOC_ADC_PERIPH_NUM);
uint8_t adc_n = (adc_unit == ADC_UNIT_1) ? 0 : 1;
return adc_channel_io_map[adc_n][adc_channel];
}